检查英语词典中是否存在单词 r

checking if word exist in english dictionary r

我正在对多个 resume 执行一些文本分析,以使用 wordcloud 包和 tm 包生成 wordcloud 进行预处理R.

文档语料库

我面临的问题是:

  1. 检查语料库中的单词是否具有某种含义即。它属于英语词典。

  2. 如何同时挖掘/处理多份简历。

  3. 正在检查 tech 术语,例如 r、java、eclipse 等

感谢帮助。

我以前遇到过一些问题,所以分享您的问题的解决方案:

1. 有一个包 qdapDictionaries,它是与 'qdap' 包一起使用的字典和单词列表的集合。

library(qdapDictionaries)

#create custom function
is.word  <- function(x) x %in% GradyAugmented # or use any dataset from package

#use this function to filter words, df = dataframe from corpus
df <- df[which(is.word(df$terms)),]

2. 使用 VCorpus(DirSource(...)) 从包含所有简历的目录创建语料库

resumeDir <- "path/all_resumes/"
myCorpus <- VCorpus(DirSource(resumeDir))

3. 创建您的自定义词典文件,如 my_dict.csv 包含 tech 个术语。

#read custom dictionary
tech_dict <- read.csv("path/to/my_dict.csv", stringsAsFactors = FALSE)
#create tech function
is.tech <- function(x) x %in% tech_dict
#filter
tech_df <- df[which(is.tech(df$terms)),]

希望这对您有所帮助。

您还可以通过以下方式添加新词或合并两个词典:

library(qdapDictionaries)

#create custom function
is.word  <- function(x) x %in% c(GradyAugmented, Dictionary2, "new_word1", "new_word2")

试试 dictionary R package免责声明:我是这个 R 库的维护者)

例子

这里我们得到了单词“hello”的定义

word <- "hello"
word_info <- define(word)

word_info$meanings
## [[1]]
##   partOfSpeech
## 1  exclamation
## 2         noun
## 3         verb
##                                                                                definitions
## 1                used as a greeting or to begin a phone conversation., hello there, Katie!
## 2 an utterance of ‘hello’; a greeting., she was getting polite nods and hellos from people
## 3                            say or shout ‘hello’., I pressed the phone button and helloed