Re: [uimaFIT Users] External Resources help

27 views
Skip to first unread message

Torsten Zesch

unread,
Jul 2, 2013, 3:37:43 AM7/2/13
to uimafi...@googlegroups.com
Hi,

I have not worked with ctakes much, but generally parameters when creating an external resource should go in key/value pairs.

So I guess your code should look something like that:
ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(
"MaxentModelFile",
org.apache.ctakes.core.resource.SuffixMaxentModelResourceImpl.class,
NAME_OF_PARAMETER, "file:sdmed.mod"
);
AnalysisEngineDescription sentenceDetectorDesc = AnalysisEngineFactory.createPrimitiveDescription(
SentenceDetector.class,
"MaxentModel", erd
);
-Torsten


2013/7/2 <ravig...@gmail.com>
Hi, 

I am trying to define an external resource using the following lines of code

ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription("MaxentModelFile", org.apache.ctakes.core.resource.SuffixMaxentModelResourceImpl.class, "file:sdmed.mod");     
      	Map<String,ExternalResourceDescription> sentenceExternalMap = new HashMap<String, ExternalResourceDescription>();
        sentenceExternalMap.put("MaxentModel", erd);
        AnalysisEngineDescription sentenceDetectorDesc = AnalysisEngineFactory.createPrimitiveDescription(SentenceDetector.class, null, null, null, sentenceDetectorCapabilities, null, null, sentenceExternalMap);

But while running it, gives an runtime error URI is not hierarchical. So I tried the above mentioned code by admac. It too gave me the same error as mentioned above. So I dont seem to get whats the correct method to declare external resource in analysis engine description. Also I cannot make changes the AnalysisComponent class file.
Can someone please help me with correct code.
Thanks 

--
You received this message because you are subscribed to the Google Groups "uimafit-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uimafit-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Richard Eckart de Castilho

unread,
Jul 2, 2013, 5:41:32 AM7/2/13
to uimafi...@googlegroups.com
The AnalysisEngineFactory.createPrimitiveDescription() used in the original post also adds capabilities. In that signature, the last parameter is indeed a map of <String, ExternalResourceDescription>. I wonder, though, if it is really necessary to declare capabilities. If not, the variant suggested by Torsten is certainly more convenient.

In any case, this is probably related to issue 133 [1].

-- Richard

[1] http://code.google.com/p/uimafit/issues/detail?id=133

Richard Eckart de Castilho

unread,
Jul 2, 2013, 5:45:50 AM7/2/13
to uimafi...@googlegroups.com
The error "URI is not hierarchical" appears to be different form the "Unsupported resource specifier class" reported in issue 133 [1]. Is it possible that relative file URLs are not supported? Maybe the URL needs to be something like "file:///my/resource/folder/sdmed.mod"?

Cheers,

ravig...@gmail.com

unread,
Jul 2, 2013, 8:52:12 AM7/2/13
to uimafi...@googlegroups.com
Hi,
I know this is related to issue 133 so I have posted it there too. But your suggestion of file:// doesn't work, it gives the error "URI has an authority component". Any idea?

Regards,
Ravi Garg

Richard Eckart de Castilho

unread,
Jul 2, 2013, 9:45:01 AM7/2/13
to uimafi...@googlegroups.com
Did you try with "file:/" or "file:///"?

-- Richard

ravig...@gmail.com

unread,
Jul 2, 2013, 10:12:59 AM7/2/13
to uimafi...@googlegroups.com
Hi,

I tried that too but strangely it gives a filenotfound exception now, but I have file present at the location.

Regards,
Ravi Garg

ravig...@gmail.com

unread,
Jul 2, 2013, 12:18:28 PM7/2/13
to uimafi...@googlegroups.com

Hi,

After working on it for quite a time I actually now have got it to work. The correct syntax was

ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription("MaxentModelFile", org.apache.ctakes.core.resource.SuffixMaxentModelResourceImpl.class, new File("sdmed.mod").toURI().toURL().toString());    
          Map<String,ExternalResourceDescription> sentenceExternalMap = new HashMap<String, ExternalResourceDescription>();
        sentenceExternalMap.put("MaxentModel", erd);
        AnalysisEngineDescription sentenceDetectorDesc = AnalysisEngineFactory.createPrimitiveDescription(SentenceDetector.class, null, null, null, sentenceDetectorCapabilities, null, null, sentenceExternalMap);
        ExternalResourceFactory.createDependency(sentenceDetectorDesc, "MaxentModel", org.apache.ctakes.core.resource.MaxentModelResource.class);
        sentenceDetectorDesc.toXML(new FileOutputStream("sentenceDesc.xml"));

Thank you all for help.

Regards,
Ravi

On Tuesday, 2 July 2013 19:15:01 UTC+5:30, Richard wrote:
Reply all
Reply to author
Forward
0 new messages