Skip to content

Instantly share code, notes, and snippets.

@johnsmith17th
Created May 27, 2013 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsmith17th/5655294 to your computer and use it in GitHub Desktop.
Save johnsmith17th/5655294 to your computer and use it in GitHub Desktop.
scws segment
import urllib, urllib2, json
def seg(text):
data = { 'data': text, 'respond': 'json', 'charset': 'utf-8', 'ignore': 'yes', 'multi': 3 }
parm = urllib.urlencode(data)
post = urllib2.urlopen(url = 'http://www.ftphp.com/scws/api.php', data = parm, timeout = 10000)
response = post.read()
data = json.loads(response)
return [i['word'] for i in data['words']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment