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


Java TypeSystemDescription.addType方法代码示例

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


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

示例1: createMultiLinkWithRoleTestTypeSytem

import org.apache.uima.resource.metadata.TypeSystemDescription; //导入方法依赖的package包/类
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem()
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", Token.class.getName());

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:22,代码来源:DiffUtils.java

示例2: testFail

import org.apache.uima.resource.metadata.TypeSystemDescription; //导入方法依赖的package包/类
@Test
public void testFail()
    throws Exception
{
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    
    String refTypeName = "RefType";
    
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    
    Type refType = cas.getTypeSystem().getType(refTypeName);
    
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);

    // A non-index annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);

    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    
    messages.forEach(System.out::println);
    
    assertFalse(result);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:38,代码来源:AllAnnotationsIndexedCheckTest.java

示例3: testOK

import org.apache.uima.resource.metadata.TypeSystemDescription; //导入方法依赖的package包/类
@Test
public void testOK()
    throws Exception
{
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    
    String refTypeName = "RefType";
    
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    
    Type refType = cas.getTypeSystem().getType(refTypeName);
    
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);

    // An indexed annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno2);

    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    
    messages.forEach(System.out::println);
    
    assertTrue(result);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:39,代码来源:AllAnnotationsIndexedCheckTest.java

示例4: generateFeature

import org.apache.uima.resource.metadata.TypeSystemDescription; //导入方法依赖的package包/类
private void generateFeature(TypeSystemDescription aTSD, TypeDescription aTD,
        AnnotationFeature aFeature)
{
    switch (aFeature.getMultiValueMode()) {
    case NONE:
        if (aFeature.isVirtualFeature()) {
            aTD.addFeature(aFeature.getName(), "", CAS.TYPE_NAME_STRING);
        }
        else {
            aTD.addFeature(aFeature.getName(), "", aFeature.getType());
        }
        break;
    case ARRAY: {
        switch (aFeature.getLinkMode()) {
        case WITH_ROLE: {
            // Link type
            TypeDescription linkTD = aTSD.addType(aFeature.getLinkTypeName(), "",
                    CAS.TYPE_NAME_TOP);
            linkTD.addFeature(aFeature.getLinkTypeRoleFeatureName(), "", CAS.TYPE_NAME_STRING);
            linkTD.addFeature(aFeature.getLinkTypeTargetFeatureName(), "", aFeature.getType());
            // Link feature
            aTD.addFeature(aFeature.getName(), "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(),
                    false);
            break;
        }
        default:
            throw new IllegalArgumentException("Unsupported link mode ["
                    + aFeature.getLinkMode() + "] on feature [" + aFeature.getName() + "]");
        }
        break;
    }
    default:
        throw new IllegalArgumentException("Unsupported multi-value mode ["
                + aFeature.getMultiValueMode() + "] on feature [" + aFeature.getName() + "]");
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:37,代码来源:AnnotationSchemaServiceImpl.java


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