问题描述
我刚刚注意到在更新到 tm
v. 0.5-10 之后,函数 Dictionary()
不再受支持.这是一个错误吗?或者它被弃用了?我想使用另一个函数来创建字典吗?
I just noticed that after updating to tm
v. 0.5-10 the function Dictionary()
is not supported anymore. Is this an mistake? Or was it deprecated? Am I suppose to use another function to create a dictionary?
既然我现在有很多行代码需要修改,那么在不设计所有内容的情况下继续进行的最佳方法是什么?
Since I have many lines of code to emend now, what's the best way to proceed without engineering everything?
推荐答案
正如 IShouldBuyABoat 所说,你没有给我们任何关于你如何使用 Dictionary
的线索,所以我们不能真正给出您有任何具体答案(请使用更多详细信息更新您的问题).
As IShouldBuyABoat says, you haven't given us any clue about how you're using Dictionary
so we can't really give you any specific answers (do update your question with more details).
无论如何,您关于如何更新我的代码"的问题的答案可能是只需删除 Dictionary
就可以了",正如您在此处看到的:
In any case, the answer your question of 'how to update my code' is probably 'just delete Dictionary
and it should be fine', as you can see here:
library(tm)
data(crude)
找出 Dictionary
在 tm
包的早期版本中做了什么:
Find out what Dictionary
did in earlier versions of the tm
package:
methods(Dictionary)
getAnywhere(Dictionary.DocumentTermMatrix)
# function(x) structure(Terms(x), class = c("Dictionary", "character"))
getAnywhere(Dictionary.character)
# function (x) structure(x, class = c("Dictionary", "character"))
无论如何,这是一个毫无意义的功能,删除它似乎很明智.但是如何更新依赖于它的代码?
Kind of a pointless function anyway, seems quite sensible to remove it. But how to update your code that depended on it?
你可能像这样使用过Dictionary
:
myDictionary <- Dictionary(c("some", "tokens", "that", "I", "am", "interested", "in"))
inspect(DocumentTermMatrix(crude, list(dictionary = myDictionary)))
现在此函数不再可用,您可以改为使用字符向量来执行此操作:'
Now that this function is not longer available, you'd do this instead, using a character vector: '
myTerms <- c("some", "tokens", "that", "I", "am", "interested", "in")
inspect(DocumentTermMatrix(crude, list(dictionary = myTerms)))
这两个示例的输出是相同的,第一个使用 tm
版本 0.5-9,第二个使用版本 0.5-10
The output for these two examples is identical, first one was using tm
version 0.5-9 and the second with version 0.5-10
NEWS 中使用 Terms
的说明是,如果您想获取文档术语矩阵中的所有单词,就像这样
The instruction in the NEWS to use Terms
is if you want to get all the words in a document term matrix, like so
Terms(DocumentTermMatrix(crude))
如果这些都没有帮助你,那么你需要提供更多关于你正在尝试做的事情的细节.
If none of that helps you then you'll need to supply more detail about what you're trying to do.
这篇关于tm 包中不再支持 Dictionary().如何修改代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!