У меня есть список фраз и состав документов. В корпусе есть 100k + фраз и документы 60k +. Фразы могут/не могут присутствовать в корпусе. Я с нетерпением жду, чтобы найти термин частота каждой фразы, присутствующей в корпусе.Сопоставление списка фраз с корпусом документов и частотой повторной фразы
Пример набора данных:
Phrases <- c("just starting", "several kilometers", "brief stroll", "gradually boost", "5 miles", "dark night", "cold morning")
Doc1 <- "If you're just starting with workout, begin slow."
Doc2 <- "Don't jump in brain initial and then try to operate several kilometers without the need of worked out well before."
Doc3 <- "It is possible to end up injuring on your own and carrying out more damage than good."
Doc4 <- "Instead start with a brief stroll and gradually boost the duration along with the speed."
Doc5 <- "Before you know it you'll be working 5 miles without any problems."
Я новичок в текст аналитики в R и подошли к этой проблеме на линиях решения Тайлер RINKER к этому R Text Mining: Counting the number of times a specific word appears in a corpus?.
Вот мой подход до сих пор:
library(tm)
library(qdap)
Docs <- c(Doc1, Doc2, Doc3, Doc4, Doc5)
text <- removeWords(Docs, stopwords("english"))
text <- removePunctuation(text)
text <- tolower(text)
corp <- Corpus(VectorSource(text))
Phrases <- tolower(Phrases)
word.freq <- apply_as_df(corp, termco_d, match.string=Phrases)
mcsv_w(word.freq, dir = NULL, open = T, sep = ", ", dataframes = NULL,
pos = 1, envir = as.environment(pos))
Когда я экспорт результатов в CSV-файл, он только дает мне, присутствует ли в какой-либо из документации или нет фразы 1.
Я ожидаю выход, как показано ниже (за исключением несовпадающих фраз):
Docs Phrase1 Phrase2 Phrase3 Phrase4 Phrase5
1 0 1 2 0 0
2 1 0 0 1 0