@Override public void getNext(CAS aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); try (InputStream is = new BufferedInputStream( CompressionUtils.getInputStream(res.getLocation(), res.getInputStream()))) { String text; if (ENCODING_AUTO.equals(sourceEncoding)) { CharsetDetector detector = new CharsetDetector(); text = IOUtils.toString(detector.getReader(is, null)); } else { text = IOUtils.toString(is, sourceEncoding); } aJCas.setDocumentText(text); } } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); goldLabelMap = new HashMap<String, List<String>>(); try { URL resourceUrl = ResourceUtils.resolveLocation(goldLabelFile, this, context); for (String line : FileUtils.readLines(new File(resourceUrl.toURI()), "utf-8")) { String[] parts = line.split(" "); if (parts.length < 2) { throw new IOException("Wrong file format in line: " + line); } String fileId = parts[0].split("/")[1]; List<String> labels = new ArrayList<String>(); for (int i = 1; i < parts.length; i++) { labels.add(parts[i]); } goldLabelMap.put(fileId, labels); } } catch (IOException e) { throw new ResourceInitializationException(e); } catch (URISyntaxException ex) { throw new ResourceInitializationException(ex); } }
@Override public void getNext(CAS aCAS) throws IOException, CollectionException { super.getNext(aCAS); JCas jcas; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(); } for (String outcomeValue : getTextClassificationOutcomes(jcas)) { TextClassificationOutcome outcome = new TextClassificationOutcome(jcas); outcome.setOutcome(outcomeValue); outcome.addToIndexes(); } }
@Override public void getNext(CAS aCAS) throws IOException, CollectionException { super.getNext(aCAS); JCas jcas; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(); } TextClassificationOutcome outcome = new TextClassificationOutcome(jcas); outcome.setOutcome(getTextClassificationOutcome(jcas)); outcome.addToIndexes(); } }
@Override public void getNext(CAS aCAS) throws IOException, CollectionException { super.getNext(aCAS); JCas jcas; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(); } for (String outcomeValue : getTextClassificationOutcomes(jcas)) { TextClassificationOutcome outcome = new TextClassificationOutcome(jcas); outcome.setOutcome(outcomeValue); outcome.addToIndexes(); } } }