nlintz / TensorFlow-Tutorials

Simple tutorials using Google's TensorFlow Framework
6k stars 1.51k forks source link

08_word2vec.py #43

Closed forfish closed 8 years ago

forfish commented 8 years ago

hello! I'm looking at https://github.com/nlintz/TensorFlow-Tutorials/blob/master/08_word2vec.py. But in this case, It puts all words like this:

Sample sentences

sentences = ["the quick brown fox jumped over the lazy dog", "I love cats and dogs", "we all love cats and dogs", "cats and dogs are great", "sung likes cats", "she loves dogs", "cats can be very independent", "cats are great companions when they want to be", "cats are playful", "cats are natural hunters", "It's raining cats and dogs", "dogs and cats love sung"]

sentences to words and count

I want to put the sentences in a file:like file.txt, and program can read from the file. What shuold I do?

hunkim commented 8 years ago

I think you can use simple python file reading something like this:

with open(fname) as f:
    content = f.readlines()

http://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list-with-python

Let us know if you need more help on this.

forfish commented 8 years ago

thanks @hunkim it work