本文整理汇总了Java中org.apache.uima.cas.TypeSystem类的典型用法代码示例。如果您正苦于以下问题:Java TypeSystem类的具体用法?Java TypeSystem怎么用?Java TypeSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeSystem类属于org.apache.uima.cas包,在下文中一共展示了TypeSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultFeatureMapper
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
/**
* {@code FeatureCopier} used for features which are references to {@code FeatureStructure}s.
*
* @param fromFeature the {@link Feature}
* @param fromFs the {@link FeatureStructure} to copy from
* @param toFs the {@link FeatureStructure} to copy to
*/
private void defaultFeatureMapper(Feature fromFeature, FeatureStructure fromFs,
FeatureStructure toFs) {
TypeSystem typeSystem = fromFs.getCAS().getTypeSystem();
if (typeSystem.subsumes(typeSystem.getType(CAS.TYPE_NAME_STRING), fromFeature.getRange())) {
STRING_COPIER.copy(fromFeature, fromFs, toFs);
} else {
FeatureStructure fromFeatureValue = fromFs.getFeatureValue(fromFeature);
if (fromFeatureValue != null) {
FeatureStructure toFeatureValue = fsEncounteredCallback.apply(fromFeatureValue);
Feature toFeature = toFs.getType().getFeatureByBaseName(fromFeature.getShortName());
toFs.setFeatureValue(toFeature, toFeatureValue);
}
}
}
示例2: typeSystemInit
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
/**
* Initializes the type system.
*/
@Override
public void typeSystemInit(TypeSystem typeSystem) throws AnalysisEngineProcessException {
// sentence type
this.sentenceType = AnnotatorUtil.getRequiredTypeParameter(this.context, typeSystem,
UimaUtil.SENTENCE_TYPE_PARAMETER);
// token type
this.tokenType = AnnotatorUtil.getRequiredTypeParameter(this.context, typeSystem,
UimaUtil.TOKEN_TYPE_PARAMETER);
// pos feature
this.posFeature = AnnotatorUtil.getRequiredFeatureParameter(this.context, this.tokenType,
UimaUtil.POS_FEATURE_PARAMETER, CAS.TYPE_NAME_STRING);
this.probabilityFeature = AnnotatorUtil.getOptionalFeatureParameter(this.context, this.tokenType,
UimaUtil.PROBABILITY_FEATURE_PARAMETER, CAS.TYPE_NAME_DOUBLE);
}
示例3: 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;
}
示例4: getValueOfFS
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
@Override
public UimaPrimitive getValueOfFS(TypeSystem typeSystem, FeatureStructure targetFS) throws NlpTabException {
Collection<Object> values = new LinkedList<>();
FeatureStructure pointer = targetFS;
while (pointer.getType().getName().equals(nonEmptyName)) {
Object value;
try {
value = headMethod.invoke(pointer, headFeature);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new NlpTabException(e);
}
values.add(value);
pointer = pointer.getFeatureValue(tailFeature);
}
Type type = targetFS.getType();
String typeShortName = type.getShortName();
return new UimaPrimitive(values, typeShortName);
}
示例5: CASDocument
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
CASDocument(@Nullable LabelAdapters labelAdapters, CAS cas) {
this.labelAdapters = labelAdapters;
this.cas = cas;
TypeSystem typeSystem = cas.getTypeSystem();
metadataType = typeSystem
.getType("edu.umn.biomedicus.uima.type1_5.DocumentMetadata");
keyFeature = metadataType.getFeatureByBaseName("key");
valueFeature = metadataType.getFeatureByBaseName("value");
metadata = cas.getView("metadata");
Type idType = typeSystem
.getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
Feature idFeat = idType.getFeatureByBaseName("documentId");
documentId = metadata.getIndexRepository()
.getAllIndexedFS(idType)
.get()
.getStringValue(idFeat);
}
示例6: process
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
LOGGER.debug("Segmenting rtf text.");
CAS systemView = aCAS.getView("SystemView");
TextSegmentsBuilder textSegmentsBuilder = new TextSegmentsBuilder(systemView);
TypeSystem typeSystem = systemView.getTypeSystem();
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.ParagraphAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.RowAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.CellAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.NestedRowAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.NestedCellAnnotation"));
textSegmentsBuilder.buildInView();
}
示例7: getAnnotation
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
@Nullable
AnnotationFS getAnnotation(CAS cas, int begin, int end, int value) {
if (begin < 0) {
throw new IllegalArgumentException("Begin: " + begin + "before 0.");
}
if (end < begin) {
throw new IllegalArgumentException(
annotationClassName + " - illegal annotation span at begin: " + begin
+ " end: " + end);
}
if (!zeroLengthEmitted && end == begin) {
return null;
}
TypeSystem typeSystem = cas.getTypeSystem();
Type type = typeSystem.getType(annotationClassName);
AnnotationFS annotation = cas.createAnnotation(type, begin, end);
if (valueIncluded) {
Feature valueFeature = type.getFeatureByBaseName("value");
annotation.setIntValue(valueFeature, value);
}
return annotation;
}
示例8: CasOutputDestination
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
/**
* Default constructor, initializes all fields.
*
* @param destinationView The view to write to.
* @param casMappings The property cas mappings
* @param annotationTypeForControlWord The annotation type to create for control words.
*/
CasOutputDestination(CAS destinationView,
List<PropertyCasMapping> casMappings,
Map<String, Type> annotationTypeForControlWord,
String name) {
this.destinationView = destinationView;
this.sofaBuilder = new StringBuilder();
this.completedAnnotations = new ArrayList<>();
this.annotationPropertyWatchers = casMappings.stream()
.map(AnnotationPropertyWatcher::new)
.collect(Collectors.toList());
this.annotationTypeForControlWord = annotationTypeForControlWord;
this.name = name;
TypeSystem typeSystem = destinationView.getTypeSystem();
illegalCharType = typeSystem
.getType("edu.umn.biomedicus.type.IllegalXmlCharacter");
valueFeat = illegalCharType.getFeatureByBaseName("value");
}
示例9: getType
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
public static Type getType(TypeSystem ts, Object value) {
if (value instanceof String)
return ts.getType(CAS.TYPE_NAME_STRING);
if (value instanceof Integer)
return ts.getType(CAS.TYPE_NAME_INTEGER);
if (value instanceof Float)
return ts.getType(CAS.TYPE_NAME_FLOAT);
if (value instanceof Byte)
return ts.getType(CAS.TYPE_NAME_BYTE);
if (value instanceof Short)
return ts.getType(CAS.TYPE_NAME_SHORT);
if (value instanceof Long)
return ts.getType(CAS.TYPE_NAME_LONG);
if (value instanceof Double)
return ts.getType(CAS.TYPE_NAME_DOUBLE);
if (value instanceof Boolean)
return ts.getType(CAS.TYPE_NAME_BOOLEAN);
if (value instanceof FeatureStructure)
return ((FeatureStructure)value).getType();
return null;
}
示例10: typeSystemInit
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
@Override
public void typeSystemInit(TypeSystem ts) throws AnalysisEngineProcessException {
super.typeSystemInit(ts);
//
tokenType = ts.getType(tokenTypeName);
annotationTypeExist(tokenTypeName, tokenType);
//
encodeTypesMap = Maps.newHashMap();
for (int i = 0; i < encodeTypeNames.size(); i++) {
String etn = encodeTypeNames.get(i);
Type et = ts.getType(etn);
annotationTypeExist(etn, et);
//
String etLabel = encodeTypeLabels != null ? encodeTypeLabels.get(i) : getTypeLabel(et);
encodeTypesMap.put(et, etLabel);
}
encodeTypesMap = ImmutableMap.copyOf(encodeTypesMap);
}
示例11: typeSystemInit
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
@Override
public void typeSystemInit(TypeSystem ts) {
tag2TypeMap = Maps.newHashMap();
for (int i = 0; i < pTags.length; i++) {
String tag = pTags[i];
String relTypeName = pTypes[i];
String typeName;
if (baseNamespace != null) {
typeName = baseNamespace + "." + relTypeName;
} else {
typeName = relTypeName;
}
Type type = ts.getType(typeName);
try {
AnnotatorUtils.annotationTypeExist(typeName, type);
} catch (AnalysisEngineProcessException e) {
throw new IllegalStateException(e);
}
tag2TypeMap.put(tag, type);
}
tag2TypeMap = ImmutableMap.copyOf(tag2TypeMap);
}
示例12: createDirectory
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
public static CasDirectory createDirectory(TypeSystem typeSystem, String implClassName,
Map<String, String> props) {
try {
@SuppressWarnings("unchecked")
Class<CasDirectory> implClass = (Class<CasDirectory>) Class.forName(implClassName);
CasDirectory result = implClass.newInstance();
result.setTypeSystem(typeSystem);
for (String curPropName : props.keySet()) {
setProperty(result, curPropName, props.get(curPropName));
}
result.init();
return result;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例13: createTypeSystem
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
private TypeSystem createTypeSystem() throws IOException, UIMAException {
TypeSystemDescription tsDesc = null;
if (typeSystemDescPaths != null && typeSystemDescPaths.length > 0) {
tsDesc = createTypeSystemDescriptionFromPath(typeSystemDescPaths);
}
if (typeSystemDescNames != null && typeSystemDescNames.length > 0) {
TypeSystemDescription tsDescFromNames = createTypeSystemDescription(
typeSystemDescNames);
if (tsDesc != null) {
tsDesc = mergeTypeSystems(asList(tsDesc, tsDescFromNames));
} else {
tsDesc = tsDescFromNames;
}
}
if (tsDesc == null) {
log.info("TypeSystemDescription will be created using the UIMAFit discovery");
tsDesc = TypeSystemDescriptionFactory.createTypeSystemDescription();
}
CAS dumbCas = CasCreationUtils.createCas(tsDesc, null, null);
TypeSystem typeSystem = dumbCas.getTypeSystem();
// printAllTypes();
return typeSystem;
}
示例14: isSlotFeature
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
private static boolean isSlotFeature(TypeSystem aTypeSystem, Feature feat)
{
// This could be written more efficiently using a single conjunction. The reason this
// has not been done is to facilitate debugging.
boolean multiValued = feat.getRange().isArray() || aTypeSystem
.subsumes(aTypeSystem.getType(CAS.TYPE_NAME_LIST_BASE), feat.getRange());
if (!multiValued) {
return false;
}
boolean linkInheritsFromTop = CAS.TYPE_NAME_TOP
.equals(aTypeSystem.getParent(feat.getRange().getComponentType()).getName());
boolean hasTargetFeature = feat.getRange().getComponentType()
.getFeatureByBaseName(FEAT_SLOT_TARGET) != null;
boolean hasRoleFeature = feat.getRange().getComponentType()
.getFeatureByBaseName(FEAT_SLOT_ROLE) != null;
return linkInheritsFromTop && hasTargetFeature && hasRoleFeature;
}
示例15: getNonIndexedFSes
import org.apache.uima.cas.TypeSystem; //导入依赖的package包/类
public static Set<FeatureStructure> getNonIndexedFSes(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Set<FeatureStructure> allReachableFS = collectReachable(aCas);
// Remove all that are indexed
allReachableFS.removeAll(allIndexedFS);
// Remove all that are not annotations
allReachableFS.removeIf(fs -> !ts.subsumes(aCas.getAnnotationType(), fs.getType()));
// All that is left are non-index annotations
return allReachableFS;
}