はじめに
自然言語処理の手法であるBERTを用いて、神奈川県高校入試の英語問題における出題予測をすることを目的とする。
前回はBERTを用いて、神奈川高校入試英語の問2適語補充の解答を予測した。
今回は今後、長文問題の文書分類を行い、今後出題されるカテゴリの予測をしたいため、形態素解析を行うための準備を進める。
その際、BERTを用いたTokenizerと、Stanford大学の自然言語処理プラグラムのStanzaを用いて、どちらが的確にTokenに区分できているかを比較する。
BERTとStanzaの比較
2017年から2020年度まで使用された中学校の教科書に掲載された本文をデータベース化した。学校で採択されている教科書は全部で6冊。それらに掲載された本文をセンテンスとして用いて、分析する。
全てを記載するのは難しいので、結果の一部を記載する。
違いが見られたセンテンス
全体的に両者ともに適切にTokenに分割できていました。
ただ、以下のようなセンテンスの際に違いをみることができました。
- Good morning, Takashi.
- But Matsue is a beautiful city.
- I want two lemons, three peaches, and two packs of cherries, please.
- That’s interesting.
- Malala said, “The pen is mightier than the sword,” because she believed in the power of education.
BERT
- good morning , tak ##ashi .
- but mats ##ue is a beautiful city .
- i want two lemon ##s , three peach ##es , and two packs of cher ##ries , please .
- that ’ sin ##ter ##est ##ing .
- mala ##la said , “ the pen is might ##ier than the sword , ” because she believed in the power of education .
名前や地名、複数形、比較による語形変化が不適切に分割されています。また、That's interestingの文ではいよいよよくわからなくなっています。
Stanza
- Good morning , Takashi .
- But Matsue is a beautiful city .
- I want two lemons , three peaches , and two packs of cherries , please .
- That ’s interesting .
- Malala said , “ The pen is mightier than the sword , ” because she believed in the power of education .
BERTのTokenizerではうまく区分できなかったところがStanzaでは適切に分割できています。
特に日本語の名前や地名は明確に違いが出ました。
結果
上記から、現状のTokenへの分割ではStanzaを用いた方が良さそうです。
気になるのはBERTのToken分割では比較の語形変化も分割対象になっていたことです。
おそらく、文章の特徴を抽出するのにそのような語形変化は影響が弱いということが考えられます。
その為、単語の分析や出題されている文法の分析をする際にはStanzaを用いた方が良いでしょう。