You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by John Cabral <jo...@gmail.com> on 2008/02/19 23:22:19 UTC
Proper Way to Point to CAS to File Using URI?
I am trying to pass the URI of the file I want to process to my
engine. The code that I am using works as expected when I extract
the text from a text document and add it to a CAS using its
setDocumentText() method. What is the proper set of methods that need
to be called when sending just the URI? This is the basic code that I
am using:
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
CAS cas = ae.newCAS();
MimetypesFileTypeMap mimetypeMap = new MimetypesFileTypeMap ();
cas.setSofaDataURI(inputFileURI, mimetypeMap.getContentType(inputFileURI));
At the last line I get this error (this is the complete trace):
java.lang.ArrayIndexOutOfBoundsException: -1
Presumably, I am not configuring the CAS correctly. Any advice? The
examples that I have been studying have all set the document text
after extracting it from the file.
Thank you.
Re: Proper Way to Point to CAS to File Using URI?
Posted by Eddie Epstein <ea...@gmail.com>.
John,
I apologize. Our test cases for cas.setSofaDataURI() all used an
explicitly created view. As you have shown, there a bug when the
_InitialView is used.
A workaround for now is use a named view,
CAS testView = cas.createView("remoteView");
remoteView .setSofaDataURI(inputFileURI,
mimetypeMap.getContentType(inputFileURI));
Thanks for finding this,
Eddie
On Feb 19, 2008 6:10 PM, John Cabral <jo...@gmail.com> wrote:
> You mean from the mimetypeMap object? That's returning "plain/text."
> I tried it with that value hard-coded in (and no usage of the
> mimetypes map ) and it behaved exactly the same way. Here try this
> code:
>
> MimetypesFileTypeMap map = new MimetypesFileTypeMap ();
> System.out.println(map.getContentType("someRandomName.txt");
>
>
> If not that kind of map, sorry for the misinterpretation, what other
> map might you be referring to?
>
>
> Thank you.
>
> John C.
>
>
> On Feb 19, 2008 5:28 PM, Eddie Epstein <ea...@gmail.com> wrote:
> > On Feb 19, 2008 5:22 PM, John Cabral <jo...@gmail.com> wrote:
> > > I am trying to pass the URI of the file I want to process to my
> > > engine. The code that I am using works as expected when I extract
> > > the text from a text document and add it to a CAS using its
> > > setDocumentText() method. What is the proper set of methods that need
> > > to be called when sending just the URI? This is the basic code that I
> > > am using:
> > >
> > > AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
> > > CAS cas = ae.newCAS();
> > > MimetypesFileTypeMap mimetypeMap = new MimetypesFileTypeMap ();
> > > cas.setSofaDataURI(inputFileURI, mimetypeMap.getContentType(inputFileURI));
> > >
> > > At the last line I get this error (this is the complete trace):
> > >
> > > java.lang.ArrayIndexOutOfBoundsException: -1
> > >
> >
> > The method cas.setSofaDataURI(String, String) is not throwing the
> > exception here. Looks to me like access to an empty map is doing it.
> >
> > Eddie
> >
>
Re: Proper Way to Point to CAS to File Using URI?
Posted by John Cabral <jo...@gmail.com>.
You mean from the mimetypeMap object? That's returning "plain/text."
I tried it with that value hard-coded in (and no usage of the
mimetypes map ) and it behaved exactly the same way. Here try this
code:
MimetypesFileTypeMap map = new MimetypesFileTypeMap ();
System.out.println(map.getContentType("someRandomName.txt");
If not that kind of map, sorry for the misinterpretation, what other
map might you be referring to?
Thank you.
John C.
On Feb 19, 2008 5:28 PM, Eddie Epstein <ea...@gmail.com> wrote:
> On Feb 19, 2008 5:22 PM, John Cabral <jo...@gmail.com> wrote:
> > I am trying to pass the URI of the file I want to process to my
> > engine. The code that I am using works as expected when I extract
> > the text from a text document and add it to a CAS using its
> > setDocumentText() method. What is the proper set of methods that need
> > to be called when sending just the URI? This is the basic code that I
> > am using:
> >
> > AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
> > CAS cas = ae.newCAS();
> > MimetypesFileTypeMap mimetypeMap = new MimetypesFileTypeMap ();
> > cas.setSofaDataURI(inputFileURI, mimetypeMap.getContentType(inputFileURI));
> >
> > At the last line I get this error (this is the complete trace):
> >
> > java.lang.ArrayIndexOutOfBoundsException: -1
> >
>
> The method cas.setSofaDataURI(String, String) is not throwing the
> exception here. Looks to me like access to an empty map is doing it.
>
> Eddie
>
Re: Proper Way to Point to CAS to File Using URI?
Posted by Eddie Epstein <ea...@gmail.com>.
On Feb 19, 2008 5:22 PM, John Cabral <jo...@gmail.com> wrote:
> I am trying to pass the URI of the file I want to process to my
> engine. The code that I am using works as expected when I extract
> the text from a text document and add it to a CAS using its
> setDocumentText() method. What is the proper set of methods that need
> to be called when sending just the URI? This is the basic code that I
> am using:
>
> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
> CAS cas = ae.newCAS();
> MimetypesFileTypeMap mimetypeMap = new MimetypesFileTypeMap ();
> cas.setSofaDataURI(inputFileURI, mimetypeMap.getContentType(inputFileURI));
>
> At the last line I get this error (this is the complete trace):
>
> java.lang.ArrayIndexOutOfBoundsException: -1
>
The method cas.setSofaDataURI(String, String) is not throwing the
exception here. Looks to me like access to an empty map is doing it.
Eddie