Какой лучший подход использовать библиотеку tm для сравнения текста с положительным списком опорных слов и возврата количества положительных слов? Я хочу чтобы иметь возможность вернуть сумму положительных слов в справочный текст.R tm Пакет: Как сравнить текст с положительным списком справочных слов и возвратить количество положительных словных событий
Вопрос: Каков наилучший способ сделать это?
Например:
positiveword_list <- c("happy", "great", "fabulous", "great")
текст ссылки:
exampleText <- c("ON A BRIGHT SPRING DAY in the year 1677, “the good ship
Kent,” Captain Gregory Marlowe, Master, set sail from the great docks of London. She carried 230 English Quakers, outward bound for a new home in British North America. As the ship dropped down the Thames she was hailed by King Charles II, who happened to be sailing on the river. The two vessels made a striking contrast. The King’s yacht was sleek and proud in gleaming paintwork, with small cannons peeping through wreaths of gold leaf, a wooden unicorn prancing high above her prow, and the royal arms emblazoned upon her stern. She seemed to dance upon the water— new sails shining white in the sun, flags streaming bravely from her mastheads, officers in brilliant uniform, ladies in court costume, servants in livery, musicians playing, and spaniels yapping. At the center of attention was the saturnine figure of the King himself in all his regal splendor. On the other side of the river came the emigrant ship. She would have been bluff-bowed and round-sided, with dirty sails and a salt-stained hull, and a single ensign drooping from its halyard. Her bulwarks were lined with apprehensive passengers— some dressed in the rough gray homespun of the northern Pen-nines, others in the brown drab of London tradesmen, several in the blue suits of servant-apprentices, and a few in the tattered motley of the country poor.")
Вот некоторые фон:
То, что я пытаюсь сделать, это подсчитать количество положительных работ и хранить счетчик в кадре данных как новый столбец.
count <- length(which(lapply(positiveword_list, grepl, x = exampleText]) == TRUE))
таким образом:
dataframeIn %>% mutate(posCount <- (length(which(lapply(positiveword_list, grepl, x = text) == TRUE))))
где текст колонки в dataFrameIn (т.е. dataFrameIn $ текста)
Ken, Спасибо за информацию - это здорово. Я действительно ценю твою помощь. Библиотека quanteda - именно то, что я искал. Perfecto! – Technophobe01
@PeteJarvis приятно слушать. Мы активно его разрабатываем, поэтому приветствуем любые отзывы/запросы/сообщения об ошибках. –
Ken, отлично, это будет очень полезно для тестирования масштабирования R на более сложных проблемах анализа языка. В северном направлении Мы разработали механизм создания совокупных компьютеров в программном обеспечении. Подумайте о 5 компьютерных системах, которые отображаются как один компьютер. То есть Одна операционная система (Centos), работающая поверх 5 узлов 1T.5b физической DRAM, масштабируется до 100Tb Ram и т. Д. Я занят написанием и нахождением примеров, которые могут использовать системы :-) Будьте осторожны и благодарны за указатели. – Technophobe01