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

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

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

CAS.createArrayFS介绍

[英]Create a new feature structure array.
[中]创建新的要素结构阵列。

代码示例

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

protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) {
 Parse[] parseChildren = parse.getChildren();
 AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length];
 // do this for all children
 for (int i = 0; i < parseChildren.length; i++) {
  parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]);
 }
 AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset +
   parse.getSpan().getStart(), offset + parse.getSpan().getEnd());
 parseAnnotation.setStringValue(mTypeFeature, parse.getType());
 if (probabilityFeature != null) {
  parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb());
 }
 ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length);
 childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length);
 parseAnnotation.setFeatureValue(childrenFeature, childrenArray);
 cas.getIndexRepository().addFS(parseAnnotation);
 return parseAnnotation;
}

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

public static ArrayFS createArrayFS(CAS aCas, Collection<? extends FeatureStructure> aCollection) {
 return fillArrayFS(aCas.createArrayFS(aCollection.size()), aCollection);
}

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

public static ArrayFS createArrayFS(CAS aCas, FeatureStructure[] aArray) {
 return fillArrayFS(aCas.createArrayFS(aArray.length), asList(aArray));
}

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

/**
 * update a base annotation with slot annotations
 * 
 * @param linkFSesPerAnno
 *            contains list of slot annotations per a base annotation
 * @param aLinkeF
 *            The link slot annotation feature
 */
private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno,
    Feature aLinkeF)
{
  for (AnnotationFS anno : linkFSesPerAnno.keySet()) {
    ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size());
    array.copyFromArray(
        linkFSesPerAnno.get(anno)
            .toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]),
        0, 0, linkFSesPerAnno.get(anno).size());
    anno.setFeatureValue(aLinkeF, array);
    anno.getCAS().addFsToIndexes(anno);
  }
}

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

/**
 * update a base annotation with slot annotations
 * 
 * @param linkFSesPerAnno
 *            contains list of slot annotations per a base annotation
 * @param aLinkeF
 *            The link slot annotation feature
 */
private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno, Feature aLinkeF) {
  for (AnnotationFS anno : linkFSesPerAnno.keySet()) {
    ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size());
    array.copyFromArray(
        linkFSesPerAnno.get(anno).toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]), 0, 0,
        linkFSesPerAnno.get(anno).size());
    anno.setFeatureValue(aLinkeF, array);
    anno.getCAS().addFsToIndexes(anno);
  }
}

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

public static void setLinkFeatureValue(FeatureStructure aFS, Feature aFeature,
    List<FeatureStructure> linkFSes)
{
  // Create a new array if size differs otherwise re-use existing one
  ArrayFS array = (ArrayFS) WebAnnoCasUtil.getFeatureFS(aFS, aFeature.getShortName());
  if (array == null || (array.size() != linkFSes.size())) {
    array = aFS.getCAS().createArrayFS(linkFSes.size());
  }
  // Fill in links
  array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0,
      linkFSes.size());
  aFS.setFeatureValue(aFeature, array);
}

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

/**
 * update a base annotation with slot annotations
 * 
 * @param linkFSesPerAnno
 *            contains list of slot annotations per a base annotation
 * @param aLinkeF
 *            The link slot annotation feature
 */
private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno,
    Feature aLinkeF)
{
  for (AnnotationFS anno : linkFSesPerAnno.keySet()) {
    ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size());
    array.copyFromArray(
        linkFSesPerAnno.get(anno)
            .toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]),
        0, 0, linkFSesPerAnno.get(anno).size());
    anno.setFeatureValue(aLinkeF, array);
    anno.getCAS().addFsToIndexes(anno);
  }
}

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

public static void setLinkFeatureValue(FeatureStructure aFS, Feature aFeature,
    List<FeatureStructure> linkFSes)
{
  // Create a new array if size differs otherwise re-use existing one
  ArrayFS array = (ArrayFS) WebAnnoCasUtil.getFeatureFS(aFS, aFeature.getShortName());
  if (array == null || (array.size() != linkFSes.size())) {
    array = aFS.getCAS().createArrayFS(linkFSes.size());
  }
  // Fill in links
  array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0,
      linkFSes.size());
  aFS.setFeatureValue(aFeature, array);
}

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

public static FeatureStructure toCompatibleCollection(CAS cas, Feature targetFeat,
    Collection<? extends FeatureStructure> srcCol) {
  if (srcCol == null) {
    return null;
  }
  // TODO handle lists
  if (targetFeat.getRange().isArray()) {
    ArrayFS result = cas.createArrayFS(srcCol.size());
    int i = 0;
    for (FeatureStructure elemFS : srcCol) {
      result.set(i, elemFS);
      i++;
    }
    return result;
  } else {
    throw new UnsupportedOperationException();
  }
}

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

ArrayFS array = baseFs.getCAS().createArrayFS(linkFSes.size());
array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0,
    0, linkFSes.size());

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

ArrayFS array = baseFs.getCAS().createArrayFS(linkFSes.size());
array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0,
    0, linkFSes.size());

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

FeatureStructure newFeatureFS = null;
if (oldRange.isArray()) {
 newFeatureFS = cas.createArrayFS(0);
} else {
 newFeatureFS = cas.createFS(feature.getRange());

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

FeatureStructure newFeatureFS = null;
if (oldRange.isArray()) {
 newFeatureFS = cas.createArrayFS(0);
} else {
 newFeatureFS = cas.createFS(feature.getRange());

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

fs = document.getCAS().createStringArrayFS(arraySize);
} else if (type.getName().equals(CAS.TYPE_NAME_FS_ARRAY)) {
 fs = document.getCAS().createArrayFS(arraySize);
} else {
 throw new CasEditorError("Unkown array type: " + type.getName() + "!");

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

ArrayFS array = cas.createArrayFS(1);
FeatureStructure linkFS = cas.createFS(linkType);
FSUtil.setFeature(linkFS, feat1.getLinkTypeRoleFeatureName(), "role");

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

protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) {
 Parse[] parseChildren = parse.getChildren();
 AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length];
 // do this for all children
 for (int i = 0; i < parseChildren.length; i++) {
  parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]);
 }
 AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset +
   parse.getSpan().getStart(), offset + parse.getSpan().getEnd());
 parseAnnotation.setStringValue(mTypeFeature, parse.getType());
 if (probabilityFeature != null) {
  parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb());
 }
 ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length);
 childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length);
 parseAnnotation.setFeatureValue(childrenFeature, childrenArray);
 cas.getIndexRepository().addFS(parseAnnotation);
 return parseAnnotation;
}

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

ArrayFS arrayFs = (ArrayFS) aSrcFs;
int len = arrayFs.size();
ArrayFS destFS = mDestCas.createArrayFS(len);
for (int i = 0; i < len; i++) {
  FeatureStructure srcElem = arrayFs.get(i);

相关文章