/** * @throws Exception */ private void updateCurrentFiles() throws Exception { currentSectionFiles = IOUtils.ls(combinedWSJHome + "/" + sections[currentSectionId]); currentSectionId++; }
/** * @throws Exception */ private void updateCurrentFiles() throws Exception { currentSectionFiles = IOUtils.ls(combinedWSJHome + "/" + sections[currentSectionId]); currentSectionId++; }
/** * List the directories contained within a directory. */ public static String[] lsDirectories(String directory) throws Exception { String[] tmp = ls(directory); ArrayList<String> files = new ArrayList<>(); for (String s : tmp) { if (isDirectory(directory + File.separator + s)) files.add(s); } return files.toArray(new String[files.size()]); }
/** * List the directories contained within a directory. */ public static String[] lsDirectories(String directory) throws Exception { String[] tmp = ls(directory); ArrayList<String> files = new ArrayList<>(); for (String s : tmp) { if (isDirectory(directory + File.separator + s)) files.add(s); } return files.toArray(new String[files.size()]); }
/** * Empty a directory without deleting it * * @param directory The directory to be cleaned * @return true only if cleaning was successful */ public static boolean cleanDir(String directory) throws IOException { String[] files = ls(directory); boolean clean = true; // Some JVMs return null for empty dirs if (files != null) { for (String f : files) { String filename = directory + File.separator + f; File file = new File(filename); if (file.isDirectory()) clean = cleanDir(filename) && file.delete(); else clean = file.delete(); } } return clean; }
/** * Empty a directory without deleting it * * @param directory The directory to be cleaned * @return true only if cleaning was successful */ public static boolean cleanDir(String directory) throws IOException { String[] files = ls(directory); boolean clean = true; // Some JVMs return null for empty dirs if (files != null) { for (String f : files) { String filename = directory + File.separator + f; File file = new File(filename); if (file.isDirectory()) clean = cleanDir(filename) && file.delete(); else clean = file.delete(); } } return clean; }
@Override protected void initializeReader() { String[] files = new String[0]; this.textAnnotations = new ArrayList<>(); String corpusdirectory = this.resourceManager.getString(CorpusReaderConfigurator.SOURCE_DIRECTORY.key); // In case the input argument is a single file if (!IOUtils.isDirectory(corpusdirectory)) { files = new String[] {corpusdirectory}; } else { try { files = IOUtils.ls(corpusdirectory); Arrays.sort(files); for (int i = 0; i < files.length; i++) { files[i] = Paths.get(corpusdirectory, files[i]).toString(); } } catch (IOException e) { logger.error("Error listing directory."); logger.error(e.getMessage()); } } try { for (String file : files) { textAnnotations.add(loadCoNLLfile(file)); } } catch (IOException e) { logger.error("Error reading file."); logger.error(e.getMessage()); } }
@Override protected void initializeReader() { String[] files = new String[0]; this.textAnnotations = new ArrayList<>(); String corpusdirectory = this.resourceManager.getString(CorpusReaderConfigurator.SOURCE_DIRECTORY.key); // In case the input argument is a single file if (!IOUtils.isDirectory(corpusdirectory)) { files = new String[] {corpusdirectory}; } else { try { files = IOUtils.ls(corpusdirectory); Arrays.sort(files); for (int i = 0; i < files.length; i++) { files[i] = Paths.get(corpusdirectory, files[i]).toString(); } } catch (IOException e) { logger.error("Error listing directory."); logger.error(e.getMessage()); } } try { for (String file : files) { textAnnotations.add(loadColumnfile(file)); } } catch (IOException e) { logger.error("Error reading file."); logger.error(e.getMessage()); } }
@Override protected void initializeReader() { String[] files = new String[0]; this.textAnnotations = new ArrayList<>(); String corpusdirectory = this.resourceManager.getString(CorpusReaderConfigurator.SOURCE_DIRECTORY.key); // In case the input argument is a single file if (!IOUtils.isDirectory(corpusdirectory)) { files = new String[] {corpusdirectory}; } else { try { files = IOUtils.ls(corpusdirectory); Arrays.sort(files); for (int i = 0; i < files.length; i++) { files[i] = Paths.get(corpusdirectory, files[i]).toString(); } } catch (IOException e) { logger.error("Error listing directory."); logger.error(e.getMessage()); } } try { for (String file : files) { textAnnotations.add(loadCoNLLfile(file)); } } catch (IOException e) { logger.error("Error reading file."); logger.error(e.getMessage()); } }
} else { try { files = IOUtils.ls(ontonotesDirectory); for (int i = 0; i < files.length; i++) { files[i] = Paths.get(ontonotesDirectory, files[i]).toString();
} else { try { files = IOUtils.ls(ontonotesDirectory); for (int i = 0; i < files.length; i++) { files[i] = Paths.get(ontonotesDirectory, files[i]).toString();