NLTK and language detection

Have you come across the following code snippet? english_vocab = set(w.lower() for w in nltk.corpus.words.words()) text_vocab = set(w.lower() for w in text if w.lower().isalpha()) unusual = text_vocab.difference(english_vocab) from http://groups.google.com/group/nltk-users/browse_thread/thread/a5f52af2cbc4cfeb?pli=1&safe=active Or the following demo file? https://web.archive.org/web/20120202055535/http://code.google.com/p/nltk/source/browse/trunk/nltk_contrib/nltk_contrib/misc/langid.py

Use jQuery to detect whether a device can make telephone calls (supports “tel://” protocol)

I’m not sure about Android or BlackBerry, but iOS will automatically pick up telephone numbers and wrap them like so: <a href=”https://stackoverflow.com/questions/17345177/tel:xxx”>xxx</a>…so you could have a hidden <div> somewhere that contains a phone number like 1-800-555-5555, then, on page load do something like this: var isTelephone = $(“a[href*=’tel:’]”).length > 0; This may or may not … Read more

Python – can I detect unicode string language code?

If you need to detect language in response to a user action then you could use google ajax language API: #!/usr/bin/env python import json import urllib, urllib2 def detect_language(text, userip=None, referrer=”http://stackoverflow.com/q/4545977/4279″, api_key=None): query = {‘q’: text.encode(‘utf-8’) if isinstance(text, unicode) else text} if userip: query.update(userip=userip) if api_key: query.update(key=api_key) url=”https://ajax.googleapis.com/ajax/services/language/detect?v=1.0&%s”%( urllib.urlencode(query)) request = urllib2.Request(url, None, headers=dict(Referer=referrer)) d … Read more

How can I detect if Flash is installed and if not, display a hidden div that informs the user?

If swfobject won’t suffice, or you need to create something a little more bespoke, try this: var hasFlash = false; try { hasFlash = Boolean(new ActiveXObject(‘ShockwaveFlash.ShockwaveFlash’)); } catch(exception) { hasFlash = (‘undefined’ != typeof navigator.mimeTypes[‘application/x-shockwave-flash’]); } It works with 7 and 8.