@Override protected void setBestCategory(CAS tcas, String bestCategory) { FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType); AnnotationFS categoryAnnotation; if (categoryIndex.size() > 0) { categoryAnnotation = categoryIndex.iterator().next(); } else { categoryAnnotation = tcas.createAnnotation(mCategoryType, 0, tcas.getDocumentText().length()); tcas.getIndexRepository().addFS(categoryAnnotation); } categoryAnnotation.setStringValue(mCategoryFeature, bestCategory); } }
private void processDocumentText(CAS aCAS) { out.println(); out.println("CAS-Text:"); out.println(aCAS.getDocumentText()); }
private void processDocumentText(CAS aCAS) { out.println(); out.println("CAS-Text:"); out.println(aCAS.getDocumentText()); }
private void processDocumentText(CAS aCAS) { out.println(); out.println("CAS-Text:"); out.println(aCAS.getDocumentText()); }
@Override public void process(CAS cas) throws AnalysisEngineProcessException { if (cas.getDocumentText().contains(ERROR_SUBSTRING)) { throw new AnalysisEngineProcessException( new Exception("ErrorProducer is on duty!")); } } }
CASDocument(CAS view, @Nullable LabelAdapters labelAdapters) { super(view.getViewName(), view.getDocumentText()); this.view = view; this.labelAdapters = labelAdapters; }
/** * @param anno an annotation * @param contextCharNum number of characters * @return contextCharNum characters after the given annotation */ public static String textAfter(AnnotationFS anno, int contextCharNum) { Preconditions.checkArgument(contextCharNum >= 0); String txt = anno.getCAS().getDocumentText(); int begin = anno.getEnd(); int end = Math.min(txt.length(), begin + contextCharNum); return txt.substring(begin, end); }
/** * @param anno an annotation * @param contextCharNum number of characters * @return contextCharNum characters before the given annotation */ public static String textBefore(AnnotationFS anno, int contextCharNum) { Preconditions.checkArgument(contextCharNum >= 0); int begin = Math.max(0, anno.getBegin() - contextCharNum); int end = anno.getBegin(); return anno.getCAS().getDocumentText().substring(begin, end); }
/** Get hash of current document text */ public String getHash() { try { return IdentityUtils.hashStrings(getCAS().getDocumentText()); } catch (BaleenException e) { return ""; } } }
/** * Call is forwarded to the set document. * * @return the text */ private String getText() { String text = getCAS().getDocumentText(); return transformText(text); }
/** Get hash of current document text */ public String getHash() { try { return IdentityUtils.hashStrings(getCAS().getDocumentText()); } catch (BaleenException e) { return ""; } } }
/** * Trim the offsets of the given annotation to remove leading/trailing whitespace. * <p> * <b>Note:</b> use this method only if the document text of the CAS has already been set! * <p> * <b>Note:</b> best use this method before adding the annotation to the indexes. * * @param aAnnotation * the annotation to trim. Offsets are updated. */ public static void trim(Annotation aAnnotation) { trim(aAnnotation.getCAS().getDocumentText(), aAnnotation); }
/** * @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() */ public String getCoveredText() { final CAS casView = this.getView(); final String text = casView.getDocumentText(); if (text == null) { return null; } return text.substring(getBegin(), getEnd()); }
/** * @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() */ public String getCoveredText() { final CAS casView = this.getView(); final String text = casView.getDocumentText(); if (text == null) { return null; } return text.substring(getBegin(), getEnd()); }
@Override protected boolean isErrorStatus(IStatus status) { return super.isErrorStatus(status) || getDocument().getCAS().getDocumentText() == null; }
@Override protected void initializeIterator() throws IOException { try { analyzeInput(); } catch (AnalysisEngineProcessException | ResourceInitializationException e) { throw new IOException(e); } finalOffset = correctOffset(cas.getDocumentText().length()); Type tokenType = cas.getTypeSystem().getType(tokenTypeString); iterator = cas.getAnnotationIndex(tokenType).iterator(); }
private void setHtmlWithEditor() { CAS cas = editor.getDocument().getCAS(); String html = cas.getDocumentText(); browser.setText(html); browser.refresh(); }
public void processCas(CAS cas) throws ResourceProcessException { FSIndex categoryIndex = cas.getAnnotationIndex(mCategoryType); if (categoryIndex.size() > 0) { AnnotationFS categoryAnnotation = (AnnotationFS) categoryIndex.iterator().next(); // add to event collection DocumentSample sample = new DocumentSample( categoryAnnotation.getStringValue(mCategoryFeature), cas.getDocumentText()); documentSamples.add(sample); } }
/** * Wide right annotation side. * * @param document the document * @param annotation the annotation */ public static void wideRightAnnotationSide(ICasDocument document, AnnotationFS annotation) { Type annotationType = annotation.getType(); Feature endFeature = annotationType.getFeatureByBaseName("end"); if (annotation.getEnd() < document.getCAS().getDocumentText().length()) { annotation.setIntValue(endFeature, annotation.getEnd() + 1); } document.update(annotation); }
/** * {@inheritDoc} */ @Override public void process(CAS cas) throws AnalysisEngineProcessException { ExtendedLogger log = getLogger(); log.info("CAS text:"); log.info(cas.getDocumentText()); for (AnnotationFS anno : cas.getAnnotationIndex()) { log.info(anno); } log.info("Logging for particular CAS is finished"); }