views:

246

answers:

3

You pass the string, and it outputs the language: english/spanish/japanese. Is there such library, and is it efficient?

+7  A: 

Yes, there is a great library named NLTK, the natural language toolkit. There is a free online book about it that covers the topic of detecting languages.

Gattster
+5  A: 

Google's Translation API supports detecting languages, try to follow this link: http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=Ciao%20mondo

The output is JSON encoded and look like this:

{"responseData": {"language":"it","isReliable":false,"confidence":0.1805579}, "responseDetails": null, "responseStatus": 200}

For more usage details check the reference.

Nadia Alramli
+1, great, I was about to mention same thing.
S.Mark
Good suggestion. That is probably much more practical than NLTK for most cases. Also it doesn't require reading a book.
Gattster
+3  A: 

If you need language guessing offline, try guess-language, I've used it myself and it is neat. According to the project site, it currently detects 60 languages based on trigram similarity.

PhilS