【问题标题】:checking if word exist in english dictionary r检查英语词典中是否存在单词
【发布时间】:2017-12-11 07:27:43
【问题描述】:

我正在对多个 resume 执行一些文本分析,以使用 wordcloud 包和 tm 包生成 wordcloud,用于预处理 R 中的文档语料库。

我面临的问题是:

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

  2. 如何一起挖掘/处理多份简历。

  3. 检查 tech 术语,如 r、java、eclipse 等。

感谢您的帮助。

【问题讨论】:

  • 您是否尝试过使用客户 dictionary 并检查其中的字词,例如简历中的技术术语
  • @ParthChaudhary,自定义dictionarytech 术语有好处,但对检查英文单词没有效果

标签: r shiny text-mining


【解决方案1】:

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

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. 创建您的自定义字典文件,例如包含tech 术语的my_dict.csv

#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)),]

希望这会有所帮助。

【讨论】:

  • 如果tech 的字数较多,而is.word 的计算时间很长,该怎么办?
  • 可以尝试使用lapply等分组函数来提高性能。
  • 大家好,我有一个与讨论相关的问题。我有一个城市和村庄名称的列表(总共约 8000 个)。在列表中的城市可能有英国/美国血统的名字,比如“Johnsonville”或“Washington”,而其他完全不同的名字,比如“Lagos”。有没有办法检测哪些是英文/美式名称,哪些是与英文/美式不同的名称?
【解决方案2】:

试试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

【讨论】:

  • @tjebo 谢谢。这不是巧合,我把它放在一起是为了我今天下午正在做的事情。我现在将编辑答案
  • @tjebo 是的,4 小时 50 米(是的,我计时了,很伤心啊……)
  • 不,令人印象深刻!
【解决方案3】:

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

library(qdapDictionaries)

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

【讨论】:

    猜你喜欢
    • 2016-11-19
    • 1970-01-01
    • 2014-04-06
    • 2012-03-03
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    • 2016-06-14
    相关资源
    最近更新 更多