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


Java FSIndex.iterator方法代码示例

本文整理汇总了Java中org.apache.uima.cas.FSIndex.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java FSIndex.iterator方法的具体用法?Java FSIndex.iterator怎么用?Java FSIndex.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.cas.FSIndex的用法示例。


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

示例1: process

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
public void process(JCas aJCas) {
double[] outcomes = categorizer.categorize(aJCas.getDocumentText());
String category = categorizer.getBestCategory(outcomes);

FSIndex docAnnIndex = aJCas.getAnnotationIndex(DocumentAnnotation.type);
Iterator docAnnIter = docAnnIndex.iterator();
DocumentAnnotation docAnn = null;
if(docAnnIter.hasNext()){
    docAnn = (DocumentAnnotation) docAnnIter.next();
}else{
    docAnn = new DocumentAnnotation(aJCas);
    docAnn.setBegin(0);
    docAnn.setEnd(aJCas.getDocumentText().length());
    docAnn.addToIndexes();
}

docAnn.setProcess(category.equals("contract"));
docAnn.setClassified(true);
   }
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:20,代码来源:ContractClassifier.java

示例2: process

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
public void process(JCas jCas, ResultSpecification rs)
             throws AnnotatorProcessException {
  JFSIndexRepository indexRep = jCas.getJFSIndexRepository();
  FSIndex tokenIndex = indexRep.getAnnotationIndex(Token.type);
  Iterator tokens = tokenIndex.iterator();
  while(tokens.hasNext()) {
    Token tok = (Token)tokens.next();
    String tokenString = tok.getString();
    if(tokenString != null) {
      int tokenLength = tokenString.length();
      int numLowerCase = 0;
      for(int i = 0; i < tokenLength; i++) {
        if(Character.isLowerCase(tokenString.charAt(i))) {
          numLowerCase++;
        }
      }
      tok.setLowerCaseLetters(numLowerCase);
    }
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:21,代码来源:CountLowercaseAnnotator.java

示例3: process

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
public void process(JCas jCas, ResultSpecification rs)
             throws AnnotatorProcessException {
  JFSIndexRepository indexRep = jCas.getJFSIndexRepository();
  FSIndexRepository fsIndexRep = indexRep.getFSIndexRepository();
  List tokensToRemove = new ArrayList();
  FSIndex tokenIndex = indexRep.getAnnotationIndex(Token.type);
  Iterator tokens = tokenIndex.iterator();
  while(tokens.hasNext()) {
    Token tok = (Token)tokens.next();
    if(((tok.getEnd() - tok.getBegin()) % 2) == 0) {
      // mark token for removal if it has an even-length span
      tokensToRemove.add(tok);
    }
  }

  // now iterate over tokens marked for removal and remove them from the
  // index
  Iterator tokensToRemoveIt = tokensToRemove.iterator();
  while(tokensToRemoveIt.hasNext()) {
    fsIndexRep.removeFS((Token)tokensToRemoveIt.next());
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:23,代码来源:RemoveEvenLengthTokens.java

示例4: hasProcess

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
private boolean hasProcess(JCas aJCas) {
	FSIndex docAnnIndex = aJCas.getAnnotationIndex(DocumentAnnotation.type);
	Iterator docAnnIter = docAnnIndex.iterator();
	if (docAnnIter.hasNext())
		return ((DocumentAnnotation) docAnnIter.next()).getClassified();
	return false;
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:8,代码来源:ContractFlowController.java

示例5: process

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
public void process(JCas jCas, ResultSpecification rs)
             throws AnnotatorProcessException {
  JFSIndexRepository indexRep = jCas.getJFSIndexRepository();
  FSIndex tokenIndex = indexRep.getAnnotationIndex(Token.type);
  Iterator tokens = tokenIndex.iterator();
  while(tokens.hasNext()) {
    Token tok = (Token)tokens.next();
    System.out.print("Token: String=\"" + tok.getString() + "\", ");
    System.out.print("Kind=\"" + tok.getKind() + "\", ");
    System.out.println("Orth=\"" + tok.getOrth() + "\"");
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:13,代码来源:TokenPrinterAnnotator.java

示例6: shouldProcess

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
private boolean shouldProcess(JCas aJCas) {
	FSIndex docAnnIndex = aJCas.getAnnotationIndex(DocumentAnnotation.type);
	Iterator docAnnIter = docAnnIndex.iterator();
	return ((DocumentAnnotation) docAnnIter.next()).getProcess();
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:6,代码来源:ContractFlowController.java

示例7: testGatePOSTagger

import org.apache.uima.cas.FSIndex; //导入方法依赖的package包/类
public void testGatePOSTagger() throws Exception {
  // load the TAE containing UIMA tokeniser and GATE POS tagger
  File tokAndPOSTaggerDescriptorFile =
    new File(testConfDir, "TokenizerAndPOSTagger.xml");

  XMLInputSource inputSource =
    new XMLInputSource(tokAndPOSTaggerDescriptorFile);

  ResourceSpecifier tokAndPOSTaggerDescriptor =
    uimaXMLParser.parseResourceSpecifier(inputSource);

  AnalysisEngine tokAndPOSTagger =
    UIMAFramework.produceAnalysisEngine(tokAndPOSTaggerDescriptor);

  // create CAS and populate it with initial text.
  CAS cas = tokAndPOSTagger.newCAS();

  cas.setDocumentText(
      "This is a test document. This is the second sentence.");
  // what POS tags do we expect to get back?
  String[] expectedPOSTags = new String[] {
    "DT",    // This
    "VBZ",   // is
    "DT",    // a
    "NN",    // test
    "NN",    // document
    ".",     // .
    "DT",    // This
    "VBZ",   // is
    "DT",    // the
    "JJ",    // second
    "NN",    // sentence
    "."      // .
  };

  // run the beast
  tokAndPOSTagger.process(cas);

  // check the results have the right POS tags
  Type tokenType = cas.getTypeSystem().getType(
      "org.apache.uima.examples.tokenizer.Token");
  assertNotNull("Token type not found in type system", tokenType);

  Feature posFeature = tokenType.getFeatureByBaseName("POS");
  assertNotNull("Token POS feature not found", posFeature);
  
  FSIndex tokensIndex = cas.getAnnotationIndex(tokenType);
  FSIterator tokensIt = tokensIndex.iterator();
  int tokenNo = 0;
  while(tokensIt.isValid()) {
    // make sure we don't have too many tokens
    assertTrue("Found more tokens than expected",
               tokenNo < expectedPOSTags.length);
    FeatureStructure token = tokensIt.get();
    String actualPOS = token.getStringValue(posFeature);
    assertEquals("Token has wrong part of speech",
                 expectedPOSTags[tokenNo], actualPOS);
    tokensIt.moveToNext();
    tokenNo++;
  }

  assertEquals("Found fewer tokens than expected",
               tokenNo, expectedPOSTags.length);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:65,代码来源:TestGATEInUIMA.java


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