如何从R中的文本向量中提取形容词和副词 [英] How to extract adjectives and adverbs from vector of text in R

查看:76
本文介绍了如何从R中的文本向量中提取形容词和副词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从向量中提取形容词和副词,有什么办法吗?

I want to extract adjectives and adverbs from a vector, is there any way to do this ?

input <- "It's a good phone" 

预期输出:"good"

推荐答案

您可以使用 tidytext :

library(tidytext)
library(tidyverse)
unnest_tokens(tibble(txt="It's a good phone"),word, txt) %>%
  left_join(parts_of_speech) %>%
  filter(pos %in% c("Adjective","Adverb")) %>%
  pull(word) %>%
  unique
# [1] "good"

这篇关于如何从R中的文本向量中提取形容词和副词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆