Ruby-wordnet - 无法创建词典
我正在尝试 Ruby-Wordnet。我可以在控制台中要求它,但是当我尝试创建词典时,出现错误:
$ lex = WordNet::Lexicon.new
TypeError: can't convert Symbol into Integer
from /Users/user1/.rvm/gems/ruby-1.9.3-p0/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:93:in `%'
I am trying out Ruby-Wordnet. I can require it in console, but then when I try to create a lexicon, I get an error:
$ lex = WordNet::Lexicon.new
TypeError: can't convert Symbol into Integer
from /Users/user1/.rvm/gems/ruby-1.9.3-p0/gems/wordnet-0.0.5/lib/wordnet/lexicon.rb:93:in `%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在尝试安装 wordnet gem 时遇到了同样的问题。它似乎是在 $DEBUG 开启时运行时触发的。
我不得不花很多功夫才能让它正常运行。我在这个要点中收集了我所采取的步骤,安装 WordNet、bdb gem、wordnet gem 并运行转换脚本。
https://gist.github.com/1779371
如果您已经运行了其他所有内容并且只想克服您看到的这个错误应该能够像这样初始化它。这绕过了 lexicon.rb 中第 93 行的错误。
I ran into the same problem when trying to install the wordnet gem. It seems to be triggered when running with $DEBUG on.
I had to fiddle quite a bit to get it running properly. I collected the steps I took, installing WordNet, the bdb gem, the wordnet gem and running the conversion script, in this gist.
https://gist.github.com/1779371
If you already have everything else running and just want to overcome this error that you're seeing you should be able to initialize it like this instead. This bypasses the bug on line 93 in lexicon.rb.
如果需要它然后尝试创建一个新实例实际上是您在收到错误之前所做的一切,那么问题几乎肯定与您如何设置数据库有关 需要工作。您确实设置了数据库,对吗?另外,根据您的设置,从控制台运行它(您的 $PATH 可能有所不同)可能会导致数据库不可见;尝试从实际文件运行它。
If requiring it and then attempting to create a new instance is really all you're doing before getting the error, the issue is almost certainly with how you've set up the database it needs to work. You did set up the database, right? Also, depending on your setup, it could be that running it from the console (where your $PATH is likely somewhat different) is causing the database to be invisible; try running it from an actual file.