Package: goolabs
Goo labs API client for python. And provide some command line tools.FeaturesRequiredSet upUsageCommand line toolPython SupportUsingLicenseAuthorsHistoryFeaturesProvide API Client forGoo labs API.Provide some command line tools.RequiredYou need to getapp idatGoo labs websitein order to use this library.Set upMake environment with pip:$ pip install goolabsFor Max OS X user. If you want to use command line tool only, you can install from homebrew:$ brew install goolabsUsagemorphMorphological analysis for Japanese.See alsohttps://labs.goo.ne.jp/api/2015/1302/fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.sample_response=api.morph(sentence=u"日本語を分析します。")# All the arguments of this func.api.morph(request_id="morph-req001",sentence=u"日本語を分析します。",info_filter="form|pos|read",pos_filter=u"名詞|格助詞|動詞活用語尾|動詞接尾辞|句点",)# Possible parts of speech, please refer to the following URL.# https://labs.goo.ne.jp/api/2015/1158/Sample response.{"word_list":[[["日本語","名詞","ニホンゴ"],["を","格助詞","ヲ"],["分析","名詞","ブンセキ"],["し","動詞活用語尾","シ"],["ます","動詞接尾辞","マス"],["。","句点","＄"]]],"request_id":"labs.goo.ne.jp\t1419262824\t0"}similarityScoring the similarity of two words.See alsohttps://labs.goo.ne.jp/api/2015/1295/fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.similarity(query_pair=["windows",u"ウィンドウズ"])# All the arguments of this func.api.similarity(request_id="similarity-req001",query_pair=["windows",u"ウィンドウズ"])Sample response.{"score":0.7679829666474438,"request_id":"labs.goo.ne.jp\t1419263621\t0"}hiraganaConvert the Japanese to Hiragana or Katakana.See alsohttps://labs.goo.ne.jp/api/2015/1293/fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.hiragana(sentence=u"漢字が混ざっている文章",output_type="hiragana")# All the arguments of this func.api.hiragana(request_id="hiragana-req001",sentence=u"漢字が混ざっている文章",output_type="hiragana"# hiragana or katakana)Sample response.{"output_type":"hiragana","converted":"かんじが まざっている ぶんしょう","request_id":"labs.goo.ne.jp\t1419263773\t0"}entitiyExtract the unique representation from sentence.see alsohttps://labs.goo.ne.jp/api/2015/1299/.fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.entity(sentence=u"鈴木さんがきょうの9時30分に横浜に行きます。")# All the arguments of this func.api.entity(request_id="entity-req001",sentence=u"鈴木さんがきょうの9時30分に横浜に行きます。"class_filter=u"ART|ORG|PSN|LOC|DAT|TIM")Sample response.{"ne_list":[["鈴木","PSN"],["きょう","DAT"],["9時30分","TIM"],["横浜","LOC"]],"request_id":"labs.goo.ne.jp\t1419264063\t0"}shortsumSummarizes the sent-in Japanese reviews into a short summary.see alsohttps://labs.goo.ne.jp/api/2015/1305/fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.shortsum(review_list=["機能は限られていますが、必要十分でしょう。","価格も安いと思います。お店の対応もよかったです。","このシリーズを買うの3台目になりました。黒の発色が綺麗です。""値段を考えれば十分すぎる性能で",])# All the arguments of this func.api.shortsum(request_id="shortsum-req001",review_list=["機能は限られていますが、必要十分でしょう。","価格も安いと思います。お店の対応もよかったです。","このシリーズを買うの3台目になりました。黒の発色が綺麗です。""値段を考えれば十分すぎる性能で",],length=60# 60 or 120 or 180)Sample response.{"length":60,"summary":"黒の発色が綺麗です。機能は限られていますが、必要十分でしょう。価格も安いと思います。","request_id":"shortsum-req001"}keywordExtracts “Japanese keywords”, such as person names, location names, and so on,
from an input document consisting of a title and a body.see alsohttps://labs.goo.ne.jp/api/2015/1325/fromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.keyword(title="「和」をコンセプトとする 匿名性コミュニケーションサービス「MURA」",body="NTTレゾナント株式会社（本社：東京都港区、代表取締役社長：若井 昌宏",)# All the arguments of this func.api.keyword(request_id="keyword-req001",title="「和」をコンセプトとする 匿名性コミュニケーションサービス「MURA」",body="NTTレゾナント株式会社（本社：東京都港区、代表取締役社長：若井 昌宏",max_num=10,forcus="ORG",)Sample response.{"keywords":[{"和":0.5893},{"コンセプト":0.5893},{"匿名性":0.5893},{"コミュニケーションサービス":0.5893},{"MURA":0.5893},{"NTTレ ゾナント株式会社":0.35},{"本社":0.35},{"東京都港区":0.35},{"代表取締役社長":0.35},{"若井":0.35}],"request_id":"labs.goo.ne.jp\t1457928295\t0"}chronoExtract expression expressing date and time and normalize its valuesee alsohttps://labs.goo.ne.jp/api/jp/time-normalizationfromgoolabsimportGoolabsAPIapp_id="xxxxxxxxxxxxxxxxxxxx"api=GoolabsAPI(app_id)# See sample response below.ret=api.chrono(sentence="今日の10時半に出かけます。",)# All the arguments of this func.api.chrono(request_id="chrono-req001",sentence="今日の10時半に出かけます。",doc_time="2016-04-01T09:00:00",)Sample response.{"request_id":"record007",,"datetime_list":}{"datetime_list":[["今日","2016-04-01"],["10時半","2016-04-01T10:30"]],"doc_time":"2016-04-01T09:00:00","request_id":"labs.goo.ne.jp\t1457928295\t0"}Other tipsYou can see the HTTP response you called right before.api=GoolabsAPI(app_id)api.morph(sentence=u"日本語を分析します。")# api.response is a instance of "requests.Response".print(api.response.status_code)# => 200print(api.response.json())# => raw json data.Command line tool$goolabsUsage:goolabs[OPTIONS]COMMAND[ARGS]...CommandlinetoolsforGoolabsAPI(https://labs.goo.ne.jp/api/).Options:--versionShowtheversionandexit.--helpShowthismessageandexit.Commands:chronoExtractexpressionexpressingdateandtime...entityExtractuniquerepresentationfromsentence.hiraganaConverttheJapanesetoHiraganaorKatakana.keywordExtract"keywords"fromaninputdocument.morphMorphologicalanalysisforJapanese.shortsumSummarizereviewsintoashortsummary.similarityScoringthesimilarityoftwowords.Set environment variable GOOLABS_APP_IDTo use this cli, it is recommended to set the environment variable GOOLABS_APP_ID.# write your shell setting files(ex ~/.bashrc).exportGOOLABS_APP_ID=xxxxxxxxxxxxxxxYou may pass the App id every time you use it, but it’s not recommended.$goolabsmorph--app-idxxxxx日本語を分析します。morph$goolabsmorph--helpUsage:goolabsmorph[OPTIONS][SENTENCE]MorphologicalanalysisforJapanese.Options:-a,--app-idTEXT-r,--request-idTEXT-i,--info-filterTEXTform,pos,read-p,--pos-filterTEXT名詞,句点,格助詞..etc-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabsmorph日本語を分析します。日本語,名詞,ニホンゴを,格助詞,ヲ分析,名詞,ブンセキし,動詞活用語尾,シます,動詞接尾辞,マス。,句点,＄# more option$goolabsmorph--info-filterform,pos,read--pos-filter名詞,句点日本語を分析します。# specify a file as an alternative to the sentence$goolabsmorph--filesentence.txt# get raw json$goolabsmorph--json--request-idreq001日本語{"word_list":[[["日本語","名詞","ニホンゴ"]]],"request_id":"req001"}similarity$goolabssimilarity--helpUsage:goolabssimilarity[OPTIONS]QUERY_PAIR...Scoringthesimilarityoftwowords.Options:-a,--app-idTEXT-r,--request-idTEXT-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabssimilarityウィンドウズwindows0.767982966647# get raw json.$goolabssimilarity--json--request-idreq002ウィンドウズwindows{"score":0.7679829666474438,"request_id":"req002"}hiragana$goolabshiragana--helpUsage:goolabshiragana[OPTIONS][SENTENCE]ConverttheJapanesetoHiraganaorKatakana.Options:-o,--output-type[hiragana|katakana]-a,--app-idTEXT-r,--request-idTEXT-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabshiragana日本語にほんご# convert to Katakana$goolabshiragana--output-typekatakana日本語ニホンゴ# specify a file as an alternative to the sentence$goolabshiragana--filesentence.txt# get raw json$goolabshiragana--json--request-idreq003日本語{"output_type":"hiragana","converted":"にほんご","request_id":"req003"}entity$goolabsentity--helpUsage:goolabsentity[OPTIONS][SENTENCE]Extractuniquerepresentationfromsentence.Options:-c,--class-filterTEXTART,ORG,PSN,LOC,DAT-a,--app-idTEXT-r,--request-idTEXT-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabsentity佐藤氏、2014年12月に足の小指骨折し豊洲の病院へ佐藤,PSN2014年12月,DAT豊洲,LOC# more option$goolabsentity--class-filterPSN,LOC佐藤氏、2014年12月に足の小指骨折し豊洲の病院へ# specify a file as an alternative to the sentence$goolabsentity--filesentence.txt# get raw json$goolabsentity--json--request-idreq004佐藤氏{"ne_list":[["佐藤","PSN"]],"request_id":"req004"}shortsum$goolabsshortsum--helpUsage:goolabsshortsum[OPTIONS][REVIEW]Summarizereviewsintoashortsummary.Options:-a,--app-idTEXT-l,--length[60|120|180]-r,--request-idTEXT-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabsshortsumこのシリーズを買うの3台目になりました。黒の発色が綺麗です黒の発色が綺麗です。# more option$goolabsshortsum--length180黒の発色が綺麗です...# specify a file as an alternative to the review$goolabsshortsum--filereview.txt# get raw json$goolabsshortsum--json--request-idreq005このシリーズを買うの3台目になりました。黒の発色が綺麗です{"length":120,"summary":"黒の発色が綺麗です。","request_id":"req005"}keyword$goolabskeyword--helpUsage:goolabskeyword[OPTIONS]TITLE[BODY]Extract"keywords"fromaninputdocument.Options:-a,--app-idTEXT-m,--max_numINTEGER-fo,--forcus[ORG|PSN|LOC]-r,--request-idTEXT-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabskeyword"匿名性コミュニケーションサービス「MURA」""NTTレゾナント株式会社"匿名性,0.6コミュニケーションサービス,0.6MURA,0.6NTTレゾナント株式会社,0.4# more option$goolabskeyword--max_num2--forcusORG"匿名性コミュニケーションサービス「MURA」""NTTレゾナント株式会社"# specify a file as an alternative to the body$goolabskeyword--filebody.txt"匿名性コミュニケーションサービス「MURA」"# get raw json$goolabskeyword--json--request-idreq006"匿名性コミュニケーションサービス「MURA」""NTTレゾナント株式会社"{"keywords":[{"匿名性":0.6},{"コミュニケーションサービス":0.6},{"MURA":0.6},{"NTTレゾナント株式会社":0.4}],"request_id":"req006"}chrono$goolabschrono--helpUsage:goolabschrono[OPTIONS][SENTENCE]Extractexpressionexpressingdateandtimeandnormalizeitsvalueptions:-a,--app-idTEXT-r,--request-idTEXT-d,--doc-timeTEXT-f,--fileFILENAME-j,--json/--no-json--helpShowthismessageandexit.Sample usage.$goolabschrono"今日の10時半に出かけます。"今日:2017-05-2910時半:2017-05-29T10:30# more option$goolabschrono-d"2016-04-01T09:00:00""今日の10時半に出かけます。"今日:2016-04-0110時半:2016-04-01T10:30# specify a file as an alternative to the body$goolabschrono--filesentence.txt# get raw json$goolabschrono--json--request-idreq007"今日の10時半に出かけます"{"datetime_list":[["今日","2017-05-29"],["10時半","2017-05-29T10:30"]],"doc_time":"2017-05-29T12:36:33","request_id":"req007"}Python SupportPython 2.6, 2.7, 3,3, 3.4 or later.UsingGoo labs API.LicenseSource code of this library Licensed under the MIT License.You have to use of Goo labs API underthe TermSee the LICENSE.rst file for specific terms.Authorstell-k <ffk2005 at gmail.com>History0.4.0(May 30, 2017)Add new api “chrono”.Add support for Python3.6.Add type annotation.0.3.0(Mar 14, 2016)Add new api “keyword”.0.2.2(Jul 12, 2015)Add “-l” option for “goolabs shortsum” command.0.2.0(Jul 12, 2015)Add new api “shortsum”.improved unit test code0.1.2(Jan 1, 2015)Exclude test code from installed packages0.1.1(Dec 31, 2014)Add unit test for commandline tools.0.1.0(Dec 25, 2014)First release