常見的英文文本處理步驟

常見的英文文本處理流程中都包含哪些步驟

1.導入相應的類庫
import nltk
from nltk import word_tokenize, sent_tokenize
2.導入數據
corpus = open(‘數據路徑’,‘r’).read()
3.對文本進行斷句處理
sentences = sent_tokenize(corpus)
4.對含有的句子列表進行分詞處理
tokenized_words = [nltk.word_tokenize(sentence) for sentence in sentences]
5.過濾詞組
from nltk.corpus import stopwords
stop_words = stopwords.words(‘english’)
filtered_corpus = [w for w in words if not w in stop_words]
6.對詞性進行標註
tagged_words = [nltk.pos_tag(word) for word in tokenized_words]
7.語態還原
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
stemmer.stem(“running”)

中文文本處理與英文文本處理任務的區別
1.如果是在主題聚類、文本分類問題上的時候中文需要做自動分詞,英文是通過間隔來進行分詞的,而中文需要自動分詞,而且很容易產生歧義。
2.中英文在詞法標註的任務上差異,詞法標註:如詞語的含義可以同時表示動詞或名詞如“學習”,熱愛”學習”(名詞也可以是動詞)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章