本文整理汇总了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();
}
}
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
}
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例13: fillAnnotation
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(Section label, AnnotationFS annotationFS) {
annotationFS.setStringValue(kindFeature, label.getKind());
}
示例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());
}
示例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);
}