Created
April 21, 2009 12:07
-
-
Save youpy/99102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* appjet:version 0.1 */ | |
var usage = """import("lib-jlp"); | |
import("lib-json"); | |
var maService = new JLP.MAService(); | |
print(P(CODE(JSON.stringify(maService.parse('庭には二羽ニワトリがいる。'))))); | |
"""; | |
print(H1(appjet.appName)); | |
print(P('Handy library to use ', | |
A({href: 'http://developer.yahoo.co.jp/webapi/jlp/'}, | |
'Yahoo! JAPAN jlp webapi'))); | |
print(H2('MAService')); | |
print(H3('usage')); | |
print(PRE(usage)); | |
print(H4('result')); | |
eval(usage); | |
/* appjet:library */ | |
import("lib-json"); | |
var JLP = {}; | |
JLP.MAService = function() { | |
if(!(this instanceof arguments.callee)) { | |
return new arguments.callee(options); | |
} | |
} | |
JLP.MAService.prototype.parse = function(text) { | |
var yql = "select * from xml where url=\"http://jlp.yahooapis.jp/MAService/V1/parse?appid=AgeuXFaxg66_am8.xytKxMt0mqfH_hvVvSvliD_iNu10KTUtmtvvfIzct9Oh&sentence=" + encodeURIComponent(text) + "\""; | |
var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(yql) + '&format=json&callback='; | |
var content = decodeURIComponent(escape(wget(url))); | |
var json = JSON.parse(content); | |
return [].concat(json.query.results.ResultSet.ma_result.word_list.word); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment