How to load sentences into Python gensim?

后端 未结 2 856
天涯浪人
天涯浪人 2021-02-04 08:30

I am trying to use the word2vec module from gensim natural language processing library in Python.

The docs say to initialize the model:



        
2条回答
  •  感情败类
    2021-02-04 09:01

    A list of utf-8 sentences. You can also stream the data from the disk.

    Make sure it's utf-8, and split it:

    sentences = [ "the quick brown fox jumps over the lazy dogs",
    "Then a cop quizzed Mick Jagger's ex-wives briefly." ]
    word2vec.Word2Vec([s.encode('utf-8').split() for s in sentences], size=100, window=5, min_count=5, workers=4)
    

提交回复
热议问题