org.apache.uima.cas.CAS.getDocumentText()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.uima.cas.CAS.getDocumentText()方法的一些代码示例,展示了CAS.getDocumentText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.getDocumentText()方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:getDocumentText

CAS.getDocumentText介绍

[英]Get the document text.
[中]获取文档文本。

代码示例

代码示例来源:origin: apache/opennlp

@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);
 }
}

代码示例来源:origin: org.apache.uima/uimafit-core

private void processDocumentText(CAS aCAS) {
 out.println();
 out.println("CAS-Text:");
 out.println(aCAS.getDocumentText());
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl

private void processDocumentText(CAS aCAS)
{
  out.println();
  out.println("CAS-Text:");
  out.println(aCAS.getDocumentText());
}

代码示例来源:origin: dkpro/dkpro-core

private void processDocumentText(CAS aCAS)
{
  out.println();
  out.println("CAS-Text:");
  out.println(aCAS.getDocumentText());
}

代码示例来源:origin: CLLKazan/UIMA-Ext

@Override
  public void process(CAS cas) throws AnalysisEngineProcessException {
    if (cas.getDocumentText().contains(ERROR_SUBSTRING)) {
      throw new AnalysisEngineProcessException(
          new Exception("ErrorProducer is on duty!"));
    }
  }
}

代码示例来源:origin: nlpie/biomedicus

CASDocument(CAS view, @Nullable LabelAdapters labelAdapters) {
 super(view.getViewName(), view.getDocumentText());
 this.view = view;
 this.labelAdapters = labelAdapters;
}

代码示例来源:origin: CLLKazan/UIMA-Ext

/**
 * @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);
}

代码示例来源:origin: CLLKazan/UIMA-Ext

/**
 * @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);
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima

/** Get hash of current document text */
 public String getHash() {
  try {
   return IdentityUtils.hashStrings(getCAS().getDocumentText());
  } catch (BaleenException e) {
   return "";
  }
 }
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

/**
 * Call is forwarded to the set document.
 * 
 * @return the text
 */
private String getText() {
 String text = getCAS().getDocumentText();
 return transformText(text);
}

代码示例来源:origin: dstl/baleen

/** Get hash of current document text */
 public String getHash() {
  try {
   return IdentityUtils.hashStrings(getCAS().getDocumentText());
  } catch (BaleenException e) {
   return "";
  }
 }
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.segmentation-asl

/**
 * 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);
}

代码示例来源:origin: apache/uima-uimaj

/**
 * @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());
}

代码示例来源:origin: apache/uima-uimaj

/**
 * @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());
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

@Override
protected boolean isErrorStatus(IStatus status) {
 return super.isErrorStatus(status) || getDocument().getCAS().getDocumentText() == null;
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers-uima

@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();
}

代码示例来源:origin: org.apache.uima/ruta-ep-caseditor

private void setHtmlWithEditor() {
 CAS cas = editor.getDocument().getCAS();
 String html = cas.getDocumentText();
 browser.setText(html);
 browser.refresh();
}

代码示例来源:origin: Ailab403/ailab-mltk4j

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);
 }
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

/**
 * 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);
}

代码示例来源:origin: CLLKazan/UIMA-Ext

/**
 * {@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");
}

相关文章