org.apache.uima.fit.util.FSUtil类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(163)

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

FSUtil介绍

暂无

代码示例

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

private static void writePrimitiveValue(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol,
    AnnotationFS aFS)
{
  Object value = getFeature(aFS, aCol.uimaFeature, Object.class);
  value = value == null ? NULL_VALUE : escapeValue(String.valueOf(value));
  aOut.print(value);
}

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

private static AnnotationFS makeChainLink(Type aType, CAS aCas,
    int aBegin, int aEnd, String aLabel, String aLinkLabel, AnnotationFS aNext)
{
  AnnotationFS link = aCas.createAnnotation(aType, aBegin, aEnd);
  FSUtil.setFeature(link, "next", aNext);
  FSUtil.setFeature(link, "referenceType", aLabel);
  FSUtil.setFeature(link, "referenceRelation", aLinkLabel);
  aCas.addFsToIndexes(link);
  return link;
}

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

private Object getValue(FeatureStructure fs, AnnotationFeature aFeature)
{
  Object value;
  
  Feature f = fs.getType().getFeatureByBaseName(aFeature.getName());
  if (f.getRange().isPrimitive()) {
    value = FSUtil.getFeature(fs, aFeature.getName(), Object.class);
  }
  else if (FSUtil.isMultiValuedFeature(fs, f)) {
    value = FSUtil.getFeature(fs, aFeature.getName(), List.class);
  }
  else {
    value = FSUtil.getFeature(fs, aFeature.getName(), FeatureStructure.class);
  }
  
  return value;
}

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

public static <T> T getFeature(FeatureStructure aFS, String aFeature, Class<T> aClazz)
{
 Feature feat = getMandatoryFeature(aFS, aFeature);
 return getFeature(aFS, feat, aClazz);
}

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

public static void setFeature(FeatureStructure aFS, String aFeature, byte... aValue) {
 Feature feat = getMandatoryFeature(aFS, aFeature);
 if (feat.getRange().isPrimitive()) {
  requireSingleValue(feat, aValue);
  aFS.setByteValue(feat, aValue[0]);
 }
 else if (aValue == null) {
  aFS.setFeatureValue(feat, null);
 }
 else {
  aFS.setFeatureValue(feat, createByteArray(aFS.getCAS(), aValue));
 }
}

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

AnnotationFS target = getFeature(rel, WebAnnoConst.FEAT_REL_TARGET,
    AnnotationFS.class);
if ((rel.getBegin() != target.getBegin()) || (rel.getEnd() != target.getEnd())) {
  fixedRels.add(rel);
  setFeature(rel, CAS.FEATURE_BASE_NAME_BEGIN, target.getBegin());
  setFeature(rel, CAS.FEATURE_BASE_NAME_END, target.getEnd());

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

public static boolean isMultiValuedFeature(FeatureStructure aFS, String aFeature) {
 Feature feat = aFS.getType().getFeatureByBaseName(aFeature);
 return isMultiValuedFeature(aFS, feat);
}

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

public static void setFeature(FeatureStructure aFS, String aFeature, FeatureStructure... aValue) {
 Feature feat = getMandatoryFeature(aFS, aFeature);
 if (feat.getRange().isArray()) {
  aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue));
 }
 else if (aValue == null) {
  aFS.setFeatureValue(feat, null);
 }
 else if (isListType(aFS.getCAS().getTypeSystem(), feat.getRange())) {
  aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue));
 }
 else {
  requireSingleValue(feat, aValue);
  aFS.setFeatureValue(feat, aValue[0]);
 }
}

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

@SuppressWarnings({ "unchecked", "rawtypes" })
public static void setFeature(FeatureStructure aFS, String aFeature, Collection aValue) {
 Feature feat = getMandatoryFeature(aFS, aFeature);
 if (aValue == null) {
  aFS.setFeatureValue(feat, null);

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

assert targetAnnotation != null;
  setFeature(aAnnotation, FEAT_REL_SOURCE, sourceAnnotation);
  setFeature(aAnnotation, FEAT_REL_TARGET, targetAnnotation);
});
break;
    if (!NULL_VALUE.equals(value)) {
      String role = Escaping.unescapeValue(value);
      setFeature(linkFS, FEAT_SLOT_ROLE, role);
setFeature(aAnnotation, aCol.uimaFeature.getShortName(), links);
break;
  FeatureStructure[] links = getFeature(aAnnotation,
      aCol.uimaFeature.getShortName(), FeatureStructure[].class);
        .resolveReference(aCol.getTargetTypeHint(), value, disambiguationId);
    setFeature(links[i], FEAT_SLOT_TARGET, targetAnnotation);

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

public static boolean isMultiValuedFeature(FeatureStructure aFS, Feature feat) {
 return isMultiValuedFeature(aFS.getCAS().getTypeSystem(), feat);
}

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

public static void setFeature(FeatureStructure aFS, String aFeature, long... aValue) {
 Feature feat = getMandatoryFeature(aFS, aFeature);
 if (feat.getRange().isPrimitive()) {
  requireSingleValue(feat, aValue);
  aFS.setLongValue(feat, aValue[0]);
 }
 else if (aValue == null) {
  aFS.setFeatureValue(feat, null);
 }
 else {
  aFS.setFeatureValue(feat, createLongArray(aFS.getCAS(), aValue));
 }
}

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

private static void writePrimitiveValue(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol,
    AnnotationFS aFS)
{
  Object value = getFeature(aFS, aCol.uimaFeature, Object.class);
  value = value == null ? NULL_VALUE : escapeValue(String.valueOf(value));
  aOut.print(value);
}

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

setFeature(head, CHAIN_FIRST_FEAT, link);
cas.addFsToIndexes(head);
while (linkIterator.hasNext()) {
  link = linkIterator.next();
  setFeature(prevLink, CHAIN_NEXT_FEAT, link);
  prevLink = link;

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

assert targetAnnotation != null;
  setFeature(aAnnotation, FEAT_REL_SOURCE, sourceAnnotation);
  setFeature(aAnnotation, FEAT_REL_TARGET, targetAnnotation);
});
break;
    if (!NULL_VALUE.equals(value)) {
      String role = Escaping.unescapeValue(value);
      setFeature(linkFS, FEAT_SLOT_ROLE, role);
setFeature(aAnnotation, aCol.uimaFeature.getShortName(), links);
break;
  FeatureStructure[] links = getFeature(aAnnotation,
      aCol.uimaFeature.getShortName(), FeatureStructure[].class);
        .resolveReference(aCol.getTargetTypeHint(), value, disambiguationId);
    setFeature(links[i], FEAT_SLOT_TARGET, targetAnnotation);

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

private Object getValue(FeatureStructure fs, AnnotationFeature aFeature)
{
  Object value;
  
  Feature f = fs.getType().getFeatureByBaseName(aFeature.getName());
  if (f.getRange().isPrimitive()) {
    value = FSUtil.getFeature(fs, aFeature.getName(), Object.class);
  }
  else if (FSUtil.isMultiValuedFeature(fs, f)) {
    value = FSUtil.getFeature(fs, aFeature.getName(), List.class);
  }
  else {
    value = FSUtil.getFeature(fs, aFeature.getName(), FeatureStructure.class);
  }
  
  return value;
}

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

private boolean isSlotFeature(TypeSystem aTS, Feature aFeature)
  if (!FSUtil.isMultiValuedFeature(aTS, aFeature)) {
    return false;

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

public static void setFeature(FeatureStructure aFS, String aFeature, double... aValue) {
 Feature feat = getMandatoryFeature(aFS, aFeature);
 if (feat.getRange().isPrimitive()) {
  requireSingleValue(feat, aValue);
  aFS.setDoubleValue(feat, aValue[0]);
 }
 else if (aValue == null) {
  aFS.setFeatureValue(feat, null);
 }
 else {
  aFS.setFeatureValue(feat, createDoubleArray(aFS.getCAS(), aValue));
 }
}

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

private static void writeSlotRole(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol,
    AnnotationFS aFS)
{
  FeatureStructure[] links = getFeature(aFS, aCol.uimaFeature, FeatureStructure[].class);
  if (links != null && links.length > 0) {
    for (int i = 0; i < links.length; i++) {
      if (i > 0) {
        aOut.print(SLOT_SEP);
      }
      String value = getFeature(links[i], TsvSchema.FEAT_SLOT_ROLE, String.class);
      value = value == null ? NULL_VALUE : escapeValue(value);
      aOut.print(value);
    }
  }
  else {
    aOut.print(NULL_COLUMN);
  }
  writeDisambiguationId(aOut, aDoc, aFS);
}

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

setFeature(head, CHAIN_FIRST_FEAT, link);
cas.addFsToIndexes(head);
while (linkIterator.hasNext()) {
  link = linkIterator.next();
  setFeature(prevLink, CHAIN_NEXT_FEAT, link);
  prevLink = link;

相关文章