當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.getFeatures方法代碼示例

本文整理匯總了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();
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:30,代碼來源:AbstractJsonConsumer.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:27,代碼來源:Tsv3XCasSchemaAnalyzer.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:19,代碼來源:Tsv3XCasSchemaAnalyzer.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:21,代碼來源:ConstraintsVerifier.java

示例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));
        }
    }
}
 
開發者ID:textocat,項目名稱:textokit-core,代碼行數:15,代碼來源:BratUimaMapping.java

示例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);
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:28,代碼來源:Tsv3XCasSchemaAnalyzer.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:28,代碼來源:Tsv3XCasSchemaAnalyzer.java

示例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);
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:40,代碼來源:WebannoTsv3Writer.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:28,代碼來源:AutomationUtil.java

示例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;
}
 
開發者ID:nantesnlp,項目名稱:uima-tokens-regex,代碼行數:10,代碼來源:FeatureMatcher.java

示例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());
    }
  }
}
 
開發者ID:ClearTK,項目名稱:cleartk,代碼行數:14,代碼來源:TypeTestUtil.java

示例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);
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:77,代碼來源:WebannoTsv3Writer.java

示例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);
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:47,代碼來源:WebannoTsv3Writer.java


注:本文中的org.apache.uima.cas.Type.getFeatures方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。