私は現在、word2vecモデルで次のようにユニグラムを使用しています。word2vecのbigramsとtrigramsを取得するGensim
def review_to_sentences(review, tokenizer, remove_stopwords=False):
#Returns a list of sentences, where each sentence is a list of words
#
#NLTK tokenizer to split the paragraph into sentences
raw_sentences = tokenizer.tokenize(review.strip())
sentences = []
for raw_sentence in raw_sentences:
# If a sentence is empty, skip it
if len(raw_sentence) > 0:
# Otherwise, call review_to_wordlist to get a list of words
sentences.append(review_to_wordlist(raw_sentence, \
remove_stopwords))
#
# Return the list of sentences (each sentence is a list of words,
# so this returns a list of lists
return sentences
しかし、私は重要なbigramsとtrigramsを私のデータセットで見逃してしまいます。
E.g.,
"team work" -> I am currently getting it as "team", "work"
"New York" -> I am currently getting it as "New", "York"
したがって、重要なバイグラムやトリグラムなどをデータセットに取り込んで、word2vecモデルに入力したいと考えています。
私はwordvecの新機能であり、それを行う方法に苦労しています。私を助けてください。
いくつかのコードとより良い例を示します。表示している例では、最初の行に入力したデータは反映されません – AK47
完了!質問が更新されました。この問題を解決するために私を助けてください。 –