/** * Get the URI that the text in this class was loaded from */ protected URI getTextURI(JCas jCas) { String textPath = JCasUtil.selectSingle(jCas, DocumentID.class).getDocumentID(); if (this.textDirectory != null) { textPath = this.textDirectory + File.separator + textPath; } File tmpFile = new File(textPath); URI answer = tmpFile.toURI(); return answer; }
private boolean isTheSameDocument(JCas aView) { DocumentMetaData meta = JCasUtil.selectSingle(aView, DocumentMetaData.class); String currentId = meta.getDocumentId(); boolean isSame = currentId.equals(lastSeenDocumentId); lastSeenDocumentId = currentId; return isSame; }
protected Writer getWriter(JCas jcas, String suffix) throws IOException { return new FileWriter( new File(outputDirectory, JCasUtil.selectSingle(jcas, Drama.class).getDocumentId() + suffix)); } }
/** * Returns the pair ID from a JCas created by an EOP LAP. * @param jcas * @return */ public static String getPairIdFromCas(JCas jcas) { Pair pairAnno = JCasUtil.selectSingle(jcas, Pair.class); return pairAnno.getPairID(); } }
private boolean isTheSameDocument(JCas aJCas) { JCasId casId = JCasUtil.selectSingle(aJCas, JCasId.class); String currentId = casId.getId() + ""; boolean isSame = currentId.equals(lastSeenDocumentId); lastSeenDocumentId = currentId; return isSame; }
private static String getFullId(JCas jcas) throws TextClassificationException { JCasId jcasId = JCasUtil.selectSingle(jcas, JCasId.class); return "" + jcasId.getId(); } }
private static String getFullId(JCas jcas) throws TextClassificationException { JCasId jcasId = JCasUtil.selectSingle(jcas, JCasId.class); return "" + jcasId.getId(); } }
@Override protected List<SourceTargetPair> getSourceTargetPairs(JCas jCas) { List<SourceTargetPair> pairs = Lists.newArrayList(); DocumentCreationTime dct = JCasUtil.selectSingle(jCas, DocumentCreationTime.class); for (Sentence sentence : JCasUtil.select(jCas, Sentence.class)) { for (Event event : JCasUtil.selectCovered(jCas, Event.class, sentence)) { pairs.add(new SourceTargetPair(event, dct)); } } return pairs; } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { DocumentMetaData dmd = JCasUtil.selectSingle(aJCas, DocumentMetaData.class); try { bw.write(dmd.getDocumentId() + "\t" + aJCas.getDocumentText() + "\n"); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { DocumentMetaData dmd = JCasUtil.selectSingle(aJCas, DocumentMetaData.class); try { bw.write(dmd.getDocumentId() + "\t" + aJCas.getDocumentText() + "\n"); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
private CASMetadata getCasMetadata(CAS aCas) throws RecommendationException { try { return JCasUtil.selectSingle(aCas.getJCas(), CASMetadata.class); } catch (CASException | IllegalArgumentException e) { throw new RecommendationException("Error while reading CAS metadata!", e); } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { int pmId = getHeaderIntDocId(jCas); DocumentSpecies docSpecies = selectSingle(jCas, DocumentSpecies.class); String msg = pmId + "\t" + docSpecies.getFamilyName(); for (LinnaeusSpecies species : select(jCas, LinnaeusSpecies.class)) { msg += "\t" + species.getMostProbableSpeciesId() + "\t" + species.getCoveredText().replaceAll("\t", " "); } LOG.debug(msg); }
public static Drama getDrama(JCas jcas) { if (JCasUtil.exists(jcas, Drama.class)) { return JCasUtil.selectSingle(jcas, Drama.class); } else { Drama d = new Drama(jcas); d.addToIndexes(); return d; } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { getLogger().log(Level.INFO, "--- meta collection on CAS with id [" + JCasUtil.selectSingle(jcas, JCasId.class).getId() + "] ---"); }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { getLogger().log(Level.FINE, "--- preprocessing of CAS with id [" + JCasUtil.selectSingle(aJCas, JCasId.class).getId() + "] ---"); nrofProcessCalls++; getLogger().log(Level.FINE, "--- preprocessing of CAS with id [" + JCasUtil.selectSingle(aJCas, JCasId.class).getId() + "] complete ---"); }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
protected TemplateRecord assertRecordCoversParas2to4() { TemplateRecord record = JCasUtil.selectSingle(jCas, TemplateRecord.class); assertEquals(52, record.getBegin()); assertEquals(212, record.getEnd()); assertEquals(String.join("\n", "", PARA2, PARA3, PARA4, ""), record.getCoveredText()); return record; }
public void assertLocationMatches() { final Location inLocation = JCasUtil.selectSingle(in, Location.class); final Location outLocation = JCasUtil.selectSingle(out, Location.class); assertEquals(inLocation.getGeoJson(), outLocation.getGeoJson()); assertEquals(inLocation.getBegin(), outLocation.getBegin()); assertEquals(inLocation.getEnd(), outLocation.getEnd()); assertEquals(inLocation.getValue(), outLocation.getValue()); assertEquals(0, inLocation.getConfidence(), outLocation.getConfidence()); }