テキスト解析
日本語形態素解析
リクエストURL
XML
https://jlp.yahooapis.jp/MAService/V1/parse
日本語文を形態素に分割し、品詞、読みがなの付与、統計情報を取得できる機能を提供します。
リクエストパラメータ
「RESTリクエストの構築(GET)」および、「RESTリクエストの構築(POST)」をご参照ください。
パラメータ | 値 | 説明 |
---|---|---|
appid(必須) | string | アプリケーションID。詳細はこちらをご覧ください。 |
sentence(必須) | string | 解析対象のテキストです。 |
results(必須) | string: ma, uniq | 解析結果の種類をコンマで区切って指定します。
無指定の場合は "ma" になります。 |
response | string: surface, reading, pos, baseform, feature |
ma_response, uniq_response のデフォルト設定です。word に返される形態素情報をコンマで区切って指定します。 無指定の場合は "surface,reading,pos" になります。 |
filter | string | ma_filter, uniq_filter のデフォルト設定です。解析結果として出力する品詞番号を "|" で区切って指定します。 filterに指定可能な品詞番号:
|
ma_response | string | ma_result 内の word に返される形態素情報をコンマで区切って指定します。無指定の場合 response の指定が用いられます。 |
ma_filter | string | ma_result 内に解析結果として出力する品詞番号を "|" で区切って指定します。無指定の場合 filter の指定が用いられます。 |
uniq_response | string | uniq_result 内の word に返される形態素情報をコンマで区切って指定します。無指定の場合 response の指定が用いられます。 |
uniq_filter | string | uniq_result 内に解析結果として出力する品詞番号を "|" で区切って指定します。無指定の場合 filter の指定が用いられます。 |
uniq_by_baseform | string | このパラメータが true ならば、基本形の同一性により、uniq_result の結果を求めます。 |
サンプルリクエストURL
https://jlp.yahooapis.jp/MAService/V1/parse?サンプルコード
日本語形態素解析を使用したサンプルコードです。
レスポンスフィールド
日本語形態素解析のスキーマの記述は、以下のURLをご覧ください。
https://jlp.yahooapis.jp/MAService/V1/parseResponse.xsd
フィールド | 説明 |
---|---|
ResultSet | 解析結果のすべてを含みます。 |
ma_result | 形態素解析の結果を含みます。 |
uniq_result | 形態素解析の結果から同一形態素の出現数を求めたものを返します。 |
total_count | 形態素の総数を返します。 |
filtered_count | フィルタにマッチした形態素数を返します。 |
word_list | 形態素のリストを返します。 |
word | 形態素を返します。 |
surface | 形態素の表記を返します。 |
reading | 形態素の読みがなを返します。 |
pos | 形態素の品詞を返します。 |
baseform | 形態素の基本形表記を返します。活用のない形態素の場合は省略されます。 |
feature | 形態素の全情報を文字列で返します。 |
count | uniq_result 中の word 内に現れる、形態素の出現数を返します。 |
サンプルレスポンス
以下は、sentence=庭には二羽ニワトリがいる。 のリクエストに対するレスポンスです。
<?xml version="1.0" encoding="UTF-8" ?> <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:jp:jlp" xsi:schemaLocation="urn:yahoo:jp:jlp https://jlp.yahooapis.jp/MAService/V1/parseResponse.xsd"> <ma_result> <total_count>9</total_count> <filtered_count>9</filtered_count> <word_list> <word> <surface>庭</surface> <reading>にわ</reading> <pos>名詞</pos> <baseform>庭</baseform> </word> <word> <surface>に</surface> <reading>に</reading> <pos>助詞</pos> <baseform>に</baseform> </word> <word> <surface>は</surface> <reading>は</reading> <pos>助詞</pos> <baseform>は</baseform> </word> <word> <surface>二</surface> <reading>2</reading> <pos>名詞</pos> <baseform>2</baseform> </word> <word> <surface>羽</surface> <reading>わ</reading> <pos>名詞</pos> <baseform>羽</baseform> </word> <word> <surface>ニワトリ</surface> <reading>にわとり</reading> <pos>名詞</pos> <baseform>ニワトリ</baseform> </word> <word> <surface>が</surface> <reading>が</reading> <pos>助詞</pos> <baseform>が</baseform> </word> <word> <surface>いる</surface> <reading>いる</reading> <pos>動詞</pos> <baseform>いる</baseform> </word> <word> <surface>。</surface> <reading>。</reading> <pos>特殊</pos> <baseform>。</baseform> </word> </word_list> </ma_result> <uniq_result> <total_count>9</total_count> <filtered_count>5</filtered_count> <word_list> <word> <surface>庭</surface> <reading>にわ</reading> <pos>名詞</pos> <baseform>庭</baseform> <count>1</count> </word> <word> <surface>二</surface> <reading>2</reading> <pos>名詞</pos> <baseform>2</baseform> <count>1</count> </word> <word> <surface>羽</surface> <reading>わ</reading> <pos>名詞</pos> <baseform>羽</baseform> <count>1</count> </word> <word> <surface>ニワトリ</surface> <reading>にわとり</reading> <pos>名詞</pos> <baseform>ニワトリ</baseform> <count>1</count> </word> <word> <surface>いる</surface> <reading>いる</reading> <pos>動詞</pos> <baseform>いる</baseform> <count>1</count> </word> </word_list> </uniq_result> </ResultSet>
エラー
日本語形態素解析はYahoo! JAPAN Web APIに共通のエラーメッセージおよびコードを返します。
利用制限
日本語形態素解析Web APIは、24時間以内で1つのアプリケーションIDにつき50000件のリクエストが上限となっています。また、1リクエストの最大サイズを100KBに制限 しています。詳しくは「利用制限」をご参照ください。