You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by Stephane Bastian <st...@hotmail.com> on 2008/10/23 17:32:45 UTC
RFE: adding a ParserFactory class
Hi All,
I've got a use case where I need most of the functionality currently
available in the AutoDetectParser; ie being able to instantiate the
appropriate parser based upon the Stream and MetaData. In case the
parser returned is the Html one, our application logic needs to setup a
specific ContentHandler to process the SaxContent ourselves.
Unfortunately, this prevents us from being able to reuse the
AutoDetectTika parser as currently defined.
However, a ParserFactory class (which doesn't exist yet) would really
help us here and could provide public method(s) to do what's currently
done internally by the class AutoDetectParser
One option is to provide something like this:
Parser parser = ParserFactory.getInstance().getParser(stream, metadata);
Another option is the following:
MimeType mt = MimeType.getMimeType(stream, metadata);
Parser parser = ParserFactory.getInstance().getParser(mt);
All the code needed is already there, it's simply just a matter of
moving things around and create/initialize a ParserFactory class
If all this makes sense to you guys, please let me know so I can go
ahead, submit a ticket, implement this and send a Patch
All the best,
Stephane
Re: RFE: adding a ParserFactory class
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Thu, Oct 23, 2008 at 5:32 PM, Stephane Bastian
<st...@hotmail.com> wrote:
> However, a ParserFactory class (which doesn't exist yet) would really help
> us here and could provide public method(s) to do what's currently done
> internally by the class AutoDetectParser
You should be able to achieve this functionality by overriding the
getParser(Metadata) method in CompositeParser (that AutoDetectParser
inherits).
Alteratively you could simply modify the Tika configuration and pass
the modified configuration to the AutoDetectParser instance.
More generally, is there a specific reason why you need custom
processing for HTML?
BR,
Jukka Zitting