I assume your classifier has an internal state which you want to maintain
and a startup time you want to avoid. If you are running on a single
machine with rocket (the built-in web2py server) you can cache that state
in ram. For example given
class NLP(object):
lock = threading.Lock()
def __init__(self, init_variables): pass
def run(self, input):
lock.acquire() # because no way this is thread safe
try:
do something
finally:
lock.release()
you can do
init_variables = ...
nlp = cache.ram('my-classfier',lambda: NLP(init_variables),None) # None=
never expore
nlp.run(....) # where needed
In a multiprocess or distributed environment where ram is not shared this
approach will not work. You will need to run your code as a service from a
single instance and call it where needed via an API. You can try use the
xmlrpc module for that.
On Monday, 20 July 2015 01:14:39 UTC-5, Anshul Goyal wrote:
>
> Hi,
>
> I have created a text classifier in spyder which classifies text data into
> certain categories. Now i want to create a web application(i am using
> web2py based on lot of positive reviews) on top of that. So workflow will
> be; User enters or types text into a user input box, input is stored into
> string and then passed onto my text classifier which returns the category
> it belongs to. I want to understand how to link that text classifier
> created in spyder with web application created using web2py.
>
> Do i copy 'text classifier' code and run it entirely when user submits
> the text. Is there any way the my NLP text classifier is stored at some
> location and user input is directly passed onto it.
>
> Any direction/hyperlinks/specific pointers to documentation on this will
> be really helpful.
>
> Thanks,
> Anshul
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.