本文整理汇总了Java中org.apache.uima.cas.Type.getFeatures方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getFeatures方法的具体用法?Java Type.getFeatures怎么用?Java Type.getFeatures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.Type
的用法示例。
在下文中一共展示了Type.getFeatures方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFS
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
/**
* Write an annotation to the file.
*
* @param generator
* the generator
* @param annotation
* the annotation
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private void writeFS(JsonGenerator generator, FeatureStructure annotation) throws IOException {
generator.writeStartObject();
Type type = annotation.getType();
generator.writeStringField("type", type.getName());
List<Feature> features = type.getFeatures();
if (annotation instanceof AnnotationFS) {
AnnotationFS annotationFS = (AnnotationFS) annotation;
if (!(annotationFS.getEnd() == 0 && annotationFS.getBegin() == 0)) {
generator.writeStringField("coveredText", annotationFS.getCoveredText());
}
}
if (!features.isEmpty()) {
writeFS(generator, annotation, features);
}
generator.writeEndObject();
}
示例2: isRelationLayer
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static boolean isRelationLayer(Type aType)
{
Feature relSourceFeat = aType.getFeatureByBaseName(FEAT_REL_SOURCE);
boolean hasSourceFeature = relSourceFeat != null && !isPrimitiveFeature(relSourceFeat);
Feature relTargetFeat = aType.getFeatureByBaseName(FEAT_REL_TARGET);
boolean hasTargetFeature = relTargetFeat != null && !isPrimitiveFeature(relTargetFeat);
boolean compatible = true;
for (Feature feat : aType.getFeatures()) {
if (
CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName()) ||
FEAT_REL_SOURCE.equals(feat.getShortName()) ||
FEAT_REL_TARGET.equals(feat.getShortName())
) {
continue;
}
if (!isPrimitiveFeature(feat)) {
compatible = false;
//LOG.debug("Incompatible feature in type [" + aType + "]: " + feat);
break;
}
}
return hasSourceFeature && hasTargetFeature && compatible;
}
示例3: isSpanLayer
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static boolean isSpanLayer(Type aType)
{
boolean compatible = true;
for (Feature feat : aType.getFeatures()) {
if (CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName())) {
continue;
}
if (!(isPrimitiveFeature(feat) || isSlotFeature(feat))) {
compatible = false;
//LOG.debug("Incompatible feature in type [" + aType + "]: " + feat);
break;
}
}
return compatible;
}
示例4: verify
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public boolean verify(FeatureStructure featureStructure, ParsedConstraints parsedConstraints)
{
boolean isOk = false;
Type type = featureStructure.getType();
for (Feature feature : type.getFeatures()) {
if (feature.getRange().isPrimitive()) {
String scopeName = featureStructure.getFeatureValueAsString(feature);
List<Rule> rules = parsedConstraints.getScopeByName(scopeName).getRules();
// Check if all the feature values are ok according to the
// rules;
}
else {
// Here some recursion would be in order
}
}
return isOk;
}
示例5: BratUimaStructureMapping
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
BratUimaStructureMapping(BT bratType, Type uimaType, Map<Feature, String> featureRoles,
BratNoteMapper noteMapper) {
super(bratType, uimaType, noteMapper);
this.featureRoles = ImmutableMap.copyOf(featureRoles);
// sanity check
List<Feature> utFeatures = uimaType.getFeatures();
for (Feature f : featureRoles.keySet()) {
if (!utFeatures.contains(f)) {
throw new IllegalArgumentException(String.format(
"Feature %s does not belong to type %s",
f, uimaType));
}
}
}
示例6: generateColumns
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
private static void generateColumns(TypeSystem aTypeSystem, TsvSchema aSchema,
LayerType aLayerType, Type aType)
{
List<String> specialFeatures = asList(
CAS.FEATURE_FULL_NAME_BEGIN,
CAS.FEATURE_FULL_NAME_END,
CAS.FEATURE_FULL_NAME_SOFA);
for (Feature feat : aType.getFeatures()) {
if (specialFeatures.contains(feat.getName())) {
continue;
}
if (isPrimitiveFeature(feat)) {
aSchema.addColumn(new TsvColumn(aType, aLayerType, feat, FeatureType.PRIMITIVE));
}
else if (SPAN.equals(aLayerType) && isSlotFeature(aTypeSystem, feat)) {
aSchema.addColumn(new TsvColumn(aType, aLayerType, feat, FeatureType.SLOT_ROLE));
Type slotTargetType = feat.getRange().getComponentType()
.getFeatureByBaseName(FEAT_SLOT_TARGET).getRange();
TsvColumn targetColumn = new TsvColumn(aType, aLayerType, feat,
FeatureType.SLOT_TARGET);
targetColumn.setTargetTypeHint(slotTargetType);
aSchema.addColumn(targetColumn);
}
}
}
示例7: isChainLayer
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static boolean isChainLayer(Type aType)
{
boolean hasTypeFeature = aType.getFeatureByBaseName(COREFERENCE_TYPE_FEATURE) != null;
boolean hasRelationFeature = aType
.getFeatureByBaseName(COREFERENCE_RELATION_FEATURE) != null;
boolean nameEndsInLink = aType.getName().endsWith("Link");
boolean compatible = true;
for (Feature feat : aType.getFeatures()) {
if (
CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName()) ||
CHAIN_NEXT_FEAT.equals(feat.getShortName()) ||
COREFERENCE_TYPE_FEATURE.equals(feat.getShortName()) ||
COREFERENCE_RELATION_FEATURE.equals(feat.getShortName())
) {
continue;
}
if (!isPrimitiveFeature(feat)) {
compatible = false;
LOG.debug("Incompatible feature in type [" + aType + "]: " + feat);
break;
}
}
return hasTypeFeature && hasRelationFeature && nameEndsInLink && compatible;
}
示例8: setRelationAnnoPerFeature
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
private void setRelationAnnoPerFeature(
Map<AnnotationUnit, List<List<String>>> annotationsPertype, Type type, AnnotationFS fs,
AnnotationUnit depUnit, AnnotationUnit govUnit, int aGovRef, int aDepRef, Type aDepType)
{
List<String> annoPerFeatures = new ArrayList<>();
featurePerLayer.putIfAbsent(type.getName(), new LinkedHashSet<>());
for (Feature feature : type.getFeatures()) {
if (feature.toString().equals("uima.cas.AnnotationBase:sofa")
|| feature.toString().equals("uima.tcas.Annotation:begin")
|| feature.toString().equals("uima.tcas.Annotation:end")
|| feature.getShortName().equals(GOVERNOR)
|| feature.getShortName().equals(DEPENDENT)
|| feature.getShortName().equals(FIRST)
|| feature.getShortName().equals(NEXT)) {
continue;
}
int ref = getRefId(type, fs, depUnit);
String annotation = fs.getFeatureValueAsString(feature);
if (annotation == null) {
annotation = "*";
}
else {
annotation = replaceEscapeChars(annotation);
}
annoPerFeatures.add(annotation);// +(ref > 0 ? "[" + ref + "]" : ""));
featurePerLayer.get(type.getName()).add(feature.getShortName());
}
// add the governor and dependent unit addresses (separated by _
String govRef = unitsLineNumber.get(govUnit)
+ ((aDepRef > 0 || aGovRef > 0) ? "[" + aGovRef + "_" + aDepRef + "]" : "");
annoPerFeatures.add(govRef);
featurePerLayer.get(type.getName()).add(BT + aDepType.getName());
// the column for the dependent unit address
annotationsPertype.putIfAbsent(depUnit, new ArrayList<>());
if (annoPerFeatures.size() == 0) {
annoPerFeatures.add("*");
}
annotationsPertype.get(depUnit).add(annoPerFeatures);
}
示例9: isSamAnno
import org.apache.uima.cas.Type; //导入方法依赖的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;
}
示例10: load
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public Boolean load(Type type) throws Exception {
Feature feature = getFeature();
List<Feature> typeFeatures = type.getFeatures();
for(Feature typeFeature:typeFeatures)
if(typeFeature == feature || typeFeature.equals(feature) || typeFeature.getName().equals(feature.getName()))
return true;
return false;
}
示例11: testType
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static void testType(JCas jcas, TOP top) throws Exception {
Class<?> cls = top.getClass();
if (top instanceof Annotation) {
testAnnotationType(jcas, (Annotation) top);
}
Type type = jcas.getTypeSystem().getType(cls.getName());
for (Object obj : type.getFeatures()) {
Feature feature = (Feature) obj;
if (feature.getDomain().equals(type)) {
invokeMethods(cls, type, top, jcas, feature.getShortName());
}
}
}
示例12: setRelationAnnotation
import org.apache.uima.cas.Type; //导入方法依赖的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);
}
}
}
示例13: setChainAnnoPerFeature
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
private void setChainAnnoPerFeature(Map<AnnotationUnit, List<List<String>>> aAnnotationsPertype,
Type aType, AnnotationFS aFs, AnnotationUnit aUnit, int aLinkNo, int achainNo,
boolean aMultiUnit, boolean aFirst)
{
List<String> annoPerFeatures = new ArrayList<>();
for (Feature feature : aType.getFeatures()) {
if (feature.toString().equals("uima.cas.AnnotationBase:sofa")
|| feature.toString().equals("uima.tcas.Annotation:begin")
|| feature.toString().equals("uima.tcas.Annotation:end")
|| feature.getShortName().equals(GOVERNOR)
|| feature.getShortName().equals(DEPENDENT)
|| feature.getShortName().equals(FIRST)
|| feature.getShortName().equals(NEXT)) {
continue;
}
String annotation = aFs.getFeatureValueAsString(feature);
if (annotation == null) {
annotation = "*";
}
else {
annotation = replaceEscapeChars(annotation);
}
if (feature.getShortName().equals(REF_REL)) {
annotation = annotation + "->" + achainNo + "-" + aLinkNo;
}
else if (aMultiUnit) {
annotation = annotation + "[" + achainNo + "]";
}
else {
annotation = annotation + "[" + achainNo + "]";
}
featurePerLayer.get(aType.getName()).add(feature.getShortName());
annoPerFeatures.add(annotation);
}
aAnnotationsPertype.putIfAbsent(aUnit, new ArrayList<>());
ambigUnits.putIfAbsent(aType.getName(), new HashMap<>());
ambigUnits.get(aType.getName()).put(aUnit, true); // coref are always ambig
if (annoPerFeatures.size() == 0) {
annoPerFeatures.add("*" + "[" + achainNo + "]");
}
aAnnotationsPertype.get(aUnit).add(annoPerFeatures);
}