自然言語処理2

9632 ワード

パージ


精製:ノイズ除去
正規化:他の単語を同じ単語に結合する方法を示します.

ルールベースのタグと他の単語の統合

USA, US

大文字と小文字の統合


ランダム統合はXの例であり,米国と米国では異なる.「会社名は、人名のように大文字で残す」というものもあります.
大文字または小文字ではなく、すべてのタグを部分タグに置き換える方法もあります.

不要な言葉を消す


自然言語のほかに、何の意味もない文字や、分析の目的に合わない不要な単語を削除しなければならない.
非常用語、出現頻度の低い語、長さの短い語などを取り除く.

正規表現


語幹抽出(Stemming)タイトル抽出(Lemmatization)


異なる単語ですが、1つの単語で一般化できれば、単語数を減らすために一般化します.

タイトル抽出


主題語(Lemma):基本辞書単語
are is amのタイトル=>be
形態素:有意義な最小単位
1)語幹:単語の意味を含む核心部分
2)接尾辞(接尾辞):単語に意味を付加する部分
dogs -> dog = 어간, s = 접사
NLTKはWord NetLemmatizerを使用
from nltk.stem import WordNetLemmatizer
n=WordNetLemmatizer()
words=['policy', 'doing', 'organization', 'have', 'going', 'love', 'lives', 'fly', 'dies', 'watched', 'has', 'starting']
print([n.lemmatize(w) for w in words])
#['policy', 'doing', 'organization', 'have', 'going', 'love', 'life', 'fly', 'dy', 'watched', 'ha', 'starting']
引用者は語類情報を知ってこそ正しい結果を得ることができる.ない場合、diesはdyhasをhaの未知の単語として出力します.
n.lemmatize('dies', 'v')
#->'die'

語幹抽出と見出し語抽出の違い


トピック語はコンテキストを考慮して抽出され、単語の語類情報を保持します.
語幹抽出は語類情報を保持しない.(多くの場合、事前に存在しない単語です.
Stemming
---------
am -> am
the going -> the go
having -> hav

Lemmatization
--------------
am -> be
the going -> the going
having -> have

語幹抽出(Stemming)


複数のアルゴリズムが存在する
ポッターアルゴリズム
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
s = PorterStemmer()
text="This was not the map we found in Billy Bones's chest, but an accurate copy, complete in all things--names and heights and soundings--with the single exception of the red crosses and the written notes."
words=word_tokenize(text)
print(words)

#['This', 'was', 'not', 'the', 'map', 'we', 'found', 'in', 'Billy', 'Bones', "'s", 'chest', ',', 'but', 'an', 'accurate', 'copy', ',', 'complete', 'in', 'all', 'things', '--', 'names', 'and', 'heights', 'and', 'soundings', '--', 'with', 'the', 'single', 'exception', 'of', 'the', 'red', 'crosses', 'and', 'the', 'written', 'notes', '.']

print([s.stem(w) for w in words])
#['thi', 'wa', 'not', 'the', 'map', 'we', 'found', 'in', 'billi', 'bone', "'s", 'chest', ',', 'but', 'an', 'accur', 'copi', ',', 'complet', 'in', 'all', 'thing', '--', 'name', 'and', 'height', 'and', 'sound', '--', 'with', 'the', 'singl', 'except', 'of', 'the', 'red', 'cross', 'and', 'the', 'written', 'note', '.']
ALIZE -> AL
ANCEの削除->
ICAL -> IC
formalize -> formal
allowance -> allow
electrical -> electric
ランケストタイマ
from nltk.stem import LancasterStemmer
l=LancasterStemmer()
words=['policy', 'doing', 'organization', 'have', 'going', 'love', 'lives', 'fly', 'dies', 'watched', 'has', 'starting']
print([l.stem(w) for w in words])

#['policy', 'doing', 'org', 'hav', 'going', 'lov', 'liv', 'fly', 'die', 'watch', 'has', 'start']
各種アルゴリズムを用いて,適切な使用を判断する.

韓国語


五言九品
|言|語類|
|---|---|
|体詞|名詞、代名詞、数詞|
|修飾語|冠詞、副詞|
|関係|調査|
|独立言|感嘆詞|
|述語|動詞、形容詞|
活用する
語幹語幹の形も変わります.(漕ぐ、漕ぐ、漕ぐ、漕ぐ)
語尾(ending):龍言の語幹の後ろに、活用によって変化する部分.

ルールの使用


語幹が母をとるとき、語幹の様子が固定されているとき
잡/어간 + 다/어미 => 잡다
어미를 단순 분리 하면 어간 추출 가능

不規則な使用


語幹が語尾を取ると,語幹の形態が変化したり,語幹が語尾を取る特殊性がある.
예를 들어 ‘듣-, 돕-, 곱-, 잇-, 오르-, 노랗-’ 등이 ‘듣/들-, 돕/도우-, 곱/고우-, 잇/이-, 올/올-, 노랗/노라-’와 같이 어간의 형식이 달라지는 일이 있거나 ‘오르+ 아/어→올라, 하+아/어→하여, 이르+아/어→이르러, 푸르+아/어→푸르러’와 같이 일반적인 어미가 아닌 특수한 어미를 취하는 경우 불규칙활용을 하는 예에 속합니다.

이 경우에는 어간이 어미가 붙는 과정에서 어간의 모습이 바뀌었으므로 단순한 분리만으로 어간 추출이 되지 않고 좀 더 복잡한 규칙을 필요로 합니다.

아래의 링크는 다양한 불규칙 활용의 예를 보여줍니다.
링크 : https://namu.wiki/w/한국어/불규칙%20활용