fcm などの分類手法や、潜在的ディリクレ配分などの他のトピック モデリング手法を適用できるように、いくつかのテキスト ドキュメントを前処理する必要があります。
前処理を少し詳しく説明するには、ストップ ワードを削除し、名詞とキーワードを抽出して、ステミングを実行する必要があります。この目的で使用したコードは次のとおりです。
#--------------------------------------------------------------------------
#Extracting nouns
#--------------------------------------------------------------------------
for i in range (0,len(a)) :
x=a[i]
text=nltk.pos_tag(nltk.Text(nltk.word_tokenize(x)))
for noun in text:
if(noun[1]=="NN" or noun[1]=="NNS"):
temp+=noun[0]
temp+=' '
documents.append(temp)
print documents
#--------------------------------------------------------------------------
#remove unnecessary words and tags
#--------------------------------------------------------------------------
texts = [[word for word in document.lower().split() if word not in stoplist]for document in documents]
allTokens = sum(texts, [])
tokensOnce = set(word for word in set(allTokens) if allTokens.count(word)== 0)
texts = [[word for word in text if word not in tokensOnce]for text in texts]
print texts
#--------------------------------------------------------------------------
#Stemming
#--------------------------------------------------------------------------
for i in texts:
for j in range (0,len(i)):
k=porter.stem(i[j])
i[j]=k
print texts
上記のコードの問題は、
- 名詞とキーワードの抽出に使用される nltk モジュールには、多くの単語がありません。たとえば、一部のドキュメントに対して前処理が実行され、「サチン」などの名前がキーワードとして認識されず、前処理後に見落とされました。
- 語幹が正しくない。ステミングが多すぎて (ネットワークとネットワークからネットへ)、名詞もステミングされる場合があります。
必要な機能のためのより良いモジュールはありますか、または同じモジュールのより良い実装はありますか? 親切に助けて