本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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() + "]");
}
}