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


Java Type类代码示例

本文整理汇总了Java中org.apache.uima.cas.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: process

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
    TreeMatcher treeMatcher = new TreeMatcher(this.tree);
    Iterator<Token> iterator = JCasUtil.iterator(jcas, Token.class);
    Type type = CasUtil.getType(jcas.getCas(), this.annotationType);
    while (iterator.hasNext()) {
        Token token = iterator.next();
        String tokenText = token.getCoveredText();
        tokenText = this.textNormalizer.normalize(tokenText);
        treeMatcher.proceed(token.getBegin(), token.getEnd(), tokenText);
        List<TreeMatch> matches = treeMatcher.getMatches();

        for (TreeMatch match : matches) {
            for (EntryMetadata metadata : match.matchedEntries()) {
                annotate(jcas, type, match, metadata);
            }
        }
    }
}
 
开发者ID:tokenmill,项目名称:dictionary-annotator,代码行数:20,代码来源:DictionaryAnnotator.java

示例2: 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

示例3: getValueOfFS

import org.apache.uima.cas.Type; //导入依赖的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);
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:25,代码来源:PrimitiveListValueAdapter.java

示例4: CasViewProcessor

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Inject
CasViewProcessor(Client client,
                 FeatureStructureProcessorFactory featureStructureProcessorFactory,
                 @Assisted CasProcessorSettings casProcessorSettings,
                 @Assisted SofaData sofaData) throws InterruptedException {
    this.client = client;
    this.featureStructureProcessorFactory = featureStructureProcessorFactory;

    this.casProcessorSettings = casProcessorSettings;
    typeSystemInfo = casProcessorSettings.getTypeSystemInfo();
    casProcessingDelegate = casProcessorSettings.getCasProcessingDelegate();


    this.sofaData = sofaData;
    this.fsRefQueue = sofaData.getFsRefQueue();

    CAS cas = sofaData.getCas();

    lowLevelCAS = cas.getLowLevelCAS();
    Type topType = cas.getTypeSystem().getTopType();
    FSIterator<FeatureStructure> allIndexedFS = cas.getIndexRepository().getAllIndexedFS(topType);
    while (allIndexedFS.hasNext()) {
        sofaData.getIdentifierForFs(allIndexedFS.next());
    }
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:26,代码来源:CasViewProcessor.java

示例5: adaptFile

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Override
public void adaptFile(CAS cas, Path path) throws CollectionException {
  LOGGER.info("Deserializing an input stream into a cas");
  try (InputStream inputStream = Files.newInputStream(path)) {
    XmiCasDeserializer.deserialize(inputStream, cas,
        !(failOnUnknownType == null || failOnUnknownType));
  } catch (SAXException | IOException e) {
    LOGGER.error("Failed on document: {}", path);
    throw new CollectionException(e);
  }

  if (addDocumentId != null && addDocumentId) {
    CAS metadata = cas.getView("metadata");

    Type idType = metadata.getTypeSystem()
        .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
    Feature idFeat = idType.getFeatureByBaseName("documentId");

    FeatureStructure fs = metadata.createFS(idType);
    fs.setStringValue(idFeat, path.getFileName().toString());
    metadata.addFsToIndexes(fs);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:24,代码来源:XmiInputFileAdapter.java

示例6: process

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
  Type documentIdType = aCAS.getTypeSystem()
      .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
  Feature docIdFeat = documentIdType.getFeatureByBaseName("documentId");

  String documentId = aCAS.getIndexRepository()
      .getAllIndexedFS(documentIdType)
      .get()
      .getStringValue(docIdFeat);

  if (documentId == null) {
    documentId = UUID.randomUUID().toString();
  }

  GridFSInputFile file = gridFS.createFile(documentId + ".xmi");

  try (OutputStream outputStream = file.getOutputStream()) {
    XmiCasSerializer.serialize(aCAS, outputStream);
  } catch (IOException | SAXException e) {
    throw new AnalysisEngineProcessException(e);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:24,代码来源:MongoDbXmiWriter.java

示例7: CASDocument

import org.apache.uima.cas.Type; //导入依赖的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);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:20,代码来源:CASDocument.java

示例8: process

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
  LOGGER.debug("Annotating rtf paragraphs.");
  CAS systemView = aCAS.getView(Views.SYSTEM_VIEW);

  Type newParagraphType = systemView.getTypeSystem()
      .getType("edu.umn.biomedicus.rtfuima.type.NewParagraph");

  Type paragraphType = systemView.getTypeSystem()
      .getType("edu.umn.biomedicus.type.ParagraphAnnotation");

  AnnotationIndex<AnnotationFS> newParagraphIndex = systemView
      .getAnnotationIndex(newParagraphType);
  int start = 0;

  for (AnnotationFS newParagraph : newParagraphIndex) {
    int end = newParagraph.getEnd();
    systemView.addFsToIndexes(
        systemView.createAnnotation(paragraphType, start, end));

    start = end;
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:24,代码来源:ParagraphAnnotator.java

示例9: getAnnotation

import org.apache.uima.cas.Type; //导入依赖的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;
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:26,代码来源:PropertyCasMapping.java

示例10: CasOutputDestination

import org.apache.uima.cas.Type; //导入依赖的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");
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:25,代码来源:CasOutputDestination.java

示例11: controlWordEncountered

import org.apache.uima.cas.Type; //导入依赖的package包/类
@Override
public void controlWordEncountered(KeywordAction keywordAction) {
  AnnotationFS annotation;
  int currentTextIndex = sofaBuilder.length();
  String controlWord = keywordAction.getControlWord();

  Type type;
  if (annotationTypeForControlWord.containsKey(controlWord)) {
    type = annotationTypeForControlWord.get(controlWord);
  } else {
    return;
  }
  annotation = destinationView.createAnnotation(type, currentTextIndex,
      currentTextIndex);
  Feature paramFeature = type.getFeatureByBaseName("param");
  if (keywordAction.hasParameter()) {
    annotation.setIntValue(paramFeature, keywordAction.getParameter());
  }
  Feature indexFeature = type.getFeatureByBaseName("index");
  annotation.setIntValue(indexFeature, keywordAction.getBegin());
  Feature knownFeature = type.getFeatureByBaseName("known");
  annotation.setBooleanValue(knownFeature, true);

  destinationView.addFsToIndexes(annotation);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:26,代码来源:CasOutputDestination.java

示例12: 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

示例13: getType

import org.apache.uima.cas.Type; //导入依赖的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;

}
 
开发者ID:argo-nactem,项目名称:nactem-type-mapper,代码行数:23,代码来源:UimaUtils.java

示例14: getChainForLink

import org.apache.uima.cas.Type; //导入依赖的package包/类
/**
 * Find the chain head for the given link.
 *
 * @param aJCas the CAS.
 * @param aLink the link to search the chain for.
 * @return the chain.
 */
private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink)
{
    Type chainType = getAnnotationType(aJCas.getCas());

    for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) {
        AnnotationFS linkFs = getFirstLink(chainFs);

        // Now we seek the link within the current chain
        while (linkFs != null) {
            if (WebAnnoCasUtil.isSame(linkFs, aLink)) {
                return chainFs;
            }
            linkFs = getNextLink(linkFs);
        }
    }

    // This should never happen unless the data in the CAS has been created erratically
    throw new IllegalArgumentException("Link not part of any chain");
}
 
开发者ID:webanno,项目名称:webanno,代码行数:27,代码来源:ChainAdapter.java

示例15: typeSystemInit

import org.apache.uima.cas.Type; //导入依赖的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);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:19,代码来源:IobWriter.java


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