You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Nick Allmaker <ni...@docenterinc.com> on 2007/08/21 16:47:33 UTC

Custom TextExtractor

In my repository, I'm storing a variety of files, including some images
of paper documents.  I'd like to be able to hook up an OCR engine to do
full-text search against these images (usually TIFFs), but I'm having
issues getting Jackrabbit to pick up my class.  To ensure that I can get
the system to pick up my class, I've written a simple testing version of
the class for now before actually adding in any OCR.  I've included this
class at the bottom of the e-mail.

I've edited the workspace.xml to include my class in the
textFilterClasses parameter of the SearchIndex node, added my jar to the
classpath, deleted the index to force a re-index, and ran a very simple
test.  Yet, when I search for the test text, I get 0 results.

Can someone please tell me what I'm doing wrong?

Thanks,

--Nick Allmaker

--------ImageTextExtractor.java--------
package test.extractors; 

import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import org.apache.jackrabbit.extractor.AbstractTextExtractor;

public class ImageTextExtractor extends
org.apache.jackrabbit.extractor.AbstractTextExtractor 
{

	public ImageTextExtractor() 
	{
		super(new String[]{"image/tiff", "image/jpeg",
"image/png", "image/gif"});
	}

	public Reader extractText(InputStream stream, String type,
String encoding)
	{
		stream.close();
		return new StringReader("This is a test extraction.");
	}

}

RE: Custom TextExtractor

Posted by Nick Allmaker <ni...@docenterinc.com>.
Replies within...

-----Original Message-----
From: Jukka Zitting [mailto:jukka.zitting@gmail.com] 
Sent: Tuesday, August 21, 2007 10:17 AM
To: users@jackrabbit.apache.org
Subject: Re: Custom TextExtractor

> Hi,
>
> On 8/21/07, Nick Allmaker <ni...@docenterinc.com> wrote:
> > I'd like to be able to hook up an OCR engine to do full-text search
> > against these images (usually TIFFs), but I'm having issues getting
> > Jackrabbit to pick up my class.
>
> Are you working with an open source OCR engine? I would be very
> interested in hearing more about your solution.

No, we are using a closed-source OCR engine.  We had already licensed it
and aren't looking to redistribute our application with the OCR feature.
When we have more time to research, we will probably look into
open-source OCR engines so we no longer have to worry about licensing.

> > I've edited the workspace.xml to include my class in the
> > textFilterClasses parameter of the SearchIndex node, added my jar to
the
> > classpath, deleted the index to force a re-index, and ran a very
simple
> > test.  Yet, when I search for the test text, I get 0 results.
> >
> > Can someone please tell me what I'm doing wrong?
>
> Have you checked that you've set the jcr:mimeType properties correctly
> on the image nodes?

Yes.  They're "image/tiff."  To test, I added a plaintext file to my
test repository and included the PlainTextExtractor in the
textFilterClasses.  When I queried for items in the text of that file,
the text file returned.

> Otherwise, do you see a warning message being logged about the
> extractor class not being available?

Indeed, I was getting this, mostly due to my inexperience with packaging
.jar files.  Once I overcame this, though, I was still seeing the same
result from the search.  I also added logging to my constructor and
extractText functions, yet saw neither in the resultant log.

Thank you for the guidance thus far.

--Nick Allmaker 

Re: Custom TextExtractor

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 8/21/07, Nick Allmaker <ni...@docenterinc.com> wrote:
> I'd like to be able to hook up an OCR engine to do full-text search
> against these images (usually TIFFs), but I'm having issues getting
> Jackrabbit to pick up my class.

Are you working with an open source OCR engine? I would be very
interested in hearing more about your solution.

> I've edited the workspace.xml to include my class in the
> textFilterClasses parameter of the SearchIndex node, added my jar to the
> classpath, deleted the index to force a re-index, and ran a very simple
> test.  Yet, when I search for the test text, I get 0 results.
>
> Can someone please tell me what I'm doing wrong?

Have you checked that you've set the jcr:mimeType properties correctly
on the image nodes?

Otherwise, do you see a warning message being logged about the
extractor class not being available?

BR,

Jukka Zitting