0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【自然言語処理】BERTとStanzaのTokenizeの違い

Posted at

はじめに

自然言語処理の手法であるBERTを用いて、神奈川県高校入試の英語問題における出題予測をすることを目的とする。

前回はBERTを用いて、神奈川高校入試英語の問2適語補充の解答を予測した。

【自然言語処理】【BERT】文章の一部を予測する

今回は今後、長文問題の文書分類を行い、今後出題されるカテゴリの予測をしたいため、形態素解析を行うための準備を進める。
その際、BERTを用いたTokenizerと、Stanford大学の自然言語処理プラグラムのStanzaを用いて、どちらが的確にTokenに区分できているかを比較する。

BERTとStanzaの比較

2017年から2020年度まで使用された中学校の教科書に掲載された本文をデータベース化した。学校で採択されている教科書は全部で6冊。それらに掲載された本文をセンテンスとして用いて、分析する。
全てを記載するのは難しいので、結果の一部を記載する。

image.png

違いが見られたセンテンス

全体的に両者ともに適切にTokenに分割できていました。
ただ、以下のようなセンテンスの際に違いをみることができました。

  1. Good morning, Takashi.
  2. But Matsue is a beautiful city.
  3. I want two lemons, three peaches, and two packs of cherries, please.
  4. That’s interesting.
  5. Malala said, “The pen is mightier than the sword,” because she believed in the power of education.

BERT

  1. good morning , tak ##ashi .
  2. but mats ##ue is a beautiful city .
  3. i want two lemon ##s , three peach ##es , and two packs of cher ##ries , please .
  4. that ’ sin ##ter ##est ##ing .
  5. mala ##la said , “ the pen is might ##ier than the sword , ” because she believed in the power of education .

名前や地名、複数形、比較による語形変化が不適切に分割されています。また、That's interestingの文ではいよいよよくわからなくなっています。

Stanza

  1. Good morning , Takashi .
  2. But Matsue is a beautiful city .
  3. I want two lemons , three peaches , and two packs of cherries , please .
  4. That ’s interesting .
  5. 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を用いた方が良いでしょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?