R 自然语言处理入门
Kasey Jones
Research Data Scientist
两句话:
去停用词:
更多语料:

library(h2o)
h2o.init()
h2o_object = as.h2o(animal_farm)
使用 h2o 分词:
words <- h2o.tokenize(h2o_object$text_column, "\\\\W+")
words <- h2o.tolower(words)
words = words[is.na(words) || (!words %in% stop_words$word),]
word2vec_model <-
h2o.word2vec(words, min_word_freq = 5, epochs = 5)
min_word_freq:移除出现少于 5 次的词epochs:训练迭代次数h2o.findSynonyms(w2v.model, "animal")
synonym score
1 drink 0.8209088
2 age 0.7952490
3 alcohol 0.7867004
4 act 0.7710537
5 hero 0.7658424
h2o.findSynonyms(w2v.model, "jones")
synonym score
1 battle 0.7996588
2 discovered 0.7944554
3 cowshed 0.7823287
4 enemies 0.7766532
5 yards 0.7679787
R 自然语言处理入门