Created
October 20, 2015 11:53
-
-
Save mattiasostmar/f6972d9935c9d9bbc261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import regex | |
import logging | |
import gensim | |
from gensim import corpora, models | |
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) | |
class MySentences(object): | |
def __init__(self, fname): | |
self.fname = fname | |
def __iter__(self): | |
for line in open(self.fname): | |
cleaned = regex.sub(r"[\:\!\?\.\,]","",line) | |
tokens = cleaned.split() | |
yield tokens | |
sentences = MySentences("/Users/mos/Downloads/SOUtxtAllBigFile.txt") | |
model = models.Word2Vec(sentences,size=200,window=5,min_count=30,workers=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment