如何使用quanteda对像makes这样的单词进行词汇化,使其成为make。
在Python语言中,可以使用NLTK WordNet Lemmatizer
发布于 2020-06-12 01:52:47
词干分析可以使用tokens_wordstem或dfm_wordstem来完成。但是词汇化需要用tokens_replace来完成。注意,在词汇化"am“时,2之间的差异被改为"be”,因为这是引理。
在dictionary包中有一个名为hash_lemmas的表,您可以将其用作字典。quanteda中没有默认的引理函数。
txt <- c("I am going to lemmatize makes into make, but not maker")
library(quanteda)
# stemming
tokens_wordstem(tokens(txt))
Tokens consisting of 1 document.
text1 :
[1] "I" "am" "go" "to" "lemmat" "make" "into" "make" "," "but" "not" "maker"
# lemmatizing using lemma table
tokens_replace(tokens(txt), pattern = lexicon::hash_lemmas$token, replacement = lexicon::hash_lemmas$lemma)
Tokens consisting of 1 document.
text1 :
[1] "I" "be" "go" "to" "lemmatize" "make" "into" "make" "," "but" "not"
[12] "maker" 其他引理选项是将spacyr与quanteda结合使用。请参见使用spacyr的教程。
或者,您可以首先使用udpipe来获取引理,然后使用quanteda的tokens_replace或dfm_replace函数。
https://stackoverflow.com/questions/62329148
复制相似问题