Python in browser with NLTK or alternative? - python

Is there a Python front-end that supports nltk?
I am building a custom application that needs to do stemming and stopping, and related processing, on a simple words query from inside the browser. I am familiar with nltk's stem/stop functionality, but a quick google of Python front-end alternatives listed in this thread does not turn up support for nltk. I tried pypy.js from its website, entered "import nltk," and it failed.
(I plan to use CherryPy as the back-end, if it matters, to serve up the application to the browser on first contact, and process the outputs.)
Is there a front-end that works with nltk? Alternatively:
Can I add nltk support to any of these environments, and how?
Is there another library that does stemming/stopping that works with these front-ends?
Thank you!

You're probably best off using a JavaScript NLP library of which there are several, like NLPJS, although I can't judge its quality.
If you use Transcrypt in your browser you can use objects and call functions from that library without conversion.
So you can program in Python, while your library is in JS.

you can use flask to show your python in web browser. Flask is a web framework. This means flask provides you with tools, libraries and technologies that allow you to build a web application.
In your case you can use flask to get data from browser and analyse your data and then show the result in browser.
you can see a word cloud example with flask here.

Related

How to use python and wix for web development [duplicate]

I'm trying to integrate backend code into a Wix site. Im not too picky about how I want to do this, or what language to write in (ideally, I have a locally-hosted Java code that I'd love to simply call). I wouldn't mind re-writing it in JavaScript though, or another language. But before I decide that I'm confused about my options. I can code but I'm new to the concepts like modules, APIs, & servers.
According to my research, back-end code with Wix is supposed to be easy (or at least do-able and not THAT complicated)....
From this webpage https://support.wix.com/en/article/corvid-calling-server-side-code-from-the-front-end-with-web-modules,
"Web modules are exclusive to Corvid and enable you to write functions that run server-side in the backend, and easily call them in your client-side code. With web modules you can import functions from backend into files or scripts in public, knowing they will run server-side. Corvid handles all the client-server communication required to enable this access."
And from this: https://www.sitepoint.com/what-is-wix-code/
"It’s serverless: All this added functionality comes in a serverless environment that lets you get your work done without any of the normal full-stack development headaches.
Just code and go: Wix Code has a built-in, online IDE and backend so you can just add the code you need to your page or your site, publish, and you’re live."
So, I thought they have a backend IDE where I can write backend code directly, or I could call my Java program. But, as I tried doing this and finding tutorials, it seems I can really only do this by calling a public API from the backend...?
https://youtu.be/tuu0D1izrUU
But ive also read (and someone who supposedly has done it before told me this) that Wix integrates with node.js, which is a backend version of JavaScript.
Can I use a Wix domain for a NodeJS app?
But, when I go into my Wix site I cannot find any option for using Node JS, and doing research on that gives me no useful results.
So, I'm thoroughly confused on what the capabilities are here. Can someone help me make sense of this?
Why are there no tutorials showing explicit code in the Corvid backend module? What's stopping me from simply writing my Java program there in a module? Do I really need an API endpoint to call and pass to the front end?
Is Node JS supported or not - has anyone done this before?
Also, in one link above they said everything is "serverless". But if I have to set up my own API endpoint won't I need to set up my own server??
There are basically two ways to go about this, which you seem to have already discovered.
Write your backend code in your Wix site. Indeed, the backend is built on Node.js as you can see here. Using this approach you will have to use JavaScript. As you seem to have found, you write this code in the Backend section of your site in a Web Module. Pros: you don't need to worry about managing a server and all your code is in one place.
Expose your already existing Java code as an API that your Wix site can call using the wix-fetch API. Pros: you don't need to rewrite your code.

How to setup python flask web project with react on glitch?

I want to build a static web page based on python as server side and React for frontend on glitch online programming environment but unable to do .
I tried to implement by using CDN link but unable to use efficiently . Apart from this, I also wanted to use MATERIAL UI but according to there website it says
Using this approach in production is discouraged though - the client has to download the entire library, regardless of which components are actually used, affecting performance and bandwidth utilization.
Please elaborate steps to do the same.
Im sorry if that's too simple, but I managed to do it reading this article:
https://towardsdatascience.com/build-deploy-a-react-flask-app-47a89a5d17d9
I use the framework Flask, but if you are using Django the process must be similar.
But I recomend building a API with python and communicate with the front-end through the fecth API from javascript, or axios on react. You'll even be able to work on the frontend and backend in two different servers if you want.

Best way to make a web interface for python script

I've made a small python script to scrap the web. I would like to make a nice and simple web interface where the user can enter data to search for and have the result displayed as a list.
I understand that there's many different ways to do that but don't know which one would be the best in my case.
I would like something :
Really simple and light
Running locally with the less dependencies possible.
So far I've thinking about :
A NodeJS server displaying content and executing the script
A web framework in Python (web.py, Flask, Django..?)
A local webserver (XAMPP) and cgi
Please note that I don't know much about web in python but I'm a bit used to NodeJS.
What would you recommend ?
Thanks, Victor
Personally I prefer gevent, bottle or Flask, and some front end framework like bootstrap or framework7.
Gevent easily makes it asynchronous and has websockets built right in, and bottle is the easiest (and fastest) way to build a web app or api.
Socket.io ist Very easy to send Data between Websites and scripts.
The Website Connect with the Socket.io Server and Inside the Server the Python Script can be executed

How to expose an NLTK based ML(machine learning) Python Script as a Web Service?

Let me explain what I'm trying to achieve. In the past while working on Java platform, I used to write Java codes(say, to push or pull data from MySQL database etc.) then create a war file which essentially bundles all the class files, supporting files etc and put it under a servlet container like Tomcat and this becomes a web service and can be invoked from any platform.
In my current scenario, I've majority of work being done in Java, however the Natural Language Processing(NLP)/Machine Learning(ML) part is being done in Python using the NLTK, Scipy, Numpy etc libraries. I'm trying to use the services of this Python engine in existing Java code. Integrating the Python code to Java through something like Jython is not that straight-forward(as Jython does not support calling any python module which has C based extensions, as far as I know), So I thought the next option would be to make it a web service, similar to what I had done with Java web services in the past. Now comes the actual crux of the question, how do I run the ML engine as a web service and call the same from any platform, in my current scenario this happens to be Java. I tried looking in the web, for various options to achieve this and found things like CherryPy, Werkzeug etc but not able to find the right approach or any sample code or anything that shows how to invoke a NLTK-Python script and serve the result through web, and eventually replicating the functionality Java web service provides. In the Python-NLTK code, the ML engine does a data-training on a large corpus(this takes 3-4 minutes) and we don't want the Python code to go through this step every time a method is invoked. If I make it a web service, the data-training will happen only once, when the service starts and then the service is ready to be invoked and use the already trained engine.
Now coming back to the problem, I'm pretty new to this web service things in Python and would appreciate any pointers on how to achieve this .Also, any pointers on achieving the goal of calling NLTK based python scripts from Java, without using web services approach and which can deployed on production servers to give good performance would also be helpful and appreciable. Thanks in advance.
Just for a note, I'm currently running all my code on a Linux machine with Python 2.6, JDK 1.6 installed on it.
One method is to build an XML-RPC server, but you may wish to fork a new process for each connection to prevent the server from seizing up. I have written a detailed tutorial on how to go about this: https://speakerdeck.com/timclicks/case-studies-of-python-in-parallel?slide=68.
NLTK based system tends to be slow at response per request, but good throughput can be achieved given enough RAM.

Web framework for *not* creating websites? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Recommended python library/framework for local web app?
I am looking for a lightweight framework/webserver that will make it easy to develop web interfaces for some demon processes or some application that should have ideally be an desktop application.
Some examples
To organize photo/music collections, move between folders, edit meta data of those etc,
A simple to-do list/ Money manager/ Documents manager etc,
A log/textFile viewer
A page showing the status of my git repositories
I prefer server side to be python. I don't want to run a full webserver like apache. As this is going to be used similar to a desktop app, I dont need any security features that will prevent me from accessing file system or running any shell commands or accessing internet etc.,
Any suggestions?
Check bottle.py
Most frameworks will have built-in development servers, so you can still use django or some other. But if you are looking for something lightweight to do some quick project, bottle.py can be great
Werkzeug is a good choice. It's a web toolkit more than a web framework. It's very mature, and is the basis of Flask, a popular microframework.
I've developed a website using vanilla Werkzeug and it was really intuitive. It has an explicit feel to it. None of the RoR-style autoload-controller and folder logic, just a bunch of classes and modules that are really well-documented and useful.
As well as cherry.py is a lightweight framework with full server.
http://www.cherrypy.org/
CherryPy allows developers to build web applications in much
the same way they would build any other object-oriented Python
program. This results in smaller source code developed in less time.
Any Python web microframework running on any wsgi compliant Python lightweight web server will do. There are already questions on both here.

Categories