0

I would like to set up a webpage that takes a number of Facebook status updates via the Javascript API and sorts them into an array. Then I'd like to send this array to a Python script, which can specifically do language analysis with NLTK. After I get a suitable result in Python, I'd like to return the result from that script to Javascript for displaying to the user, etc. Does this sound possible?

5
  • 2
    Why don't you just use json? Commented Apr 25, 2013 at 14:56
  • Use json for what? With NLTK? Does that work? Commented Apr 25, 2013 at 14:58
  • Use json for communicating between Python and JavaScript. Commented Apr 25, 2013 at 15:02
  • I meant you can simply parse the Javascript API result using the json module in the standard library, which will return a python object which you can then presumably use in NLTK Commented Apr 25, 2013 at 15:02
  • Any resources showing how to do that with an array would be helpful. Commented Apr 25, 2013 at 15:13

2 Answers 2

2

Yes, totally. Check out Google App Engine to build this sort of functionality. In particular check out these links:

NLTK on App Engine: Using the Python NLTK (2.0b5) on the Google App Engine and http://code.google.com/p/nltk-gae/

Facebook API on App Engine: https://developers.google.com/appengine/articles/shelftalkers

I assume that you want to make it interactive because you mentioned the word "user".

Sign up to request clarification or add additional context in comments.

2 Comments

You don't need to use the App Engine for this sort of thing - although it's one possibility. Fundamentally, this is a very common problem and can be summed up by considering the NLTK part of the process as an API. You could then call it using Ajax
True; I listed one of the most common options.
1

Calling a service from Javascript is a very common problem. One way of solving it is to write a specific type of website known as a Webservice which would make the process flow something like...

  • Javascript uses Ajax (Asynchronous Javascript and XML) to send an HTTP Request to your Webservice containing the information you want to process.
  • The Webservice receives the request and performs the requested processing (eg by invoking the NLTK)
  • The resulting data is sent back over the same Http connection
  • A javascript function is called and passed the results of the data

The easiest way to send a request is using jQuery. The easiest way to format the data to be passed back and forth is JSON (JavaScript Object Notation).

An example call would look something like this...

$.json({
  url: "/url/of/Webservice",
  data: {
         "SomeKey": "SomeValue",
         "SomeList": ["Item1", "Item2", "Item3"]
         /*... etc */
        }
}).done(function(response) {
  //Assuming a response that looks like this: {"Result": "Some Result"}
  alert("The Webservice said: " + response.Result);
});

It's up to you how you'd implement the Webservice. If you want to use Python, Django is one of many good frameworks to get you started

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.