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


Java TypeSystem.getParent方法代码示例

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


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

示例1: shouldAcceptType

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
public boolean shouldAcceptType(Type type, TypeSystem typeSystem) {
    Type parentType = type;
    int acceptedParentDistance = Integer.MAX_VALUE;
    int deniedParentDistance = Integer.MAX_VALUE;
    int parentDistance = 0;
    while (parentType != null) {
        String parentTypeName = parentType.getName();
        if (typeWhitelist.contains(parentTypeName)) {
            acceptedParentDistance = Math.min(acceptedParentDistance, parentDistance);
        }

        if (typeBlacklist.contains(parentTypeName)) {
            deniedParentDistance = Math.min(deniedParentDistance, parentDistance);
        }

        parentType = typeSystem.getParent(parentType);
        parentDistance++;
    }

    return acceptedParentDistance <= deniedParentDistance;
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:22,代码来源:TypeFilterLists.java

示例2: willProcess

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
@Override
public void willProcess(FeatureStructure featureStructure, TypeSystemInfo typeSystemInfo) throws NlpTabException {
    Type type = featureStructure.getType();
    TypeSystem typeSystem = featureStructure.getCAS().getTypeSystem();

    Type typePointer = type;
    while (typePointer != null && !typesSeen.contains(typePointer.getName())) {
        typesSeen.add(typePointer.getName());

        uploadType(typeSystemInfo, typeSystem, typePointer);

        typePointer = typeSystem.getParent(typePointer);
    }
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:15,代码来源:SystemIndexCasProcessingDelegate.java

示例3: buildRequest

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
@Override
public IndexRequestBuilder buildRequest(String primaryIndex, SofaData sofaData, FeatureStructure featureStructure) throws IOException, NlpTabException, InterruptedException {
    Type type = featureStructure.getType();
    if (type == null) {
        throw new IllegalStateException();
    }

    CAS cas = featureStructure.getCAS();
    TypeSystem typeSystem = cas.getTypeSystem();
    if (typeSystem == null) {
        throw new IllegalStateException();
    }
    XContentBuilder builder = XContentFactory.jsonBuilder()
            .startObject()
            .field("system", primaryIndex)
            .field("casIdentifier", sofaData.getCasIdentifierString())
            .field("casViewIdentifier", sofaData.getCasViewIdentifierString())
            .field("documentIdentifier", sofaData.getDocumentIdentifierString())
            .field("primaryType", type.getName());

    builder.startArray("types");
    Type parentType = type;
    while (parentType != null) {
        builder.value(parentType.getName());
        parentType = typeSystem.getParent(parentType);
    }
    builder.endArray();

    if (primitiveValue != null) {
        builder.field("items", primitiveValue.getValueOrNull());
    }

    if (listItems != null) {
        builder.array("listItems", listItems.toArray());
    }

    if (arrayItems != null) {
        builder.array("arrayItems", arrayItems.toArray());
    }

    if (primitiveFeatureInstances != null) {
        Set<String> primitiveFeatureInstanceIds = primitiveFeatureInstances.keySet();
        for (String valueTypeKey : primitiveFeatureInstanceIds) {
            builder.startObject(valueTypeKey + "Features");
            Collection<PrimitiveFeatureInstance> valuePrimitiveFeatures = primitiveFeatureInstances.get(valueTypeKey);
            if (valuePrimitiveFeatures != null) {
                for (PrimitiveFeatureInstance primitiveFeatureInstance : valuePrimitiveFeatures) {
                    String name = primitiveFeatureInstance.getLuceneSafeFeatureName();
                    Object valueOrNull = primitiveFeatureInstance.getValueOfFeature().getValueOrNull();
                    builder.field(name, valueOrNull);
                }
            }
            builder.endObject();
        }
    }

    if (referenceFeatureInstances != null) {
        builder.startObject("references");
        for (ReferenceFeatureInstance referenceFeatureInstance : referenceFeatureInstances) {
            String featureName = referenceFeatureInstance.getLuceneSafeFeatureName();
            String referenceId = referenceFeatureInstance.getReferenceId();
            builder.field(featureName, referenceId);
        }
        builder.endObject();
    }

    return client.prepareIndex(primaryIndex, "FeatureStructure")
            .setId(sofaData.getIdentifierForFs(featureStructure))
            .setSource(builder.endObject());
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:71,代码来源:SystemIndexFSProcessorDelegate.java


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