Nlp 我得到';单个';字符作为word2vec genism上的学习词汇作为输出

Nlp 我得到';单个';字符作为word2vec genism上的学习词汇作为输出,nlp,gensim,word2vec,feature-extraction,text-classification,Nlp,Gensim,Word2vec,Feature Extraction,Text Classification,我是word2vec新手,我通过word2vec训练了一个文本文件进行特征提取。当我查看训练过的单词时,我发现它是单个字符而不是单词,我在这里遗漏了什么?有人帮忙吗 我尝试将标记而不是原始文本输入到模型中 import nltk from pathlib import Path data_folder = Path("") file_to_open = data_folder / "test.txt" #read the file file = open(file_to_open , "rt"

我是word2vec新手,我通过word2vec训练了一个文本文件进行特征提取。当我查看训练过的单词时,我发现它是单个字符而不是单词,我在这里遗漏了什么?有人帮忙吗

我尝试将标记而不是原始文本输入到模型中

import nltk

from pathlib import Path
data_folder = Path("")
file_to_open = data_folder / "test.txt"
#read the file
file = open(file_to_open , "rt")
raw_text = file.read()
file.close()

#tokenization
token_list = nltk.word_tokenize(raw_text)

#Remove Punctuation
from nltk.tokenize import punkt
token_list2 = list(filter(lambda token : punkt.PunktToken(token).is_non_punct,token_list))
#upper to lower case
token_list3 = [word.lower() for word in token_list2]
#remove stopwords
from nltk.corpus import stopwords
token_list4 = list(filter(lambda token: token not in stopwords.words("english"),token_list3))

#lemmatization
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
token_list5 = [lemmatizer.lemmatize(word) for word in token_list4]
print("Final Tokens are :")
print(token_list5,"\n")
print("Total tokens : ", len(token_list5))

#word Embedding
from gensim.models import Word2Vec
# train model
model = Word2Vec(token_list5, min_count=2)
# summarize the loaded model

    print("The model is :")
    print(model,"\n")`enter code here`

# summarize vocabulary

    words = list(model.wv`enter code here`.vocab)
    print("The learned vocabulary words are : \n",words)

Output- ['p', 'o', 't', 'e', 'n', 'i', 'a', 'l', 'r', 'b', 'u', 'm', 'h', 'd', 'c', 's', 'g', 'q', 'f', 'w', '-']
Expected -[ 'potenial', 'xyz','etc']

Word2Vec
需要其训练语料库是一个序列,其中每个项目(文本/句子)都是字符串标记的列表

如果您传递的文本是原始字符串,则每个文本都将显示为一个由一个字符标记组成的列表,这将导致您看到的最终词汇表,其中所有学习的“单词”都是单个字符


因此,请仔细查看您的
标记清单5
变量。由于它是一个列表,什么是
令牌\u列表5[0]
?(它是字符串列表吗?)什么是
令牌\u列表5[0][0]
?(这是一个完整的单词吗?

谢谢,我只是列出了一个列表,现在它有了意义:)