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

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

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

CAS.createFS介绍

[英]Create a new FeatureStructure.
[中]创建一个新的FeatureStructure。

代码示例

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

protected void documentDone(CAS cas) {
 // TODO: Create confidence FS
 // contains String name type
 // contains Double prob
 if (documentConfidenceType != null) {
  FeatureStructure confidenceFS = cas.createFS(documentConfidenceType);
  confidenceFS.setDoubleValue(documentConfidenceFeature,
    documentConfidence.mean());
  confidenceFS.setStringValue(documentConfidenceNameTypeFeature,
    mNameType.getName());
  cas.addFsToIndexes(confidenceFS);
 }
 // Clears the adaptive data which was created for the current document
 mNameFinder.clearAdaptiveData();
 documentConfidence = new Mean();
}

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

@Override
 public boolean containsKey(Object key) {
  if (!(key instanceof String)) {
   return false;
  }
  FeatureStructure check = metadataCas.createFS(metadataType);
  check.setStringValue(keyFeature, (String) key);
  return metadataIndex.contains(check);
 }
}

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

@Nullable
@Override
public String get(Object key) {
 if (!(key instanceof String)) {
  return null;
 }
 FeatureStructure check = metadataCas.createFS(metadataType);
 check.setStringValue(keyFeature, (String) key);
 FeatureStructure fs = metadataIndex.find(check);
 return fs.getStringValue(valueFeature);
}

代码示例来源:origin: de.unistuttgart.ims/de.unistuttgart.ims.drama.util

public static <T extends TOP> T createFeatureStructure(JCas jcas, Class<T> cls) {
  T fs = jcas.getCas().createFS(JCasUtil.getType(jcas, cls));
  fs.addToIndexes();
  return fs;
}

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

@Override
 public void run() {
  // TODO: check if an AnnotationFS was created, if so
  // add it to the document
  // inserts a new feature structure of current type
  if (mCurrentType == null) {
   return;
  }
  FeatureStructure newFeatureStructure = mDocument.getCAS().createFS(mCurrentType);
  mDocument.addFeatureStructure(newFeatureStructure);
  mFSList.refresh();
 }
}

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

/**
 * Function for creating generic UIMA {@code FeatureStructure}s.
 *
 * @param featureStructure {@code FeatureStructure} to create a new object of the same type in the
 * target cas.
 * @return newly created {@code FeatureStructure} matching the type of the parameter {@code
 * FeatureStructure}
 */
private FeatureStructure defaultCreateType(FeatureStructure featureStructure) {
 String typeName = featureStructure.getType().getName();
 Type targetType = targetCas.getTypeSystem().getType(typeName);
 return targetCas.createFS(targetType);
}

代码示例来源:origin: de.unistuttgart.ims/uimautil

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

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

/**
 * Create a new chain head feature structure. Already adds the chain to the CAS.
 */
private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink)
{
  Type chainType = getAnnotationType(aJCas.getCas());
  FeatureStructure newChain = aJCas.getCas().createFS(chainType);
  newChain.setFeatureValue(chainType.getFeatureByBaseName(chainFirstFeatureName), aFirstLink);
  aJCas.addFsToIndexes(newChain);
  return newChain;
}

代码示例来源:origin: de.unistuttgart.ims/de.unistuttgart.ims.drama.util

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

代码示例来源:origin: de.unistuttgart.ims.uima.io/generic-xml-reader

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

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

public Object clone() throws CASRuntimeException {
  if (getType().getName().equals(CAS.TYPE_NAME_SOFA)) {
    throw new CASRuntimeException(CASRuntimeException.CANNOT_CLONE_SOFA);
  }
  CASImpl casImpl = this.getCASImpl();
  FeatureStructure newFS = getCAS().createFS(getType());
  casImpl.copyFeatures(((FeatureStructureImpl) newFS).getAddress(), this.getAddress());
  return newFS;
}

代码示例来源:origin: webanno/webanno

private static void makeChainHead(Type aType, AnnotationFS first)
{
  CAS cas = first.getCAS();
  FeatureStructure h = cas.createFS(aType);
  FSUtil.setFeature(h, "first", first);
  cas.addFsToIndexes(h);
}

代码示例来源:origin: webanno/webanno

/**
 * Create a new chain head feature structure. Already adds the chain to the CAS.
 */
private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink)
{
  Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName());
  FeatureStructure newChain = aJCas.getCas().createFS(chainType);
  newChain.setFeatureValue(chainType.getFeatureByBaseName(getChainFirstFeatureName()),
      aFirstLink);
  aJCas.addFsToIndexes(newChain);
  return newChain;
}

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

protected void documentDone(CAS cas) {
 // TODO: Create confidence FS
 // contains String name type
 // contains Double prob
 if (documentConfidenceType != null) {
  FeatureStructure confidenceFS = cas.createFS(documentConfidenceType);
  confidenceFS.setDoubleValue(documentConfidenceFeature,
    documentConfidence.mean());
  confidenceFS.setStringValue(documentConfidenceNameTypeFeature,
    mNameType.getName());
  cas.addFsToIndexes(confidenceFS);
 }
 // Clears the adaptive data which was created for the current document
 mNameFinder.clearAdaptiveData();
 documentConfidence = new Mean();
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

/**
 * Create a new chain head feature structure. Already adds the chain to the CAS.
 */
private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink)
{
  Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName());
  FeatureStructure newChain = aJCas.getCas().createFS(chainType);
  newChain.setFeatureValue(chainType.getFeatureByBaseName(getChainFirstFeatureName()),
      aFirstLink);
  aJCas.addFsToIndexes(newChain);
  return newChain;
}

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

@Override
public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
 RuleElement element = context.getElement();
 Type casType = stream.getJCas().getCasType(RutaColoring.type);
 FeatureStructure newAnnotationFS = stream.getCas().createFS(casType);
 RutaColoring coloring = null;
 if (newAnnotationFS instanceof RutaColoring) {
  coloring = (RutaColoring) newAnnotationFS;
  element.getParent();
  coloring.setBgColor(bgcolor.getStringValue(context, stream));
  coloring.setFgColor(fgcolor.getStringValue(context, stream));
  coloring.setSelected(selected.getBooleanValue(context, stream));
  coloring.setTargetType(type.getType(context, stream).getName());
  coloring.addToIndexes();
 }
}

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

@Override
public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
    InferenceCrowd crowd) {
 Type casType = stream.getJCas().getCasType(TextMarkerColoring.type);
 FeatureStructure newAnnotationFS = stream.getCas().createFS(casType);
 TextMarkerColoring coloring = null;
 if (newAnnotationFS instanceof TextMarkerColoring) {
  coloring = (TextMarkerColoring) newAnnotationFS;
  coloring.setBgColor(bgcolor.getStringValue(element.getParent()));
  coloring.setFgColor(fgcolor.getStringValue(element.getParent()));
  coloring.setSelected(selected.getBooleanValue(element.getParent()));
  coloring.setTargetType(type.getType(element.getParent()).getName());
  coloring.addToIndexes();
 }
}

代码示例来源:origin: webanno/webanno

private static FeatureStructure makeLinkFS(JCas aJCas, String aType, String aSlotLabel,
    AnnotationFS aTarget)
{
  Type linkType = aJCas.getTypeSystem().getType(aType);
  FeatureStructure linkA1 = aJCas.getCas().createFS(linkType);
  linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel);
  linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), aTarget);
  aJCas.getCas().addFsToIndexes(linkA1);
  return linkA1;
}

代码示例来源:origin: webanno/webanno

public static FeatureStructure makeLinkFS(JCas aJCas, String aSlotLabel, int aTargetBegin,
      int aTargetEnd)
  {
    Token token1 = new Token(aJCas, aTargetBegin, aTargetEnd);
    token1.addToIndexes();

    Type linkType = aJCas.getTypeSystem().getType(LINK_TYPE);
    FeatureStructure linkA1 = aJCas.getCas().createFS(linkType);
    linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel);
    linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), token1);
    aJCas.getCas().addFsToIndexes(linkA1);

    return linkA1;
  }
}

代码示例来源:origin: webanno/webanno

public static FeatureStructure makeLinkFS(JCas aJCas, String aSlotLabel, int aTargetBegin,
      int aTargetEnd)
  {
    Token token1 = new Token(aJCas, aTargetBegin, aTargetEnd);
    token1.addToIndexes();

    Type linkType = aJCas.getTypeSystem().getType(LINK_TYPE);
    FeatureStructure linkA1 = aJCas.getCas().createFS(linkType);
    linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel);
    linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), token1);
    aJCas.getCas().addFsToIndexes(linkA1);

    return linkA1;
  }
}

相关文章