Search in sources :

Example 11 with NumberRangesFileFilter

use of edu.stanford.nlp.io.NumberRangesFileFilter in project CoreNLP by stanfordnlp.

the class ArgUtils method getWeightedTreebankDescription.

public static Triple<String, FileFilter, Double> getWeightedTreebankDescription(String[] args, int argIndex, String flag) {
    String path = null;
    FileFilter filter = null;
    Double weight = 1.0;
    // the next arguments are the treebank path and maybe the range for testing
    int numSubArgs = numSubArgs(args, argIndex);
    if (numSubArgs > 0 && numSubArgs < 4) {
        argIndex++;
        path = args[argIndex++];
        boolean hasWeight = false;
        if (numSubArgs > 1 && DOUBLE_PATTERN.matcher(args[argIndex + numSubArgs - 2]).matches()) {
            weight = Double.parseDouble(args[argIndex + numSubArgs - 2]);
            hasWeight = true;
            numSubArgs--;
        }
        if (numSubArgs == 2) {
            filter = new NumberRangesFileFilter(args[argIndex++], true);
        } else if (numSubArgs == 3) {
            try {
                int low = Integer.parseInt(args[argIndex]);
                int high = Integer.parseInt(args[argIndex + 1]);
                filter = new NumberRangeFileFilter(low, high, true);
                argIndex += 2;
            } catch (NumberFormatException e) {
                // maybe it's a ranges expression?
                filter = new NumberRangesFileFilter(args[argIndex++], true);
            }
        }
        if (hasWeight) {
            argIndex++;
        }
    } else {
        throw new IllegalArgumentException("Bad arguments after " + flag);
    }
    return Triple.makeTriple(path, filter, weight);
}
Also used : NumberRangeFileFilter(edu.stanford.nlp.io.NumberRangeFileFilter) NumberRangesFileFilter(edu.stanford.nlp.io.NumberRangesFileFilter) NumberRangesFileFilter(edu.stanford.nlp.io.NumberRangesFileFilter) FileFilter(java.io.FileFilter) NumberRangeFileFilter(edu.stanford.nlp.io.NumberRangeFileFilter)

Aggregations

NumberRangesFileFilter (edu.stanford.nlp.io.NumberRangesFileFilter)11 NumberRangeFileFilter (edu.stanford.nlp.io.NumberRangeFileFilter)3 TaggedWord (edu.stanford.nlp.ling.TaggedWord)3 Tree (edu.stanford.nlp.trees.Tree)3 FileFilter (java.io.FileFilter)3 HasWord (edu.stanford.nlp.ling.HasWord)2 Word (edu.stanford.nlp.ling.Word)2 TreeTransformer (edu.stanford.nlp.trees.TreeTransformer)2 Treebank (edu.stanford.nlp.trees.Treebank)2 HashIndex (edu.stanford.nlp.util.HashIndex)2 File (java.io.File)2 StringLabel (edu.stanford.nlp.ling.StringLabel)1 ChineseTreebankParserParams (edu.stanford.nlp.parser.lexparser.ChineseTreebankParserParams)1 LexicalizedParser (edu.stanford.nlp.parser.lexparser.LexicalizedParser)1 Options (edu.stanford.nlp.parser.lexparser.Options)1 WordSegmenter (edu.stanford.nlp.process.WordSegmenter)1 EquivalenceClassEval (edu.stanford.nlp.stats.EquivalenceClassEval)1 DiskTreebank (edu.stanford.nlp.trees.DiskTreebank)1 MemoryTreebank (edu.stanford.nlp.trees.MemoryTreebank)1 TreeNormalizer (edu.stanford.nlp.trees.TreeNormalizer)1