@Override public void initialize(UimaContext context) throws ResourceInitializationException { articleIds = new HashSet<String>(); try { if (articleIdsListFile == null) { filterArticles = false; } else { filterArticles = true; String[] ids = FileUtil.loadListOfStrings(articleIdsListFile); for (String id : ids) { articleIds.add(id); } } parser = new GeniaPosParser(geniaCorpusFile); loadPosTags = loadTokens & loadPosTags; } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } catch (JDOMException je) { throw new ResourceInitializationException(je); } }
/** * Loads a list of non-empty EOL-delimited strings from a given text file using the default file * encoding. * * @param textFile * The given text file. * @return The array of non-empty strings loaded from the given text file. * @throws IOException * If any I/O exception occurred. */ public static String[] loadListOfStrings(File textFile) throws IOException { BufferedReader iStream = null; String[] outputArray = null; try { iStream = new BufferedReader(new InputStreamReader(new FileInputStream(textFile))); outputArray = loadListOfStrings(iStream); } catch (IOException exc) { throw exc; } finally { if (iStream != null) { try { iStream.close(); } catch (Exception e) { } } } return (outputArray != null) ? outputArray : new String[0]; }
/** * Loads a list of non-empty EOL-delimited strings from a given remote text file. * * @param textFileURL * The URL of the given input text file. * @return The array of non-empty strings loaded from the given text file. * @throws IOException * If any I/O exception occurred. */ public static String[] loadListOfStrings(URL textFileURL) throws IOException { URLConnection urlConnection = textFileURL.openConnection(); // See https://issues.apache.org/jira/browse/UIMA-1746 urlConnection.setUseCaches(false); BufferedReader iStream = null; String[] outputArray = null; try { iStream = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); outputArray = loadListOfStrings(iStream); } catch (IOException exc) { throw exc; } finally { if (iStream != null) { try { iStream.close(); } catch (Exception e) { } } } return (outputArray != null) ? outputArray : new String[0]; }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { articleIds = new HashSet<String>(); try { if (articleIdsListFile == null) { filterArticles = false; } else { filterArticles = true; String[] ids = FileUtil.loadListOfStrings(articleIdsListFile); for (String id : ids) { articleIds.add(id); } } parser = new GeniaPosParser(geniaCorpusFile); loadPosTags = loadTokens & loadPosTags; } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } catch (JDOMException je) { throw new ResourceInitializationException(je); } }
try { for (String fileNamesList : nameFilesFileNames) { fileNamesFromLists.addAll(Arrays.asList(FileUtil.loadListOfStrings(new File(fileNamesList))));
try { for (String fileNamesList : nameFilesFileNames) { fileNamesFromLists.addAll(Arrays.asList(FileUtil.loadListOfStrings(new File(fileNamesList))));