当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationFS.setStringValue方法代码示例

本文整理汇总了Java中org.apache.uima.cas.text.AnnotationFS.setStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationFS.setStringValue方法的具体用法?Java AnnotationFS.setStringValue怎么用?Java AnnotationFS.setStringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.cas.text.AnnotationFS的用法示例。


在下文中一共展示了AnnotationFS.setStringValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapAttributes

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void mapAttributes(Map<String, Feature> attr2FeatMap,
                           HasAttributes attrHolder, AnnotationFS uAnno) {
    for (String attrName : attr2FeatMap.keySet()) {
        Feature uFeat = attr2FeatMap.get(attrName);
        Object attrValue = attrHolder.getAttributesMap().get(attrName);
        if (attrValue == null) {
            continue;
        } else if (attrValue instanceof Boolean) {
            uAnno.setBooleanValue(uFeat, (Boolean) attrValue);
        } else if (attrValue instanceof String) {
            uAnno.setStringValue(uFeat, (String) attrValue);
        } else {
            throw new IllegalStateException();
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:17,代码来源:BratCollectionReader.java

示例2: simpleCopyToSameExistingAnnoTest

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Test
public void simpleCopyToSameExistingAnnoTest()
    throws Exception
{
    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NN");
    mergeCAs.addFsToIndexes(existingFs);

    exception.expect(AnnotationException.class);
    MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
            posLayer, mergeCAs, clickedFs, false);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:19,代码来源:CopyAnnotationTest.java

示例3: simpleCopyToDiffExistingAnnoWithNoStackingTest

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithNoStackingTest()
    throws Exception
{
    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NE");
    mergeCAs.addFsToIndexes(existingFs);

    MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
            posLayer, mergeCAs, clickedFs, false);

    assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:CopyAnnotationTest.java

示例4: simpleCopyToDiffExistingAnnoWithStackingTest

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithStackingTest()
    throws Exception
{
    AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
    state.setUser(new User());
    
    posLayer.setAllowStacking(true);

    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    createTokenAnno(mergeCAs, 0, 0);
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NE");
    mergeCAs.addFsToIndexes(existingFs);

    MergeCas.addSpanAnnotation(state, annotationSchemaService, posLayer, mergeCAs, clickedFs,
            true);

    assertEquals(2, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:26,代码来源:CopyAnnotationTest.java

示例5: process

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
  Type type = jcas.getCas().getTypeSystem().getType(TYPE_NAME);
  Feature entityFeature = type.getFeatureByBaseName(ENTITY_FEATURE);
  Feature nameFeature = type.getFeatureByBaseName(NAME_FEATURE);

  for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) {
    String tokenPOS = ((TokenAnnotation) annotation).getPosTag();

    if (NP.equals(tokenPOS) || NPS.equals(tokenPOS)) {
      AnnotationFS entityAnnotation = jcas.getCas().createAnnotation(type, annotation.getBegin(), annotation.getEnd());

      entityAnnotation.setStringValue(entityFeature, annotation.getCoveredText());

      String name = "OTHER"; // "OTHER" makes no sense. In practice, "PERSON", "COUNTRY", "E-MAIL", etc.
      if (annotation.getCoveredText().equals("Apache"))
        name = "ORGANIZATION";
      entityAnnotation.setStringValue(nameFeature, name);

      jcas.addFsToIndexes(entityAnnotation);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SampleEntityAnnotator.java

示例6: fillAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(DictionaryConcept label, AnnotationFS annotationFS) {
  annotationFS.setStringValue(identifierFeature, label.getIdentifier());
  annotationFS.setStringValue(sourceFeature, label.getSource());
  annotationFS.setDoubleValue(confidenceFeature, label.getConfidence());
  annotationFS.setStringValue(semanticTypeFeature, label.getType());
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:8,代码来源:DictionaryConceptLabelAdapter.java

示例7: wroteToDestination

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void wroteToDestination(String destinationName,
    int destinationIndex,
    Label originalDocumentTextLocation) {
  AnnotationFS viewIndex = originalDocumentView
      .createAnnotation(viewIndexType, originalDocumentTextLocation.getStartIndex(),
          originalDocumentTextLocation.getEndIndex());
  viewIndex.setStringValue(destinationNameFeature, destinationName);
  viewIndex.setIntValue(destinationIndexFeature, destinationIndex);
  originalDocumentView.addFsToIndexes(viewIndex);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:12,代码来源:CasIndexListener.java

示例8: setDocumentUri

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
 * Search for a {@link DocumentMetadata} annotation in the given CAS and set
 * its 'uri' feature to the specified value.
 *
 * @param cas
 * @param uri
 * @param createDocMeta if true then this method will create a new
 *                      {@link DocumentMetadata} instance if there is none in the CAS.
 */
public static void setDocumentUri(CAS cas, String uri, boolean createDocMeta) {
    TypeSystem ts = cas.getTypeSystem();
    Type docMetaType = ts.getType(getMetadataTypeName());
    if (docMetaType == null) {
        throw new IllegalStateException(
                "The typesystem of the given CAS does not contain DocumentMetadata type");
    }
    Feature sourceUriFeat;
    try {
        sourceUriFeat = featureExist(docMetaType, "sourceUri");
    } catch (AnalysisEngineProcessException e) {
        throw new IllegalStateException(e);
    }
    AnnotationFS docMetaFS = null;
    FSIterator<AnnotationFS> dmIter = cas.getAnnotationIndex(docMetaType).iterator();
    if (dmIter.hasNext()) {
        docMetaFS = dmIter.next();
    }
    if (docMetaFS == null) {
        if (createDocMeta) {
            docMetaFS = cas.createAnnotation(docMetaType, 0, 0);
            cas.addFsToIndexes(docMetaFS);
        } else {
            throw new IllegalStateException("The given CAS does not contain a DocumentMetadata");
        }
    }
    docMetaFS.setStringValue(sourceUriFeat, uri);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:38,代码来源:DocumentUtils.java

示例9: process

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
    for (AnnotationFS unit : CasUtil.select(aCAS, unitType)) {
        for (Type classType : classTypes) {
            for (AnnotationFS classAnnotation : CasUtil.select(aCAS,
                    classType)) {
                if (isIntersect(unit, classAnnotation)) {
                    unit.setStringValue(classFeature, classType.getName());
                }
            }
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:14,代码来源:UnitClassifier.java

示例10: makeAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void makeAnnotation(AnnotationFS firstToken, AnnotationFS lastToken, String tag) {
    Preconditions.checkArgument(firstToken != null, "firstToken == null");
    CAS cas = firstToken.getCAS();
    AnnotationFS anno = cas.createAnnotation(resultAnnotationType, firstToken.getBegin(), lastToken.getEnd());
    anno.setStringValue(tagFeature, tag);
    if (firstTokenFeature != null) {
        anno.setFeatureValue(firstTokenFeature, firstToken);
    }
    cas.addFsToIndexes(anno);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:12,代码来源:TaggedChunkAnnotationAdapter.java

示例11: createPOSAnno

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private AnnotationFS createPOSAnno(JCas aJCas, Type aType, String aValue, int aBegin, int aEnd)
{
    AnnotationFS clickedFs = aJCas.getCas().createAnnotation(aType, aBegin, aEnd);
    Feature posValue = aType.getFeatureByBaseName("PosValue");
    clickedFs.setStringValue(posValue, aValue);
    aJCas.addFsToIndexes(clickedFs);
    return clickedFs;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:9,代码来源:CopyAnnotationTest.java

示例12: makeLinkHostMultiSPanFeatureFS

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public static AnnotationFS makeLinkHostMultiSPanFeatureFS(JCas aJCas, int aBegin, int aEnd,
        Feature aSpanFeature, String aValue, FeatureStructure... aLinks)
{
    Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE);
    AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
    hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
            FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
    hostA1.setStringValue(aSpanFeature, aValue);
    aJCas.getCas().addFsToIndexes(hostA1);
    return hostA1;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:12,代码来源:DiffUtils.java

示例13: fillAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(Section label, AnnotationFS annotationFS) {
  annotationFS.setStringValue(kindFeature, label.getKind());
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:5,代码来源:BiomedicusTsLabelsPlugin.java

示例14: fillAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(T token, AnnotationFS annotationFS) {
  annotationFS.setStringValue(textFeature, token.getText());
  annotationFS.setBooleanValue(hasSpaceAfterFeature, token.getHasSpaceAfter());
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:6,代码来源:AbstractTokenLabelAdapter.java

示例15: setDocumentMetadata

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void setDocumentMetadata(CAS cas, String docName, int docSize) {
    AnnotationFS docMeta = cas.createAnnotation(documentMetadataType, 0, 0);
    docMeta.setLongValue(docMetaSizeFeature, docSize);
    docMeta.setStringValue(docMetaUriFeature, docName);
    cas.addFsToIndexes(docMeta);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:7,代码来源:BratCollectionReader.java


注:本文中的org.apache.uima.cas.text.AnnotationFS.setStringValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。