You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Peter Litsegård <pe...@foi.se> on 2014/02/10 13:54:10 UTC

Unable to use ConceptMapper annotator

Hi!

I'm trying to get the ConceptMapper annotator to work but so far I've been
unable to get it up and running.

Part of the code in my service looks like the following:

XMLInputSource in = new XMLInputSource(".../ConceptMapperOffsetTokenizer.xml");
ResourceSpecifier specifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

The code fails on the "produceAnalysisEngine(specifier)" part with the
following error:

An import could not be resolved.  No file with name
"org/apache/uima/conceptMapper/DictTerm.xml" was found in the class path or
data path.

I find this very strange as the uima-an-conceptMapper.jar contains the
org.apache.uima.conceptMapper.DictTerm class and that jar is referenced in
my project!

I'm using v2.5.0 of UIMA.

What am I doing wrong here?

Many thanks in advance!!!!


Re: Unable to use ConceptMapper annotator

Posted by Peter Litsegård <pe...@foi.se>.
Richard Eckart de Castilho <re...@...> writes:

> 
> On 12.02.2014, at 11:22, Peter Litsegård <pe...@...> wrote:
> 
> > Why would the
> > ConceptMapper want to use these as the types declared on those xmls have
> > already been "Cas generated" and their .class files are present in the
CM-jar?
> 
> The generated JCas classes are just a way of mapping the UIMA type system
to the
> Java type system. They offer a convenience for programming using the known
> class/getter/setter concepts in Java.
> 
> These classes are not a substitute for the XML-based type system definitions.
> The type system definitions are always required in addition to the JCas
classes.
> 
> When you use only the JCas classes, but did not initialize the CAS with
the proper
> types, you'll get such an error message:
> 
> "JCas type used in Java code, but was not declared in the XML type descriptor"
> 
> Cheers,
> 

Hi!

I've had some progress on this - no exceptions that is:) I don't get any
hits however when I use the ConceptMapper. I've set PrintDictionary = true
which shows that it successfully loads 49 dictentries and no exceptions
while executing the code below. I use the following code:

XMLInputSource in = new XMLInputSource(".../ConceptMapperOffsetTokenizer.xml");
ResourceSpecifier specifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);

JCas jcas = ae.newJCas();
jcas.setDocumentText("...some text containing a number of dictentries");
ae.process(jcas);

Now, how do I loop through the hits in the jcas-instance (the dictionary 
entry together with begin/end positions, SemClass which is part of the 
dictionary entry attributes etc.)?

I'm very sorry for posting these trivial questions but...


Re: Unable to use ConceptMapper annotator

Posted by Richard Eckart de Castilho <re...@apache.org>.
On 12.02.2014, at 11:22, Peter Litsegård <pe...@foi.se> wrote:

> Why would the
> ConceptMapper want to use these as the types declared on those xmls have
> already been "Cas generated" and their .class files are present in the CM-jar?

The generated JCas classes are just a way of mapping the UIMA type system to the
Java type system. They offer a convenience for programming using the known
class/getter/setter concepts in Java.

These classes are not a substitute for the XML-based type system definitions.
The type system definitions are always required in addition to the JCas classes.

When you use only the JCas classes, but did not initialize the CAS with the proper
types, you'll get such an error message:

"JCas type used in Java code, but was not declared in the XML type descriptor"

Cheers,

-- Richard

Re: Unable to use ConceptMapper annotator

Posted by Peter Litsegård <pe...@foi.se>.
Marshall Schor <ms...@...> writes:

> 
> Hi Peter,
> 
> Thanks for pointing this out.  I checked, and did see it there (in
> analysis_engine/primitive/DictTerm.xml)
> 
> So, to make this work, you have to change the spot where this is referenced,
> from trying to reference:
> 
>   "org/apache/uima/conceptMapper/DictTerm.xml" (won't be found in the jar at
> that spot) to
>   "analysis_engine/primitive/DictTerm.xml"  (where it is in the Jar)
> 
> if you want to reference that embedded copy. 
> 
> I'm not sure that's the proper way to do this, though... 
> I hope the documentation (
>
http://uima.apache.org/d/uima-addons-current/ConceptMapper/ConceptMapperAnnotatorUserGuide.html
> ) for this can be of help.
> 
> -Marshall
> 
> On 2/11/2014 1:52 AM, Peter Litsegård wrote:
> > Hi Marshall!
> >
> > Hmmm, the DictTerm.xml file is present and I've tried to put it in a number
> > of places with no avail. I thought that the error might be a typo in the
> > exception handling of a class-loader exception. I know very farfecthed...:)
> >
> > Nevertheless DictTerm.xml exists in the "uima-an-conceptMapper.jar" file
> > under "analysis_engine.primitive" folder. Do you know what I need to do in
> > order for the DictTerm.xml file to be found?
> >
> >
> 
> 

Hi Marshall!

Thanks for trying to help me out here. The more I look into this the
trickier it gets...:(

Just to give you some additional background I've done the following:

1. downloaded the uima-core
2. downloaded the ConceptMapper.jar
3. referenced both of the above from my project

In my code I do the following:
			XMLInputSource in = new
XMLInputSource("bin/descriptors/analysis_engine/
ConceptMapperOffsetTokenizer.xml");
			ResourceSpecifier specifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(in);
			AnalysisEngine ae = UIMAFramework.
produceAnalysisEngine(specifier);

When I try to invoke the 'produceAnalysisEngine(...)' 
method above I get the following error:

"...Caused by: org.apache.uima.util.InvalidXMLException: 
An import could not be resolved.  No file with name 
"org/apache/uima/conceptMapper/DictTerm.xml"
was found in the class path or data path. (Descriptor:
file:/C:/.../ConceptMapperOffsetTokenizer.xml)
	at
org.apache.uima.resource.metadata.impl.Import_impl.findAbsoluteUrl
(Import_impl.java:115)
	at
org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl
.resolveImports(TypeSystemDescription_impl.java:220)
	at
org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl
.resolveImports(TypeSystemDescription_impl.java:202)
	at
org.apache.uima.analysis_engine.metadata.impl.
AnalysisEngineMetaData_impl.
resolveImports(AnalysisEngineMetaData_impl.java:87)
	at
org.apache.uima.resource.Resource_ImplBase.
initialize(Resource_ImplBase.java:129)"

I simply can't understand why I get these errors as I'm relying on the
defaults for the ConceptMapper and all the type systems are in place in the
jars. I'm far from an expert on UIMA BUT I would have thought this should be
pretty forward but no:( I thought the DictTerm.xml and TokenAnnotation.xml
etc were "simple" type system declarations and nothing else. Why would the
ConceptMapper want to use these as the types declared on those xmls have
already been "Cas generated" and their .class files are present in the CM-jar?

Sorry for the lengthy post but I want to be clear:)




Re: Unable to use ConceptMapper annotator

Posted by Marshall Schor <ms...@schor.com>.
Hi Peter,

Thanks for pointing this out.  I checked, and did see it there (in
analysis_engine/primitive/DictTerm.xml)

So, to make this work, you have to change the spot where this is referenced,
from trying to reference:

  "org/apache/uima/conceptMapper/DictTerm.xml" (won't be found in the jar at
that spot) to
  "analysis_engine/primitive/DictTerm.xml"  (where it is in the Jar)

if you want to reference that embedded copy. 

I'm not sure that's the proper way to do this, though... 
I hope the documentation (
http://uima.apache.org/d/uima-addons-current/ConceptMapper/ConceptMapperAnnotatorUserGuide.html
) for this can be of help.

-Marshall

On 2/11/2014 1:52 AM, Peter Litsegård wrote:
> Hi Marshall!
>
> Hmmm, the DictTerm.xml file is present and I've tried to put it in a number
> of places with no avail. I thought that the error might be a typo in the
> exception handling of a class-loader exception. I know very farfecthed...:)
>
> Nevertheless DictTerm.xml exists in the "uima-an-conceptMapper.jar" file
> under "analysis_engine.primitive" folder. Do you know what I need to do in
> order for the DictTerm.xml file to be found?
>
>


Re: Unable to use ConceptMapper annotator

Posted by Luca Foppiano <lu...@foppiano.org>.
On Tue, Feb 11, 2014 at 7:52 AM, Peter Litsegård <pe...@foi.se>wrote:

> Hi Marshall!
>
> Hmmm, the DictTerm.xml file is present and I've tried to put it in a number
> of places with no avail. I thought that the error might be a typo in the
> exception handling of a class-loader exception. I know very farfecthed...:)
>
> Nevertheless DictTerm.xml exists in the "uima-an-conceptMapper.jar" file
> under "analysis_engine.primitive" folder. Do you know what I need to do in
> order for the DictTerm.xml file to be found?
>

Hi Peter,
    can you try to reference it with something like: "*file:*
org/apache/uima/conceptMapper/DictTerm.xml"

I remember I had some problems to make it works. You can have a look at the
code of my sample project here:
https://github.com/lfoppiano/uima-fit-sample-pipeline

Cheers
-- 
Luca Foppiano

Software Engineer
+31615253280
luca@foppiano.org
www.foppiano.org

Re: Unable to use ConceptMapper annotator

Posted by Peter Litsegård <pe...@foi.se>.
Hi Marshall!

Hmmm, the DictTerm.xml file is present and I've tried to put it in a number
of places with no avail. I thought that the error might be a typo in the
exception handling of a class-loader exception. I know very farfecthed...:)

Nevertheless DictTerm.xml exists in the "uima-an-conceptMapper.jar" file
under "analysis_engine.primitive" folder. Do you know what I need to do in
order for the DictTerm.xml file to be found?


Re: Unable to use ConceptMapper annotator

Posted by Marshall Schor <ms...@schor.com>.
I'm not an expert for this, but in looking at what you posted, I noticed that
the error is saying it can't find a file (... DictTerm.xml), whereas you say the
Jar contains the "class" - which it does, but it doesn't have that file.

-Marshall

The file in question, .../DictTerm.xml is
On 2/10/2014 7:54 AM, Peter Litsegård wrote:
> Hi!
>
> I'm trying to get the ConceptMapper annotator to work but so far I've been
> unable to get it up and running.
>
> Part of the code in my service looks like the following:
>
> XMLInputSource in = new XMLInputSource(".../ConceptMapperOffsetTokenizer.xml");
> ResourceSpecifier specifier =
> UIMAFramework.getXMLParser().parseResourceSpecifier(in);
> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
>
> The code fails on the "produceAnalysisEngine(specifier)" part with the
> following error:
>
> An import could not be resolved.  No file with name
> "org/apache/uima/conceptMapper/DictTerm.xml" was found in the class path or
> data path.
>
> I find this very strange as the uima-an-conceptMapper.jar contains the
> org.apache.uima.conceptMapper.DictTerm class and that jar is referenced in
> my project!
>
> I'm using v2.5.0 of UIMA.
>
> What am I doing wrong here?
>
> Many thanks in advance!!!!
>
>