/** * List the files contained in a directory. */ public static String[] lsFiles(String directory) throws IOException { return lsFiles(directory, new FilenameFilter() { @Override public boolean accept(File dir, String name) { return true; } }); }
/** * List the files contained in a directory. */ public static String[] lsFiles(String directory) throws IOException { return lsFiles(directory, new FilenameFilter() { @Override public boolean accept(File dir, String name) { return true; } }); }
private void readPropbankFrameData(String dir) throws Exception { frameData = new HashMap<>(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(false); dbf.setValidating(false); for (String file : IOUtils.lsFiles(dir, (dir1, name) -> name.endsWith("xml"))) { // IOUtils.getFileName(file) doesn't work in Windows int slashIndex = file.lastIndexOf(File.separator); String fileName = file.substring(slashIndex + 1); // A hack to deal with percent-sign in nombank. There is another // file called perc-sign that will fill this void. if (fileName.contains("percent-sign.xml")) continue; DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(file); NodeList predicateElements = doc.getElementsByTagName("predicate"); for (int i = 0; i < predicateElements.getLength(); i++) { String lemma = IOUtils.stripFileExtension(fileName); FrameData fData = new FrameData(lemma); frameData.put(lemma, fData); NodeList roleSets = doc.getElementsByTagName("roleset"); addRoleSets(fileName, lemma, fData, roleSets); } } }
String[] files; try { files = IOUtils.lsFiles(dataFolder); } catch (Exception e) { e.printStackTrace();
inFiles = IOUtils.lsFiles(inDir); } catch (IOException e) { e.printStackTrace();
inFiles = IOUtils.lsFiles(inDir); } catch (IOException e) { e.printStackTrace();
files = IOUtils.lsFiles(directory, new FilenameFilter() { @Override public boolean accept(File dir, String name) {
/** * A table is built from either a given source corpus file or source corpus directory by simply * counting the number of times that each form-POS association appear in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by * counting the number of times that each suffix-POS association in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by * counting the number of times that each suffix-POS association in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by simply * counting the number of times that each form-POS association appear in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }