Skip to content

Instantly share code, notes, and snippets.

@youpy
Created March 20, 2009 05:23
Show Gist options
  • Save youpy/82231 to your computer and use it in GitHub Desktop.
Save youpy/82231 to your computer and use it in GitHub Desktop.
/* 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 = 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