I’m using the Natural Language Toolkit for python and in it there is a useful function called pos_tag. You can run nltk.pos_tag() on any a list of words that were tokenized from a sentence and it will return a list of tuples with each word in the sentence and its part of speech (POS).
Well thats great, but I need to run this every time some runs an AJAX call on my website. Unfortunately the function has a lot of initial overhead and takes about 10 seconds to do everything it needs to do to work. Once it does, I can call nltk.pos_tag() and it will run very fast. But Each time I make the AJAX call it has to load the function again.
So I was wondering if there is a way to make that persist so I don’t have to load it every time someone comes to my page or updates it with an AJAX call. I’ve tried pickling and that didn’t work. I’ve looked at shelve but it seems like its similar to pickle. Hope someone can help.
Thanks.
I believe that the most efficient and quick way to accomplish that is to have a separate server or process which receives text and replies with the results of post_tag() function, or whatever function you want.