/** * {@inheritDoc} */ @Override public void process( final CAS aCAS ) throws AnalysisEngineProcessException { try { final JCas jcas = aCAS.getJCas(); process( jcas ); } catch ( CASException casE ) { throw new AnalysisEngineProcessException( casE ); } }
public void process(JCas jcas) { try { ttw.process(jcas); } catch(AnalysisEngineProcessException e) { e.printStackTrace(); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { PrintWriter out = null; try { out = new PrintWriter(new OutputStreamWriter(getOutputStream(aJCas, filenameSuffix), targetEncoding)); convert(aJCas, out); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } finally { closeQuietly(out); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { Collection<JCoReURI> jcoreUris = JCasUtil.select(aJCas, JCoReURI.class); if (log.isDebugEnabled()) log.debug("Received batch of {} NXML URIs", jcoreUris.size()); currentUriBatch = jcoreUris.stream().map(JCoReURI::getUri).map(URI::create).iterator(); try { casPopulator = new CasPopulator(currentUriBatch); } catch (IOException e) { log.error("Exception occurred when trying to inizialize the NXML parser", e); throw new AnalysisEngineProcessException(e); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { try (OutputStream docOS = getOutputStream(aJCas, filenameSuffix)) { IOUtils.write(aJCas.getDocumentText(), docOS, targetEncoding); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { JCas srcView, tgtView; try { srcView = aJCas.getView(sourceViewName); tgtView = aJCas.getView(targetViewName); for (Annotation a : JCasUtil.select(srcView, clazz)) { AnnotationFactory.createAnnotation(tgtView, a.getBegin(), a.getEnd(), clazz); } } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { JCas goldView; try { goldView = jCas.getView("GoldView"); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } JCas systemView; try { systemView = jCas.getView("_InitialView"); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } // iterate over sentences in case the context is needed for(Sentence sentence : JCasUtil.select(systemView, Sentence.class)) { List<EventMention> events = JCasUtil.selectCovered(goldView, EventMention.class, sentence); List<EntityMention> entities = JCasUtil.selectCovered(goldView, EntityMention.class, sentence); } } }
@Override public void process( JCas jCas ) throws AnalysisEngineProcessException { try { JCas goldView = jCas.getView( GOLD_VIEW_NAME ); goldView.setDocumentText( jCas.getDocumentText() ); } catch ( CASException e ) { throw new AnalysisEngineProcessException( e ); } } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { try{ logger.debug("Entering annotator WSDAnnotatorBaseDocumentCollective."); Map<WSDItem, Map<String, Double>> disambiguationResults = getDisambiguation(JCasUtil .select(aJCas, WSDItem.class), aJCas.getDocumentText()); for (WSDItem wsdItem : disambiguationResults.keySet()) { if (maxItemsAttempted >= 0 && numItemsAttempted++ >= maxItemsAttempted) { return; } setWSDItem(aJCas, wsdItem, disambiguationResults.get(wsdItem)); } } catch (SenseInventoryException e) { throw new AnalysisEngineProcessException(e); } } }
public static String toTimeML(JCas jCas) throws AnalysisEngineProcessException { try { return toXML(jCas.getCas(), new TimeMlAnnotationsToElements()); } catch (SAXException e) { throw new AnalysisEngineProcessException(e); } }
throw new AnalysisEngineProcessException( new Exception("No name type or valid name type mapping configured!"));
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { for (POS pos : select(aJCas, POS.class)) { for (Token token : JCasUtil.selectCovered(aJCas, Token.class, pos)) { try { String semanticField = ubySemanticFieldResource.getSemanticTag(token); SemanticField semanticFieldAnnotation = new SemanticField(aJCas, token.getBegin(), token.getEnd()); semanticFieldAnnotation.setValue(semanticField); semanticFieldAnnotation.addToIndexes(); } catch (ResourceAccessException 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); } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { try { converter.add(jcas, inputPaths, jcas.getCas().getTypeSystem().getType(contextType)); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
private static String[] lines(JCas jCas, String viewName) throws AnalysisEngineProcessException { JCas view; try { view = jCas.getView(viewName); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } String text = view.getDocumentText(); if (text == null) { throw new IllegalArgumentException("no text in view " + viewName); } return text.length() > 0 ? text.split("\n") : new String[0]; }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { JCas systemView; try { systemView = jCas.getView(CAS.NAME_DEFAULT_SOFA); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } for(BinaryTextRelation binaryTextRelation : JCasUtil.select(systemView, BinaryTextRelation.class)) { IdentifiedAnnotation entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument(); IdentifiedAnnotation entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument(); String category = binaryTextRelation.getCategory(); String arg1 = entity1.getCoveredText().toLowerCase(); String arg2 = entity2.getCoveredText().toLowerCase(); List<Sentence> enclosingSentences = JCasUtil.selectCovering( systemView, Sentence.class, entity1.getBegin(), entity2.getEnd()); System.out.format("%s|%s|%s|%s\n", category, arg1, arg2, enclosingSentences.get(0).getCoveredText()); } } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { DocumentMetadata meta = JCasUtil.selectSingle(jCas, DocumentMetadata.class); OutputStream out = null; try { out = getOutputStream(meta); writeXmi(jCas.getCas(), out); } catch (IOException | SAXException e) { throw new AnalysisEngineProcessException(e); } finally { afterXMIWritten(out); } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { String id = new File(ViewUriUtil.getURI(jCas)).getName(); File outFile = new File(this.outputDirectory, id + ".txt"); try { FileUtils.saveString2File(jCas.getDocumentText(), outFile); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
private void getFeatureNames(JCas aJCas) throws AnalysisEngineProcessException { LogFactory.getLog(getClass()).info("--- collecting feature names ---"); // We run one time through feature extraction to get all features names try { // Create a mock CAS, we don't care about the feature values just // their names. An empty CAS will be a lot faster! JCas mockCas = buildMockCAS(JCasUtil.selectSingle(aJCas, DocumentMetaData.class)); List<Instance> instances = instanceExtractor.getInstances(mockCas, false); featureMeta.collectMetaData(instances); featureMeta.writeMetaData(outputDirectory); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }
@Override protected FreqDist<String> getTermFrequencies(JCas jcas) throws AnalysisEngineProcessException { // count all terms with the given annotation FreqDist<String> termFrequencies = new FreqDist<String>(); try { for(Entry<AnnotationFS, String> entry : FeaturePathFactory.select(jcas.getCas(), featurePath)){ int occurrences = 1; for(CoreferenceLink link : JCasUtil.selectCovering(jcas, CoreferenceLink.class, entry.getKey())){ occurrences += getRemainingChainLength(link); } termFrequencies.count(entry.getValue(), occurrences); } } catch (FeaturePathException e) { throw new AnalysisEngineProcessException(e); } return termFrequencies; }