RUVIDEO
Поделитесь видео 🙏

R tutorial: Cleaning and preprocessing text

📁 Обучение 👁️ 16 📅 03.12.2023

Learn more about text mining with R: https://www.datacamp.com/courses/intro-to-text-mining-bag-of-words

Now that you have a corpus, you have to take it from the unorganized raw state and start to clean it up. We will focus on some common preprocessing functions. But before we actually apply them to the corpus, let’s learn what each one does because you don’t always apply the same ones for all your analyses.

Base R has a function tolower. It makes all the characters in a string lowercase. This is helpful for term aggregation but can be harmful if you are trying to identify proper nouns like cities.

The removePunctuation function...well it removes punctuation. This can be especially helpful in social media but can be harmful if you are trying to find emoticons made of punctuation marks like a smiley face.

Depending on your analysis you may want to remove numbers. Obviously don’t do this if you are trying to text mine quantities or currency amounts but removeNumbers may be useful sometimes.

The stripWhitespace function is also very useful. Sometimes text has extra tabbed whitespace or extra lines. This simply removes it.

A very important function from tm is removeWords. You can probably guess that a lot of words like "the" and "of" are not very interesting, so may need to be removed.

All of these transformations are applied to the corpus using the tm_map function. This text mining function is an interface to transform your corpus through a mapping to the corpus content. You see here the tm_map takes a corpus, then one of the preprocessing functions like removeNumbers or removePunctuation to transform the corpus. If the transforming function is not from the tm library it has to be wrapped in the content_transformer function. Doing this tells tm_map to import the function and use it on the content of the corpus.

The stemDocument function uses an algorithm to segment words to their base. In this example, you can see "complicatedly", "complicated" and "complication" all get stemmed to "complic". This definitely helps aggregate terms. The problem is that you are often left with tokens that are not words! So you have to take an additional step to complete the base tokens. The stemCompletion function takes as arguments the stemmed words and a dictionary of complete words. In this example, the dictionary is only "complicate", but you can see how all three words were unified to "complicate". You can even use a corpus as your completion dictionary as shown here.

There is another whole group of preprocessing functions from the qdap package which can complement these nicely. In the exercises, you will have the opportunity to work with both tm and qdap preprocessing functions, then apply them to a corpus.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «R tutorial: Cleaning and preprocessing text», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.