You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@opennlp.apache.org by siping <si...@hotmail.com> on 2015/11/12 03:39:48 UTC

ParserTool.parseLine() takes long time

Hi - I'm using following code to parse a simple sentence:
InputStream chunkingStream = new FileInputStream("en-parser-chunking.bin");
Parser parser = new ParserModel(chunkingStream);
String sentence = "Unfortunately, your service request does not include a valid serial number that is required to service your issue.";
Parse[] parses = ParserTool.parseLine(sentence, parser, 1);
Using OpenNLP 2.6.0, Java 8, running this in a loop on a normal Linux server with plenty memory, I find that the above ParserTool.parseLine() can take 50-80ms. Does that sound normal? When you have thousands of documents, each with hundreds of sentences, the delay adds up quickly.
Is there any way to speed it up?
thanks in advance. 		 	   		  

Re: ParserTool.parseLine() takes long time

Posted by Rodrigo Agerri <ra...@apache.org>.
Hello,

Are you loading the model for each sentence or document to be parsed?
If so, just load the model once and keep listening for parsing
requests. Apart from that, parsing is a heavy task, and parsers in
general are not lightning fast. Also, beware long sentences, the
longer the sentences the slower the parsing.

HTH,

R

On Thu, Nov 12, 2015 at 3:39 AM, siping <si...@hotmail.com> wrote:
> Hi - I'm using following code to parse a simple sentence:
> InputStream chunkingStream = new FileInputStream("en-parser-chunking.bin");
> Parser parser = new ParserModel(chunkingStream);
> String sentence = "Unfortunately, your service request does not include a valid serial number that is required to service your issue.";
> Parse[] parses = ParserTool.parseLine(sentence, parser, 1);
> Using OpenNLP 2.6.0, Java 8, running this in a loop on a normal Linux server with plenty memory, I find that the above ParserTool.parseLine() can take 50-80ms. Does that sound normal? When you have thousands of documents, each with hundreds of sentences, the delay adds up quickly.
> Is there any way to speed it up?
> thanks in advance.