uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject Re: How to test a CollectionReader
Date Thu, 30 Aug 2007 02:13:45 GMT
Hi Roberto -

This might be caused by the Collection Reader Descriptor's type system
missing the particular type
"it.celi.types.SourceDocumentInformation";  can you verify it is defined
(and spelled correctly, etc.) as part of this particular Collection
Reader Descriptor?

If this type was defined in another descriptor that is deployed with
this collection reader, it would work when the whole CPE was run,
because all the types from the various descriptors that make up the CPE
pipeline are merged.

-Marshall

Roberto Franchini wrote:
> Hi,
> I'm trying to test a CollectionReader, but it seems that the
> TypeSystem isn't initialized since I get this:
>
> org.apache.uima.cas.CASRuntimeException: JCas type
> "it.celi.types.SourceDocumentInformation" used in Java code,  but was
> not declared in the XML type descriptor.
> 	at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:397)
> 	at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:92)
> 	at org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:53)
> 	at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:54)
> 	at it.celi.types.Annotation.<init>(Annotation.java:41)
> 	at it.celi.types.SourceDocumentInformation.<init>(SourceDocumentInformation.java:41)
> 	at it.celi.components.collection.RecursiveFileSytemCollectionReader.getCurrent(RecursiveFileSytemCollectionReader.java:192)
> 	at it.celi.components.collection.RecursiveFileSytemCollectionReader.getNext(RecursiveFileSytemCollectionReader.java:158)
> 	at it.celi.components.retriever.TestRecursiveFileSytemCollectionReader.testGetNext(TestRecursiveFileSytemCollectionReader.java:70)
>
> ..........
>
>
> Thes test is something like that:
> ....
> 	private RecursiveFileSytemCollectionReader rfcr;
>
> 	@Before
> 	public void setUp() throws Exception {
> 		
> 		File file;
>
> 		file = FileUtil.getFileAsResource("RecursiveFileSystemCollectionReader.xml");
> 		
> 		ResourceSpecifier aSpecifier =
> UIMAFramework.getXMLParser().parseCollectionReaderDescription(new
> XMLInputSource(file));
>
> 		rfcr = (RecursiveFileSytemCollectionReader)
> UIMAFramework.produceCollectionReader(aSpecifier);
>
> 	}
>
> 	@Test
> 	public void getNext() {
> 		try {
>
> 			CasManager casManager = rfcr.getCasManager();
> 			casManager.defineCasPool("pool", 2, null);
> 			
>
> 			while (rfcr.hasNext()) {
>
> 				CAS cas = casManager.getCas("pool");
> 		
> 				rfcr.getNext(cas);
>
> 				Type fileLocType =
> cas.getTypeSystem().getType(SourceDocumentInformation.class.getName());
> 				Feature fileNameFeat = fileLocType.getFeatureByBaseName("uri");
> 				FSIterator it = cas.getAnnotationIndex(fileLocType).iterator();
> 				FeatureStructure fileLoc = it.get();
> .......... a lot of catch
>
> In the collection reader's xml descriptor  are declared the typesystem
> and the output capabilities. And, if deployed in a CPE this CR works!
>
> Thanks in advance,
> Roberto
>
>   


Mime
View raw message