Last active
October 4, 2015 07:58
-
-
Save rhysd/2605666 to your computer and use it in GitHub Desktop.
Examples for Yahoo Japanese Analysis Library
This file contains 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
require 'yahoo-japanese-analysis' | |
# use module's class methods directly | |
# configration | |
YahooJA.configure do |config| | |
config.app_key = 'your appid' | |
end | |
# "日本語形態素解析" API | |
result = YahooJA.morpheme_analysis "庭には2羽ニワトリがいる。",{:results => "ma,uniq"} # you can specify options. | |
p result # return result as Hash | |
# "かな漢字変換" API | |
result = YahooJA.kanji_conv "きょうはよいてんきです。" | |
p result # return result as Hash | |
# "ルビ振り" API | |
result = YahooJA.furigana "漢字かな混じりの文にふりがなを振る。" | |
p result # return result as Hash | |
# "校正支援" API | |
result = YahooJA.kousei_support "遙か彼方に小形飛行機が見える。" | |
p result # return result as Hash | |
# "日本語係り受け解析" API | |
result = YahooJA.kakari_uke "うちの庭には二羽鶏がいます。" | |
p result # return result as Hash | |
# "特徴語解析" API | |
result = YahooJA.keyphrase "東京ミッドタウンから国立新美術館まで歩いて5分で着きます。" | |
p result # return result as { "word1" => score1, "word2" => score2 } | |
# YahooJA::Client instance is also available to use multi-accounts at the same time. | |
# YahooJA::Client's instance methods are the same as YahooJA's class methods. | |
c1 = YahooJA::Client.new | |
c2 = YahooJA::Client.new | |
c1.configure do |config| | |
#... | |
end | |
c2.configure do |config| | |
#... | |
end | |
#... | |
# see below URL to get more info about APIs | |
# http://developer.yahoo.co.jp/webapi/jlp/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment