I will try Japanese morphological analysis with Python. Since the API is from Yahoo, we will use it.
http://developer.yahoo.co.jp/webapi/jlp/ma/v1/parse.html
First of all, the essential parameters for POST are ・ Appid ・ Sentence ・ Results There are three points. If you want to POST in detail, please add a parameter.
You can get the appid by registering with Yahoo. sentence is the text to be morphologically analyzed. results is for specifying the format of the response.
Morphological analysis.py
#coding: utf-8
import requests
from xml.etree.ElementTree import *
def POST(body):
request_URL = "http://jlp.yahooapis.jp/MAService/V1/parse"
parameter = {'appid': 'Your appid!',
'sentence': body,
'results': 'ma'}
r = requests.get(request_URL, params=parameter)
yield (r, r.text)
def XML_parse(body):
elem = fromstring(body)
for e in elem.getiterator("{urn:yahoo:jp:jlp}surface"):
print e.text
if __name__ == '__main__':
for response in POST(body="It's nice weather today, is not it"):
r = response[0]
text = response[1]
XML_parse(text.encode('utf-8'))#Unicode without encode-error