本文整理汇总了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);
}
示例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);
}
}
}
示例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());
}
}
示例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;
}
示例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() + "\"");
}
}
示例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();
}
示例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);
}