from gensim.models import Word2Vecfrom nltk.toke(◎_◎;)nize import sent_tokenize, word_tokenize假設我們有一個(gè)包含(′▽?zhuān)?多個(gè)句子的文本text = "This is the first sentence. This is the seco(⊙_⊙)nd sentence."將文本分割成句??子和單詞sentences = sent??_token(′?ω?`)ize(text)words = [word_tokenize(s) for s in sentences]訓練Word2Vec模型model = Word2Vec(words, min_count=1)將句子轉換為向量sentence_vector = model.wv['sentence']print(sentence_vector) # 輸出:[(′?`*)0.00076898 0.00019995 0.000??24988 ...]