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


Java AnnotationIndex.subiterator方法代码示例

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


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

示例1: testChunkUnambiguousStrictSubiterator

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
private void testChunkUnambiguousStrictSubiterator(JCas testJcas,
		AnnotationIndex<Annotation> annotationIndex) {
	System.out.println("Debug: ---------------------------------------------------------------");

	System.out.println("Debug: unambiguous and strict subiterating all the chunk annotations");
	AnnotationIndex<Annotation> chunkAnnotationIndex = (AnnotationIndex<Annotation>) testJcas.getAnnotationIndex(Chunk.type);
	for (Annotation aChunk : chunkAnnotationIndex) {
		FSIterator<Annotation> chunkSubIterator = annotationIndex.subiterator(aChunk,false,true);
		System.out.println("annotation to subiterate type>"+aChunk.getClass().getName()+"< coveredText>"+aChunk.getCoveredText()+"<");

		while(chunkSubIterator.isValid()) {
			Annotation subAnnotation = chunkSubIterator.get();

			System.out.println("moveToNext subAnnotation type>"+subAnnotation.getClass().getName()+"< coveredText>"+subAnnotation.getCoveredText()+"<");
			chunkSubIterator.moveToNext();
		}
	}
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:19,代码来源:TestLocatedAnnotationAE.java

示例2: removeSubsumedAnnotation

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * Remove some subsumed annotations from a given type of subsuming annotation 
 * Somehow based on 
 * http://permalink.gmane.org/gmane.comp.apache.uima.general/3501
 * http://www.mail-archive.com/[email protected]/msg01645.html
 * http://uima.apache.org/downloads/releaseDocs/2.3.0-incubating/docs/api/org/apache/uima/jcas/JCas.html#removeFsFromIndexes(org.apache.uima.cas.FeatureStructure)
 * @param aJCas 
 * @param subsumingAnnotation
 * @param subsumedAnnotation
 * @param strictOffset

 */
public static void removeSubsumedAnnotation(JCas aJCas, String subsumingAnnotation, String subsumedAnnotation, boolean strictOffset) {
	List<Annotation> annotationToRemoveList = new ArrayList<Annotation>();

	Type subsumingAnnotationType = aJCas.getTypeSystem().getType(subsumingAnnotation);
	AnnotationIndex<Annotation> subsumingAnnotationIndex = aJCas.getAnnotationIndex(subsumingAnnotationType);

	Type subsumedAnnotationType = aJCas.getTypeSystem().getType(subsumedAnnotation);
	AnnotationIndex<Annotation> subsumedAnnotationIndex = aJCas.getAnnotationIndex(subsumedAnnotationType);

	FSIterator<Annotation> subsumingAnnotationIterator = subsumingAnnotationIndex.iterator();

	while (subsumingAnnotationIterator.hasNext()) {
		Annotation aSubsumingAnnotation = subsumingAnnotationIterator.next();
		FSIterator<Annotation> subsumedAnnotationIterator = subsumedAnnotationIndex.subiterator(aSubsumingAnnotation);
		while (subsumedAnnotationIterator.hasNext()) {
			Annotation aSubsumedAnnotation = subsumedAnnotationIterator.next();
			if (strictOffset) { 
				if ((aSubsumingAnnotation.getBegin() == aSubsumedAnnotation.getBegin()) && (aSubsumingAnnotation.getEnd() == aSubsumedAnnotation.getEnd()) ) {
					annotationToRemoveList.add(aSubsumedAnnotation);
				} } 
			else annotationToRemoveList.add(aSubsumedAnnotation);
		}
	}


	for (Annotation remove : annotationToRemoveList) {
		remove.removeFromIndexes();
	}
}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:42,代码来源:AnnotationCollectionUtils.java

示例3: removeSubsumedAnnotation

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * Remove some subsumed annotations from a given type of subsuming annotation 
 * Somehow based on 
 * http://permalink.gmane.org/gmane.comp.apache.uima.general/3501
 * http://www.mail-archive.com/[email protected]/msg01645.html
 * http://uima.apache.org/downloads/releaseDocs/2.3.0-incubating/docs/api/org/apache/uima/jcas/JCas.html#removeFsFromIndexes(org.apache.uima.cas.FeatureStructure)
 * @param aJCas 
 * @param subsumingAnnotation
 * @param subsumedAnnotation
 * @param strictOffset

 */
public static void removeSubsumedAnnotation(JCas aJCas, String subsumingAnnotation, String subsumedAnnotation, boolean strictOffset)
{
	/*  93 */     List<Annotation> annotationToRemoveList = new ArrayList();

	/*  95 */     Type subsumingAnnotationType = aJCas.getTypeSystem().getType(subsumingAnnotation);
	/*  96 */     AnnotationIndex<Annotation> subsumingAnnotationIndex = aJCas.getAnnotationIndex(subsumingAnnotationType);

	/*  98 */     Type subsumedAnnotationType = aJCas.getTypeSystem().getType(subsumedAnnotation);
	/*  99 */     AnnotationIndex<Annotation> subsumedAnnotationIndex = aJCas.getAnnotationIndex(subsumedAnnotationType);

	/* 101 */     FSIterator<Annotation> subsumingAnnotationIterator = subsumingAnnotationIndex.iterator();
	FSIterator<Annotation> subsumedAnnotationIterator;
	/* 103 */     while (subsumingAnnotationIterator.hasNext())  {

		/* 104 */       Annotation aSubsumingAnnotation = (Annotation)subsumingAnnotationIterator.next();
		/* 105 */       subsumedAnnotationIterator = subsumedAnnotationIndex.subiterator(aSubsumingAnnotation);
		/* 106 */       while (subsumedAnnotationIterator.hasNext()) {
			/* 107 */    	   Annotation aSubsumedAnnotation = (Annotation)subsumedAnnotationIterator.next();
			/* 108 */     		  if (strictOffset) {
				/* 109 */        		 if ((aSubsumingAnnotation.getBegin() == aSubsumedAnnotation.getBegin()) && (aSubsumingAnnotation.getEnd() == aSubsumedAnnotation.getEnd()))
					/* 110 */           annotationToRemoveList.add(aSubsumedAnnotation);
			} else {
				/* 112 */         annotationToRemoveList.add(aSubsumedAnnotation);
			}
		}
	}

	/* 117 */     for (Annotation remove : annotationToRemoveList) {
		/* 118 */       remove.removeFromIndexes();
	}
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:44,代码来源:AnnotationCollectionUtils.java

示例4: process

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
private void process(JCas cas, AnnotationIndex<Annotation> pmIndex, Annotation span) {
     // TODO what about type priorities?
     FSIterator<Annotation> pmIter = pmIndex.subiterator(span);
     // qm = 'quotation mark'
     List<Annotation> qmList = Lists.newLinkedList();
     while (pmIter.hasNext()) {
         Annotation pm = pmIter.next();
         // TODO handle other quotation marks! See TODO in the class header
         if ("\"".equals(pm.getCoveredText())) {
             qmList.add(pm);
         }
     }
     if (qmList.isEmpty()) {
         return;
     }
     if (qmList.size() == 1) {
         info("Following span contains independent quotation mark:\n%s",
                 span.getCoveredText());
         return;
     }
     if (qmList.size() == 2) {
         createQSegment(cas, qmList.get(0), qmList.get(1), null);
     } else if (qmList.size() == 3) {
         QSegment parentSeg = createQSegment(cas, qmList.get(0), qmList.get(2), null);
         createQSegment(cas, qmList.get(1), qmList.get(2), parentSeg);
     } else {
         // more than 3 quotation marks
         // TODO
         /*
LinkedList<Annotation> qmStack = Lists.newLinkedList();
// first is always opening one
Iterator<Annotation> qmIter = qmList.iterator();
qmStack.add(qmIter.next());
while (qmIter.hasNext()) {
	Annotation qm = qmIter.next();
	boolean wsAfter = isWhitespaceAfter(cas, qm);
	boolean wsBefore = isWhitespaceBefore(cas, qm);
	if (wsAfter == wsBefore) {
		info("Can't define qSegments in:\n%s", span.getCoveredText());
		break;
	}
	if(!wsBefore){
		// close segment
		Annotation openingQM = qmStack.pollLast();
		if(openingQM)
		createQSegment(cas, openingQM, qm, null);
	}
}
*/
     }
 }
 
开发者ID:textocat,项目名称:textokit-core,代码行数:52,代码来源:QuotationAnnotator.java

示例5: testChunkSubiterator

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
	 * @param testJcas
	 * @param annotationIndex
	 * 
	 * Debug: ---------------------------------------------------------------
Debug: subiterating all the chunk annotations
annotation to subiterate type>common.types.text.Chunk< coveredText>Verne<
moveToNext subAnnotation type>org.apache.uima.examples.SourceDocumentInformation< coveredText><
annotation to subiterate type>common.types.text.Chunk< coveredText>visited<
annotation to subiterate type>common.types.text.Chunk< coveredText>the seaport of Nantes<
moveToNext subAnnotation type>common.types.text.Chunk< coveredText>the seaport<
moveToNext subAnnotation type>common.types.text.Token< coveredText>the<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>the<
moveToNext subAnnotation type>common.types.text.Token< coveredText>seaport<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>seaport<
moveToNext subAnnotation type>common.types.text.Chunk< coveredText>of Nantes<
moveToNext subAnnotation type>common.types.text.Token< coveredText>of<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>of<
moveToNext subAnnotation type>common.types.text.Token< coveredText>Nantes<
moveToNext subAnnotation type>common.types.ne.NamedEntity< coveredText>Nantes<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>Nantes<
annotation to subiterate type>common.types.text.Chunk< coveredText>the seaport<
moveToNext subAnnotation type>common.types.text.Token< coveredText>the<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>the<
moveToNext subAnnotation type>common.types.text.Token< coveredText>seaport<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>seaport<
annotation to subiterate type>common.types.text.Chunk< coveredText>of Nantes<
moveToNext subAnnotation type>common.types.text.Token< coveredText>of<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>of<
moveToNext subAnnotation type>common.types.text.Token< coveredText>Nantes<
moveToNext subAnnotation type>common.types.ne.NamedEntity< coveredText>Nantes<
moveToNext subAnnotation type>common.types.coref.Coreference< coveredText>Nantes<
	 */
	private void testChunkSubiterator(JCas testJcas,
			AnnotationIndex<Annotation> annotationIndex) {
		System.out.println("Debug: ---------------------------------------------------------------");

		System.out.println("Debug: ambiguous subiterating all the chunk annotations");
		AnnotationIndex<Annotation> chunkAnnotationIndex = (AnnotationIndex<Annotation>) testJcas.getAnnotationIndex(Chunk.type);
		for (Annotation aChunk : chunkAnnotationIndex) {
			FSIterator<Annotation> chunkSubIterator = annotationIndex.subiterator(aChunk);
			System.out.println("annotation to subiterate type>"+aChunk.getClass().getName()+"< coveredText>"+aChunk.getCoveredText()+"<");

			while(chunkSubIterator.isValid()) {
				Annotation subAnnotation = chunkSubIterator.get();

				System.out.println("moveToNext subAnnotation type>"+subAnnotation.getClass().getName()+"< coveredText>"+subAnnotation.getCoveredText()+"<");
				chunkSubIterator.moveToNext();
			}
		}
	}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:52,代码来源:TestLocatedAnnotationAE.java

示例6: testNonAmbiguousSubiterator

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
	 * @param annotationIndex
	 * @param firstSentence
	 */
	private void testNonAmbiguousSubiterator(
			AnnotationIndex<Annotation> annotationIndex,
			Annotation firstSentence) {
		FSIterator<Annotation> annotationIndexIterator;
		Annotation annotation;
		System.out.println("Debug: ---------------------------------------------------------------");
		System.out.println("Debug: non-ambiguous subiterator over an annotation index");
		/**
		 * Debug: non-ambiguous subiterator over an annotation index
move to first sentence annotation coveredText>Jean pousse la voiture.< type>common.types.text.Sentence< 
moveToNext ambiguous annotationIndexSubiterator coveredText>Jean< type>common.types.text.Chunk<
moveToNext ambiguous annotationIndexSubiterator coveredText>Jean< type>common.types.text.LexicalUnit<
moveToNext ambiguous annotationIndexSubiterator coveredText>< type>org.apache.uima.examples.SourceDocumentInformation<
moveToNext ambiguous annotationIndexSubiterator coveredText>pousse< type>common.types.text.Chunk<
moveToNext ambiguous annotationIndexSubiterator coveredText>pousse< type>common.types.text.LexicalUnit<
moveToNext ambiguous annotationIndexSubiterator coveredText>la voiture< type>common.types.text.Chunk<
moveToNext ambiguous annotationIndexSubiterator coveredText>la< type>common.types.text.LexicalUnit<
moveToNext ambiguous annotationIndexSubiterator coveredText>voiture< type>common.types.text.LexicalUnit<
moveToNext ambiguous annotationIndexSubiterator coveredText>.< type>common.types.text.LexicalUnit<
move to first sentence annotation coveredText>Jean pousse la voiture.< type>common.types.text.Sentence< 
moveToNext non ambiguous annotationIndexSubiterator coveredText>Jean< type>common.types.text.Chunk<
moveToNext non ambiguous annotationIndexSubiterator coveredText>pousse< type>common.types.text.Chunk<
moveToNext non ambiguous annotationIndexSubiterator coveredText>la voiture< type>common.types.text.Chunk<
moveToNext non ambiguous annotationIndexSubiterator coveredText>.< type>common.types.text.LexicalUnit<
		 */
		annotationIndexIterator = annotationIndex.iterator();

		annotationIndexIterator.moveTo(firstSentence);
		annotation = annotationIndexIterator.get();
		System.out.println("move to first sentence annotation coveredText>"+annotation.getCoveredText()+"< type>"+annotation.getClass().getName()+"< ");

		FSIterator<Annotation> annotationIndexSubiterator = annotationIndex.subiterator(annotation);
		while(annotationIndexSubiterator.isValid()) {
			annotation = annotationIndexSubiterator.get();
			System.out.println("moveToNext ambiguous annotationIndexSubiterator coveredText>"+annotation.getCoveredText()+"< type>"+annotation.getClass().getName()+"<");
			annotationIndexSubiterator.moveToNext();
		}


		annotationIndexIterator.moveTo(firstSentence);
		annotation = annotationIndexIterator.get();
		System.out.println("move to first sentence annotation coveredText>"+annotation.getCoveredText()+"< type>"+annotation.getClass().getName()+"< ");
		annotationIndexSubiterator = annotationIndex.subiterator(annotation,false,true);
		while(annotationIndexSubiterator.isValid()) {
			annotation = annotationIndexSubiterator.get();
			System.out.println("moveToNext non ambiguous annotationIndexSubiterator coveredText>"+annotation.getCoveredText()+"< type>"+annotation.getClass().getName()+"<");
			annotationIndexSubiterator.moveToNext();
		}
	}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:54,代码来源:TestLocatedAnnotationAE.java

示例7: coveredIteratorAdapter

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * Creates an {@link java.util.Iterator} which is bound by an UIMA {@link
 * org.apache.uima.jcas.tcas.Annotation}. Uses the {@link AnnotationIndex#subiterator(AnnotationFS)}
 * functionality within UIMA.
 *
 * @param index the index of annotations to filter
 * @param bound the annotation to use as filter bounds
 * @param mapper the function to map annotations to biomedicus models
 * @param <T> the biomedicus model we are creating an iterator of
 * @return an iterator of biomedicus model classes within the UIMA annotation
 */
public static <T> Iterator<T> coveredIteratorAdapter(AnnotationIndex<AnnotationFS> index,
    AnnotationFS bound,
    Function<AnnotationFS, T> mapper) {
  FSIterator<AnnotationFS> subiterator = index.subiterator(bound);
  return new FSIteratorAdapter<>(subiterator, mapper);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:18,代码来源:FSIteratorAdapter.java

示例8: subiterator

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * A simple Subiterator call
 * Depending on the index size, can be much much much faster than with the constraint approach !
 * 
 * Here an example to simulate a constraint (as a post processing)
 * The current Annotation is compared with another (the filter) 
 * FSIterator wordsAnnotationIterator = AnnotationCollectionUtils.subiterator(
			inputViewJCas, aSentenceAnnotation);

		while (wordsAnnotationIterator.hasNext()) {
			Annotation aWordAnnotation = (Annotation) wordsAnnotationIterator
			.next();
			//System.out.println("Debug: aWordAnnotation.getClass().getName() "+aWordAnnotation.getClass().getName()+" wordTypeName"+ wordTypeName);
			if (aWordAnnotation.getClass().getName().equalsIgnoreCase(wordTypeName))  
				if (! aWordAnnotation.getCoveredText().trim().equalsIgnoreCase("")) { 
					//doTheRequiredProcessing;
				}
		}
 * 
 * 
 * Some discussions about it 
 * http://www.uima-fr.org/planet//index.php?post_id=4
 * http://jerome.rocheteau.free.fr/index/post/2011/03/10/Comment-r%C3%A9cup%C3%A9rer-les-annotations-entre-deux-annotations-donn%C3%A9es
 *
 * @param jcas
 * @param annotation
 * @return an index of annotations subsumed by the annotation given in parameter
 */
public static FSIterator<Annotation> subiterator(JCas aJCas, Annotation beginEndAnnotation)
{
	/* 347 */     AnnotationIndex<Annotation> index = aJCas.getAnnotationIndex();
	/* 348 */     Annotation between = new Annotation(aJCas, beginEndAnnotation.getBegin(), beginEndAnnotation.getEnd());
	/* 349 */     return index.subiterator(between);
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:35,代码来源:AnnotationCollectionUtils.java

示例9: subiterator

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * A simple Subiterator call
 * Depending on the index size, can be much much much faster than with the constraint approach !
 * 
 * Here an example to simulate a constraint (as a post processing)
 * The current Annotation is compared with another (the filter) 
 * FSIterator wordsAnnotationIterator = AnnotationCollectionUtils.subiterator(
			inputViewJCas, aSentenceAnnotation);

		while (wordsAnnotationIterator.hasNext()) {
			Annotation aWordAnnotation = (Annotation) wordsAnnotationIterator
			.next();
			//System.out.println("Debug: aWordAnnotation.getClass().getName() "+aWordAnnotation.getClass().getName()+" wordTypeName"+ wordTypeName);
			if (aWordAnnotation.getClass().getName().equalsIgnoreCase(wordTypeName))  
				if (! aWordAnnotation.getCoveredText().trim().equalsIgnoreCase("")) { 
					//doTheRequiredProcessing;
				}
		}
 * 
 * 
 * Some discussions about it 
 * http://www.uima-fr.org/planet//index.php?post_id=4
 * http://jerome.rocheteau.free.fr/index/post/2011/03/10/Comment-r%C3%A9cup%C3%A9rer-les-annotations-entre-deux-annotations-donn%C3%A9es
 *
 * @param jcas
 * @param annotation
 * @return an index of annotations subsumed by the annotation given in parameter
 */
public static FSIterator<Annotation> subiterator(JCas cas, Annotation beginEndAnnotation) {
	AnnotationIndex<Annotation> index = cas.getAnnotationIndex();
	Annotation between = new Annotation(cas, beginEndAnnotation.getBegin(),beginEndAnnotation.getEnd());
	return index.subiterator(between);
}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:34,代码来源:AnnotationCollectionUtils.java


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