本文整理匯總了Java中org.apache.uima.cas.Type.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.getName方法的具體用法?Java Type.getName怎麽用?Java Type.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.uima.cas.Type
的用法示例。
在下文中一共展示了Type.getName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldAcceptType
import org.apache.uima.cas.Type; //導入方法依賴的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;
}
示例2: createArray
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
public static CommonArrayFS createArray(CAS cas, Type type, int length) {
String name = type.getName();
if (CAS.TYPE_NAME_BOOLEAN_ARRAY.equals(name))
return cas.createBooleanArrayFS(length);
if (CAS.TYPE_NAME_BYTE_ARRAY.equals(name))
return cas.createByteArrayFS(length);
if (CAS.TYPE_NAME_DOUBLE_ARRAY.equals(name))
return cas.createDoubleArrayFS(length);
if (CAS.TYPE_NAME_FLOAT_ARRAY.equals(name))
return cas.createFloatArrayFS(length);
if (CAS.TYPE_NAME_INTEGER_ARRAY.equals(name))
return cas.createIntArrayFS(length);
if (CAS.TYPE_NAME_LONG_ARRAY.equals(name))
return cas.createLongArrayFS(length);
if (CAS.TYPE_NAME_SHORT_ARRAY.equals(name))
return cas.createShortArrayFS(length);
if (CAS.TYPE_NAME_STRING_ARRAY.equals(name))
return cas.createStringArrayFS(length);
return cas.createArrayFS(length);
}
示例3: resolveReference
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
public AnnotationFS resolveReference(Type aType, String aId,
int aDisambiguationId)
{
AnnotationFS annotation;
// If there is a disambiguation ID then we can easily look up the annotation via the ID.
// A disambiguation ID of 0 used when a relation refers to a non-ambiguous target and
// it is handled in the second case.
if (aDisambiguationId > 0) {
annotation = getDisambiguatedAnnotation(aDisambiguationId);
if (annotation == null) {
throw new IllegalStateException("Unable to resolve reference to disambiguation ID ["
+ aDisambiguationId + "]");
}
}
// Otherwise, we'll have to go through the source unit.
else {
annotation = getUnit(aId).getUimaAnnotation(aType, 0);
if (annotation == null) {
throw new IllegalStateException(
"Unable to resolve reference to unambiguous annotation of type ["
+ aType.getName() + "] in unit [" + aId + "]");
}
}
return annotation;
}
示例4: getIdentifierForFs
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
public String getIdentifierForFs(FeatureStructure featureStructure) throws InterruptedException {
int fsRef = featureStructure.getCAS().getLowLevelCAS().ll_getFSRef(featureStructure);
Type type = featureStructure.getType();
if (type == null) {
throw new IllegalArgumentException("type was null");
}
String typeName = type.getName();
String identifier = identifierForFsRef.get(fsRef);
boolean newlyCreated = false;
if (identifier == null) {
synchronized (this) {
identifier = identifierForFsRef.get(fsRef);
if (identifier == null) {
identifier = Strings.base64UUID();
identifierForFsRef.put(fsRef, identifier);
}
newlyCreated = true;
}
}
if (newlyCreated && typeFilter.apply(typeName)) {
fsRefQueue.put(fsRef);
}
return identifier;
}
示例5: isValidType
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
public static boolean isValidType(Type type, TypeSystem typeSystem) {
String typeName = type.getName();
for (String handledType : HANDLED_TYPES) {
if (typeName.equals(handledType))
return true;
}
// see section 2.3.4 of UIMA References
if (typeSystem.subsumes(typeSystem.getType("uima.cas.String"), type))
return true;
if (typeSystem.subsumes(typeSystem.getType("uima.tcas.Annotation"), type))
return true;
return false;
}
示例6: getType
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
/**
* For a given type name, look through the type system and return the matching class.
* If two types of the same name (but different packages) exist, then null will be returned and the package will need to be included in the typeName.
*
* @param typeName The name of the type, optionally including the package
* @param typeSystem The type system to search
* @return The class associated with that type
*/
@SuppressWarnings("unchecked")
public static Class<AnnotationBase> getType(String typeName, TypeSystem typeSystem){
SuffixTree<Class<AnnotationBase>> types = new ConcurrentSuffixTree<>(new DefaultByteArrayNodeFactory());
Iterator<Type> itTypes = typeSystem.getTypeIterator();
while(itTypes.hasNext()){
Type t = itTypes.next();
Class<AnnotationBase> c;
try {
String clazz = t.getName();
if(clazz.startsWith("uima.")){
continue;
} else if(clazz.endsWith("[]")){
clazz = clazz.substring(0, clazz.length() - 2);
}
Class<?> unchecked = Class.forName(clazz);
if(AnnotationBase.class.isAssignableFrom(unchecked)){
c = (Class<AnnotationBase>) unchecked;
types.put(t.getName(), c);
}else{
LOGGER.debug("Skipping class {} that doesn't inherit from AnnotationBase");
}
} catch (ClassNotFoundException e) {
LOGGER.warn("Unable to load class {} from type system", t.getName(), e);
}
}
Class<AnnotationBase> ret = getClassFromType("."+typeName, types);
if(ret == null){
ret = getClassFromType(typeName, types);
}
if(ret == null){
LOGGER.warn("No uniquely matching class found for type {}", typeName);
}
return ret;
}
示例7: setTokenAnnos
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
private void setTokenAnnos(CAS aCas, Map<Integer, String> aTokenAnnoMap, Type aType,
Feature aFeature)
{
LowLevelCAS llCas = aCas.getLowLevelCAS();
for (AnnotationFS annoFs : CasUtil.select(aCas, aType)) {
boolean first = true;
boolean previous = false; // exists previous annotation, place-holed O-_ should be kept
for (Token token : selectCovered(Token.class, annoFs)) {
if (annoFs.getBegin() <= token.getBegin() && annoFs.getEnd() >= token.getEnd()) {
String annotation = annoFs.getFeatureValueAsString(aFeature);
if (annotation == null) {
annotation = aType.getName() + "_";
}
if (aTokenAnnoMap.get(llCas.ll_getFSRef(token)) == null) {
if (previous) {
if (!multipleSpans.contains(aType.getName())) {
aTokenAnnoMap.put(llCas.ll_getFSRef(token), annotation);
}
else {
aTokenAnnoMap.put(llCas.ll_getFSRef(token), "O-_|"
+ (first ? "B-" : "I-") + annotation);
first = false;
}
}
else {
if (!multipleSpans.contains(aType.getName())) {
aTokenAnnoMap.put(llCas.ll_getFSRef(token), annotation);
}
else {
aTokenAnnoMap.put(llCas.ll_getFSRef(token), (first ? "B-" : "I-")
+ annotation);
first = false;
}
}
}
else {
if (!multipleSpans.contains(aType.getName())) {
aTokenAnnoMap.put(llCas.ll_getFSRef(token),
aTokenAnnoMap.get(llCas.ll_getFSRef(token)) + "|"
+ annotation);
previous = true;
}
else {
aTokenAnnoMap.put(llCas.ll_getFSRef(token),
aTokenAnnoMap.get(llCas.ll_getFSRef(token)) + "|"
+ (first ? "B-" : "I-") + annotation);
first = false;
previous = true;
}
}
}
}
}
}
示例8: setChainAnnotation
import org.apache.uima.cas.Type; //導入方法依賴的package包/類
private void setChainAnnotation(JCas aJCas)
{
for (String l : chainLayers) {
if (l.equals(Token.class.getName())) {
continue;
}
Map<AnnotationUnit, List<List<String>>> annotationsPertype = null;
Type type = getType(aJCas.getCas(), l + CHAIN);
Feature chainFirst = type.getFeatureByBaseName(FIRST);
int chainNo = 1;
for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) {
AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst);
AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(),
linkFs.getCoveredText());
Type lType = linkFs.getType();
// this is the layer with annotations
l = lType.getName();
if (annotationsPerPostion.get(l) == null) {
annotationsPertype = new HashMap<>();
}
else {
annotationsPertype = annotationsPerPostion.get(l);
}
Feature linkNext = linkFs.getType().getFeatureByBaseName(NEXT);
int linkNo = 1;
while (linkFs != null) {
AnnotationFS nextLinkFs = (AnnotationFS) linkFs.getFeatureValue(linkNext);
if (nextLinkFs != null) {
addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo,
chainNo);
}
else {
addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo,
chainNo);
}
linkFs = nextLinkFs;
linkNo++;
if (nextLinkFs != null) {
unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText());
}
}
if (annotationsPertype.keySet().size() > 0) {
annotationsPerPostion.put(l, annotationsPertype);
}
chainNo++;
}
}
}