filter = new NumberRangesFileFilter(args[argIndex++], true); } else if (numSubArgs == 3) { try { } catch (NumberFormatException e) { filter = new NumberRangesFileFilter(args[argIndex++], true);
private static boolean checkFile(EnumMap<FilterType, String> filters, File file) { String fileName = file.getName(); if(isLikelyInvisible(fileName)) return false; if(filters.containsKey(FilterType.hasExtension)) { String ext = filters.get(FilterType.hasExtension); if(!fileName.endsWith(ext)) { return false; } } if(filters.containsKey(FilterType.hasPrefix)) { String pre = filters.get(FilterType.hasPrefix); if(!fileName.startsWith(pre)) return false; } if(filters.containsKey(FilterType.isInRange)) { NumberRangesFileFilter f = new NumberRangesFileFilter(filters.get(FilterType.isInRange), false); if(!f.accept(fileName)) return false; } return true; }
treeRange.toString().replaceAll(",", ":"));
/** * Checks whether a file satisfies the number range selection filter. * The test is evaluated based on the rightmost natural number found in * the filename string (proper, not including directories in a path). * * @param file The file * @return true If the file is within the ranges filtered for */ public boolean accept(File file) { if (file.isDirectory()) { return recursively; } else { String filename = file.getName(); return accept(filename); } }
/** * Checks whether a file satisfies the number range selection filter. * The test is evaluated based on the rightmost natural number found in * the filename string (proper, not including directories in a path). * * @param file The file * @return true If the file is within the ranges filtered for */ public boolean accept(File file) { if (file.isDirectory()) { return recursively; } else { String filename = file.getName(); return accept(filename); } }
try { new NumberRangesFileFilter(filters.get(FilterType.isInRange), false); } catch(Exception e) { JOptionPane.showMessageDialog(dialog, new JLabel("<html>Please check the range you specified for the file number. Ranges must be numerical, and disjoint <br>ranges should be separated by commas. For example \"1-200,250-375\" is a valid range.</html>"), "Error in File Number Range", JOptionPane.ERROR_MESSAGE);
private static boolean checkFile(EnumMap<FilterType, String> filters, File file) { String fileName = file.getName(); if(isLikelyInvisible(fileName)) return false; if(filters.containsKey(FilterType.hasExtension)) { String ext = filters.get(FilterType.hasExtension); if(!fileName.endsWith(ext)) { return false; } } if(filters.containsKey(FilterType.hasPrefix)) { String pre = filters.get(FilterType.hasPrefix); if(!fileName.startsWith(pre)) return false; } if(filters.containsKey(FilterType.isInRange)) { NumberRangesFileFilter f = new NumberRangesFileFilter(filters.get(FilterType.isInRange), false); if(!f.accept(fileName)) return false; } return true; }
/** * Checks whether a file satisfies the number range selection filter. * The test is evaluated based on the rightmost natural number found in * the filename string (proper, not including directories in a path). * * @param file The file * @return true If the file is within the ranges filtered for */ public boolean accept(File file) { if (file.isDirectory()) { return recursively; } else { String filename = file.getName(); return accept(filename); } }
treeRange.toString().replaceAll(",", ":"));
} else if (argPieces[0].equalsIgnoreCase(TREE_RANGE)) { String range = argPieces[1].replaceAll(":", ","); treeRange = new NumberRangesFileFilter(range, true); } else if (argPieces[0].equalsIgnoreCase(TREE_FILTER)) { treeFilter = ReflectionLoading.loadByReflection(argPieces[1]);
/** * Checks whether a file satisfies the number range selection filter. * The test is evaluated based on the rightmost natural number found in * the filename string (proper, not including directories in a path). * * @param file The file * @return true If the file is within the ranges filtered for */ public boolean accept(File file) { if (file.isDirectory()) { return recursively; } else { String filename = file.getName(); return accept(filename); } }
treeRange.toString().replaceAll(",", ":"));
tb.loadPath(args[0], new NumberRangesFileFilter(args[1], true));
/** * Checks whether a file satisfies the number range selection filter. * The test is evaluated based on the rightmost natural number found in * the filename string (proper, not including directories in a path). * * @param file The file * @return true If the file is within the ranges filtered for */ public boolean accept(File file) { if (file.isDirectory()) { return recursively; } else { String filename = file.getName(); return accept(filename); } }
treeRange.toString().replaceAll(",", ":"));
FileFilter trainFilt = new NumberRangesFileFilter(args[1], false); FileFilter testFilt = new NumberRangesFileFilter(args[2], false); MemoryTreebank testTreebank = ctpp.memoryTreebank(); testTreebank.loadPath(new File(args[0]), testFilt);
/** * For testing: loads a treebank and prints the trees. */ public static void main(String[] args) { TreebankLangParserParams tlpp = new ChineseTreebankParserParams(); System.out.println("Default encoding is: " + tlpp.diskTreebank().encoding()); if (args.length < 2) { printlnErr("Usage: edu.stanford.nlp.parser.lexparser.ChineseTreebankParserParams treesPath fileRange"); } else { Treebank m = tlpp.diskTreebank(); m.loadPath(args[0], new NumberRangesFileFilter(args[1], false)); for (Tree t : m ) { t.pennPrint(tlpp.pw()); } System.out.println("There were " + m.size() + " trees."); } }
treebank.loadPath(args[i], new NumberRangesFileFilter(args[i+1], true)); } else if (i < args.length) { treebank.loadPath(args[i], suffix, true);
trainFilter = new NumberRangesFileFilter(args[i++], true); } else if (numSubArgs >= 3) { int low = Integer.parseInt(args[i]);
String[] statArgs = (argMap.get("-stats")); MemoryTreebank rawTrainTreebank = op.tlpParams.memoryTreebank(); FileFilter trainFilt = new NumberRangesFileFilter(statArgs[1], false); rawTrainTreebank.loadPath(new File(statArgs[0]), trainFilt); log.info("Done reading trees."); String[] parserArgs = (argMap.get("-parser")); if (parserArgs.length > 1) { FileFilter trainFilt = new NumberRangesFileFilter(parserArgs[1], false); lp = LexicalizedParser.trainFromTreebank(parserArgs[0], trainFilt, op); if (parserArgs.length == 3) { lex = ctpp.lex(op, wordIndex, tagIndex); MemoryTreebank rawTrainTreebank = op.tlpParams.memoryTreebank(); FileFilter trainFilt = new NumberRangesFileFilter(lexArgs[1], false); rawTrainTreebank.loadPath(new File(lexArgs[0]), trainFilt); log.info("Done reading trees."); FileFilter testFilt = new NumberRangesFileFilter(testArgs[1], false); testTreebank.loadPath(new File(testArgs[0]), testFilt); TreeTransformer subcategoryStripper = op.tlpParams.subcategoryStripper();