當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.getName方法代碼示例

本文整理匯總了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;
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:22,代碼來源:TypeFilterLists.java

示例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);
}
 
開發者ID:argo-nactem,項目名稱:nactem-type-mapper,代碼行數:21,代碼來源:UimaUtils.java

示例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;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:27,代碼來源:TsvDocument.java

示例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;
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:29,代碼來源:SofaData.java

示例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;
}
 
開發者ID:ClearTK,項目名稱:cleartk,代碼行數:16,代碼來源:TypePathExtractor.java

示例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;
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:50,代碼來源:TypeUtils.java

示例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;
                    }
                }

            }
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:56,代碼來源:WebannoTsv2Writer.java

示例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++;
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:52,代碼來源:WebannoTsv3Writer.java


注:本文中的org.apache.uima.cas.Type.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。