简体   繁体   中英

Profiling of Stanford Parser

I am using Stanford Parser in my project where I will be parsing more than 100,000 sentences. Since running the Stanford Parser from both Java or NLTK loads the parser first and then actually runs the sentence over it. I wanted to find out how much is the loading time compared to actually parsing time of the input sentence.

Is there a way I can add print statements in the code, compile it and find out the time it takes for each of the sentences.

First of all, you should make sure you're using the shift reduce parser (~10x faster), and if you only need dependency parses, the dependency parser (~100x faster).

But for profiling: if you parse a few hundred sentences the time taken to parse the sentences will be substantially higher than the time to load the models. The model is only loaded once when the program starts up. If that's not granular enough, you can always put a System.currentTimeMillis() call before and after calling the parser, and profile it that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM