首页 > 解决方案 > 从词形还原词典中删除单词/更新文本词干中的词形词典

问题描述

我正在使用 textstem 包在某些回复中对单词进行词形还原。然而,有一个词(spotting)我不想被包括在内,并简化为“spot”。我希望它保持斑点。我怎么能做到这一点?我需要制作自定义词典吗?正在做:

lemmatize_strings(df, dictionary = lexicon::hash_lemmas)

标签: rnlpsentiment-analysisstemminglemmatization

解决方案


您可以创建自己的字典,在其中删除令牌spotting

# hash_lemmas is a datatable, so you can use column name token instead hash_lemmas$token
my_lex <- lexicon::hash_lemmas[!token == "spotting", ]

df_lemmatized <- lemmatize_strings(df, dictionary = my_lex)

或者,如果您想在不创建自己的词典的情况下这样做:

df_lemmatized <- lemmatize_strings(df, dictionary = lexicon::hash_lemmas[!token == "spotting", ])

推荐阅读