本文整理汇总了Java中org.apache.uima.cas.text.AnnotationFS.getFeatureValue方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationFS.getFeatureValue方法的具体用法?Java AnnotationFS.getFeatureValue怎么用?Java AnnotationFS.getFeatureValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.text.AnnotationFS
的用法示例。
在下文中一共展示了AnnotationFS.getFeatureValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotationToLabel
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public DictionaryTerm annotationToLabel(AnnotationFS annotationFS) {
FeatureStructure conceptsFeatureValue = annotationFS.getFeatureValue(conceptsFeature);
if (!(conceptsFeatureValue instanceof ArrayFS)) {
throw new IllegalStateException("Concepts feature structure is not array.");
}
ArrayFS conceptsArray = (ArrayFS) conceptsFeatureValue;
int size = conceptsArray.size();
List<DictionaryConcept> concepts = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
AnnotationFS conceptFeatureStructure = (AnnotationFS) conceptsArray.get(i);
concepts.add(dictionaryConceptLabelAdapter.annotationToLabel(conceptFeatureStructure));
}
return new DictionaryTerm(annotationFS.getBegin(), annotationFS.getEnd(), concepts);
}
示例2: annotationToLabel
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public T annotationToLabel(AnnotationFS annotationFS) {
FeatureStructure cuesValue = annotationFS.getFeatureValue(cues);
if (!(cuesValue instanceof ArrayFS)) {
throw new IllegalStateException("Cues is not ArrayFS");
}
ArrayFS cuesArray = (ArrayFS) cuesValue;
int size = cuesArray.size();
List<Span> cueTerms = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
FeatureStructure cueFs = cuesArray.get(i);
if (!(cueFs instanceof AnnotationFS)) {
throw new IllegalStateException();
}
AnnotationFS cueAnnotation = (AnnotationFS) cueFs;
Span span = new Span(cueAnnotation.getBegin(),
cueAnnotation.getEnd());
cueTerms.add(span);
}
return create(annotationFS.getBegin(), annotationFS.getEnd(), cueTerms);
}
示例3: makeArgMap
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private Map<String, BratEntity> makeArgMap(AnnotationFS uAnno,
BratRelationType bratType, Map<String, Feature> argFeatMap) {
Map<String, BratEntity> argAnnotations = Maps.newHashMapWithExpectedSize(2);
for (String argName : argFeatMap.keySet()) {
Feature argFeat = argFeatMap.get(argName);
FeatureStructure argFS = uAnno.getFeatureValue(argFeat);
if (argFS == null) {
getLogger().warn(String.format(
"Can't map %s to Brat relation. Its feature '%s' is not set.",
toPrettyString(uAnno), argFeat));
return null;
}
BratEntity argValue = context.demandEntity(argFS);
argAnnotations.put(argName, argValue);
}
return argAnnotations;
}
示例4: generateSubPositions
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public List<? extends Position> generateSubPositions(int aCasId, AnnotationFS aFs,
LinkCompareBehavior aLinkCompareBehavior)
{
List<Position> subPositions = new ArrayList<>();
for (LinkFeatureDecl decl : linkFeatures) {
Feature linkFeature = aFs.getType().getFeatureByBaseName(decl.name);
ArrayFS array = (ArrayFS) aFs.getFeatureValue(linkFeature);
if (array == null) {
continue;
}
for (FeatureStructure linkFS : array.toArray()) {
String role = linkFS.getStringValue(linkFS.getType().getFeatureByBaseName(
decl.roleFeature));
AnnotationFS target = (AnnotationFS) linkFS.getFeatureValue(linkFS.getType()
.getFeatureByBaseName(decl.targetFeature));
Position pos = getPosition(aCasId, aFs, decl.name, role, target.getBegin(),
target.getEnd(), aLinkCompareBehavior);
subPositions.add(pos);
}
}
return subPositions;
}
示例5: repair
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void repair(Project aProject, CAS aCas, List<LogMessage> aMessages)
{
Set<FeatureStructure> nonIndexed = getNonIndexedFSes(aCas);
Set<FeatureStructure> toDelete = new LinkedHashSet<>();
for (AnnotationFS fs : aCas.getAnnotationIndex()) {
Type t = fs.getType();
Feature sourceFeat = t.getFeatureByBaseName(WebAnnoConst.FEAT_REL_SOURCE);
Feature targetFeat = t.getFeatureByBaseName(WebAnnoConst.FEAT_REL_TARGET);
// Is this a relation?
if (!(sourceFeat != null && targetFeat != null)) {
continue;
}
FeatureStructure source = fs.getFeatureValue(sourceFeat);
FeatureStructure target = fs.getFeatureValue(targetFeat);
// Does it point to deleted spans?
if (nonIndexed.contains(source) || nonIndexed.contains(target)) {
toDelete.add(fs);
}
}
// Delete those relations that pointed to deleted spans
if (!toDelete.isEmpty()) {
toDelete.forEach(aCas::removeFsFromIndexes);
aMessages.add(new LogMessage(this, LogLevel.INFO, "Removed [%d] dangling relations.",
nonIndexed.size()));
}
}
示例6: isSamAnno
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private static boolean isSamAnno(Type aType, AnnotationFS aMFs, AnnotationFS aFs)
{
for (Feature f : aType.getFeatures()) {
// anywhere is ok
if (f.getName().equals(CAS.FEATURE_FULL_NAME_BEGIN)) {
continue;
}
// anywhere is ok
if (f.getName().equals(CAS.FEATURE_FULL_NAME_END)) {
continue;
}
if (!f.getRange().isPrimitive() && aMFs.getFeatureValue(f) instanceof SofaFS) {
continue;
}
// do not attach relation on empty span annotations
if (aMFs.getFeatureValueAsString(f) == null) {
continue;
}
if (aFs.getFeatureValueAsString(f) == null) {
continue;
}
if (!aMFs.getFeatureValueAsString(f).equals(aFs.getFeatureValueAsString(f))) {
return false;
}
}
return true;
}
示例7: makeRoleMap
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private Multimap<String, BratAnnotation<?>> makeRoleMap(AnnotationFS uAnno,
BratEventType bratType, Map<String, Feature> roleFeatMap) {
Multimap<String, BratAnnotation<?>> roleAnnotations = LinkedHashMultimap.create();
for (String roleName : roleFeatMap.keySet()) {
EventRole roleDesc = bratType.getRole(roleName);
// check role range types
boolean entityInRange = isEveryInstanceOf(roleDesc.getRangeTypes(),
BratEntityType.class);
if (!entityInRange && !isEveryInstanceOf(roleDesc.getRangeTypes(), BratEventType.class)) {
throw new UnsupportedOperationException(String.format(
"Mixed entity/event types in role range is not supported: %s", roleDesc));
}
//
Feature roleFeat = roleFeatMap.get(roleName);
FeatureStructure _roleFS = uAnno.getFeatureValue(roleFeat);
if (_roleFS == null) {
continue;
}
List<FeatureStructure> roleFSList;
if (PUtils.hasCollectionRange(roleFeat)) {
roleFSList = PUtils.toList(roleFeat, _roleFS);
} else {
roleFSList = ImmutableList.of(_roleFS);
}
//
for (FeatureStructure roleFS : roleFSList) {
BratAnnotation<?> rv;
if (entityInRange) {
rv = context.demandEntity(roleFS);
} else { // role value should be event
rv = context.getEvent(roleFS, false);
if (rv == null) {
// means that a sub-event has not been mapped yet
// TODO implement nested event mapping
throw new UnsupportedOperationException(
"Nested event mapping is not supported yet");
}
}
roleAnnotations.put(roleName, rv);
}
}
return roleAnnotations;
}
示例8: setChainAnnotation
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void setChainAnnotation(JCas aJCas)
{
for (String l : chainLayers) {
if (l.equals(Token.class.getName())) {
continue;
}
Map<AnnotationUnit, List<List<String>>> annotationsPertype = null;
Type type = getType(aJCas.getCas(), l + CHAIN);
Feature chainFirst = type.getFeatureByBaseName(FIRST);
int chainNo = 1;
for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) {
AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst);
AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(),
linkFs.getCoveredText());
Type lType = linkFs.getType();
// this is the layer with annotations
l = lType.getName();
if (annotationsPerPostion.get(l) == null) {
annotationsPertype = new HashMap<>();
}
else {
annotationsPertype = annotationsPerPostion.get(l);
}
Feature linkNext = linkFs.getType().getFeatureByBaseName(NEXT);
int linkNo = 1;
while (linkFs != null) {
AnnotationFS nextLinkFs = (AnnotationFS) linkFs.getFeatureValue(linkNext);
if (nextLinkFs != null) {
addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo,
chainNo);
}
else {
addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo,
chainNo);
}
linkFs = nextLinkFs;
linkNo++;
if (nextLinkFs != null) {
unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText());
}
}
if (annotationsPertype.keySet().size() > 0) {
annotationsPerPostion.put(l, annotationsPertype);
}
chainNo++;
}
}
}
示例9: setRelationAnnotation
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void setRelationAnnotation(JCas aJCas)
{
for (String l : relationLayers) {
if (l.equals(Token.class.getName())) {
continue;
}
Map<AnnotationUnit, List<List<String>>> annotationsPertype;
if (annotationsPerPostion.get(l) == null) {
annotationsPertype = new HashMap<>();
}
else {
annotationsPertype = annotationsPerPostion.get(l);
}
Type type = getType(aJCas.getCas(), l);
Feature dependentFeature = null;
Feature governorFeature = null;
for (Feature feature : type.getFeatures()) {
if (feature.getShortName().equals(DEPENDENT)) {
// check if the dependent is
dependentFeature = feature;
}
if (feature.getShortName().equals(GOVERNOR)) {
governorFeature = feature;
}
}
for (AnnotationFS fs : CasUtil.select(aJCas.getCas(), type)) {
AnnotationFS depFs = (AnnotationFS) fs.getFeatureValue(dependentFeature);
AnnotationFS govFs = (AnnotationFS) fs.getFeatureValue(governorFeature);
Type govType = govFs.getType();
AnnotationUnit govUnit = getFirstUnit(
getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText()));
if (ambigUnits.get(govType.getName()).get(govUnit) == null) {
govUnit = getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText());
}
AnnotationUnit depUnit = getFirstUnit(
getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText()));
if (ambigUnits.get(govType.getName()).get(depUnit) == null) {
depUnit = getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText());
}
// Since de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency is over
// Over POS anno which itself attached to Token, we need the POS type here
if (type.getName().equals(Dependency.class.getName())) {
govType = aJCas.getCas().getTypeSystem().getType(POS.class.getName());
}
int govRef = 0;
int depRef = 0;
// For that unit test case only, where annotations are on Tokens.
// The WebAnno world do not ever process Token as an annotation
if (!govType.getName().equals(Token.class.getName())
&& ambigUnits.get(govType.getName()).get(govUnit).equals(true)) {
govRef = annotaionRefPerType.get(govType).get(govFs);
}
if (!govType.getName().equals(Token.class.getName())
&& ambigUnits.get(govType.getName()).get(depUnit).equals(true)) {
depRef = annotaionRefPerType.get(govType).get(depFs);
}
setRelationAnnoPerFeature(annotationsPertype, type, fs, depUnit, govUnit, govRef,
depRef, govType);
}
if (annotationsPertype.keySet().size() > 0) {
annotationsPerPostion.put(l, annotationsPertype);
}
}
}
示例10: getNextLink
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
* Get the link following the current link.
*/
private AnnotationFS getNextLink(AnnotationFS aLink)
{
return (AnnotationFS) aLink.getFeatureValue(aLink.getType().getFeatureByBaseName(
linkNextFeatureName));
}
示例11: getAttachedRels
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public Set<AnnotationFS> getAttachedRels(AnnotationFS aFs, AnnotationLayer aLayer)
{
CAS cas = aFs.getCAS();
Set<AnnotationFS> toBeDeleted = new HashSet<>();
for (AnnotationLayer relationLayer : annotationService
.listAttachedRelationLayers(aLayer)) {
ArcAdapter relationAdapter = (ArcAdapter) annotationService.getAdapter(relationLayer);
Type relationType = CasUtil.getType(cas, relationLayer.getName());
Feature sourceFeature = relationType.getFeatureByBaseName(relationAdapter
.getSourceFeatureName());
Feature targetFeature = relationType.getFeatureByBaseName(relationAdapter
.getTargetFeatureName());
// This code is already prepared for the day that relations can go between
// different layers and may have different attach features for the source and
// target layers.
Feature relationSourceAttachFeature = null;
Feature relationTargetAttachFeature = null;
if (relationAdapter.getAttachFeatureName() != null) {
relationSourceAttachFeature = sourceFeature.getRange().getFeatureByBaseName(
relationAdapter.getAttachFeatureName());
relationTargetAttachFeature = targetFeature.getRange().getFeatureByBaseName(
relationAdapter.getAttachFeatureName());
}
for (AnnotationFS relationFS : CasUtil.select(cas, relationType)) {
// Here we get the annotations that the relation is pointing to in the UI
FeatureStructure sourceFS;
if (relationSourceAttachFeature != null) {
sourceFS = relationFS.getFeatureValue(sourceFeature).getFeatureValue(
relationSourceAttachFeature);
}
else {
sourceFS = relationFS.getFeatureValue(sourceFeature);
}
FeatureStructure targetFS;
if (relationTargetAttachFeature != null) {
targetFS = relationFS.getFeatureValue(targetFeature).getFeatureValue(
relationTargetAttachFeature);
}
else {
targetFS = relationFS.getFeatureValue(targetFeature);
}
if (isSame(sourceFS, aFs) || isSame(targetFS, aFs)) {
toBeDeleted.add(relationFS);
LOG.debug("Deleted relation [" + getAddr(relationFS) + "] from layer ["
+ relationLayer.getName() + "]");
}
}
}
return toBeDeleted;
}