/** * An implementation of {@code readGZip(String, Transformer<String, T>)}. This function reads * the lines in a gzipped file and returns them. * * @param fileName The name of the file to be read * @return An arraylist of the lines of the file. */ public static ArrayList<String> readGZip(String fileName) throws IOException { return readGZip(fileName, identityTransformer); }
/** * An implementation of {@code readGZip(String, Transformer<String, T>)}. This function reads * the lines in a gzipped file and returns them. * * @param fileName The name of the file to be read * @return An arraylist of the lines of the file. */ public static ArrayList<String> readGZip(String fileName) throws IOException { return readGZip(fileName, identityTransformer); }
public TweetReader(String dataFile) { tweets = new ArrayList<>(); List<String> lines = null; try { lines = LineIO.readGZip(dataFile); } catch (IOException e) { System.err.println("Unable to read " + dataFile + ". Exiting..."); System.exit(-1); } for (String line : lines) { if (!line.isEmpty()) tweets.add(new Tweet(line.split(","))); } }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { Set<Feature> features = new LinkedHashSet<>(); List<String> nomFrames; try { URL file = IOUtils.lsResources(WordFeatureExtractorFactory.class, "nombank.list.gz") .get(0); nomFrames = LineIO.readGZip(file.getFile()); String lemma = WordHelpers.getLemma(ta, wordPosition); if (nomFrames.contains(lemma)) { features.add(isNom); } } catch (Exception e) { System.err.println("Could not read nombank.list.gz file from classpath"); e.printStackTrace(); } return features; } };
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { Set<Feature> features = new LinkedHashSet<>(); List<String> nomFrames; try { URL file = IOUtils.lsResources(WordFeatureExtractorFactory.class, "nombank.list.gz") .get(0); nomFrames = LineIO.readGZip(file.getFile()); String lemma = WordHelpers.getLemma(ta, wordPosition); if (nomFrames.contains(lemma)) { features.add(isNom); } } catch (Exception e) { System.err.println("Could not read nombank.list.gz file from classpath"); e.printStackTrace(); } return features; } };