【问题标题】:WordNet with swi-prolog带有 swi-prolog 的 WordNet
【发布时间】:2021-05-07 22:04:49
【问题描述】:

我正在尝试将 WordNet 包用于 swi-prolog,但安装后似乎无法使用它。我在 MacOS Big Sur 上。我尝试过使用 homebrew 和 macports 进行全新安装,我什至尝试过 docker 容器,但每次都会遇到相同的错误。

这是过程和输出:

derek@Dereks-MBP-2 thelazyreader % swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.2.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- pack_install(wordnet).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Select download location for wordnet@0.9.3
   (1) * https://api.github.com/repos/JanWielemaker/wordnet/zipball/V0.9.3
   (2)   GIT repository at https://github.com/JanWielemaker/wordnet.git
   (3)   Cancel

Your choice? 
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "V0.9.3" was downloaded 46 times
Package:                wordnet
Title:                  Access to WordNet database
Installed version:      0.9.3
Author:                 Jan Wielemaker <jan@swi-prolog.org>
Home page:              https://github.com/JanWielemaker/wordnet
Download URL:           https://github.com/JanWielemaker/wordnet/releases/*.zip
Install "wordnet-0.9.3" (7,451 bytes) Y/n? 
true.

?- pack_list_installed.
Installed packages (1):

i wordnet@0.9.3             - Access to WordNet database
true.

?- use_module(library(wordnet)).
ERROR: source_sink `library(wordnet)' does not exist
ERROR: In:
ERROR:   [19] throw(error(existence_error(source_sink,...),_12810))
ERROR:   [15] '$resolve_source_path'(library(wordnet),_12842,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2318
ERROR:   [14] '$load_file'(library(wordnet),user,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2292
ERROR:    [9] <user>
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- 

如果我在调试模式下运行,这是我得到的输出...

[debug]  ?- use_module(library(wordnet)).
ERROR: source_sink `library(wordnet)' does not exist
ERROR: In:
ERROR:   [19] throw(error(existence_error(source_sink,...),_4386))
ERROR:   [18] '$existence_error'(source_sink,library(wordnet)) at /opt/local/lib/swipl/boot/init.pl:3794
ERROR:   [17] '$abs_file_error'(library(wordnet),[],[file_type(prolog),...]) at /opt/local/lib/swipl/boot/init.pl:1221
ERROR:   [16] absolute_file_name(library(wordnet),_4496,[file_type(prolog),...]) at /opt/local/lib/swipl/boot/init.pl:1157
ERROR:   [15] '$resolve_source_path'(library(wordnet),_4544,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2318
ERROR:   [14] '$load_file'(library(wordnet),user,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2292
ERROR:   [13] '$load_one_file'(library(wordnet),user,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2128
ERROR:   [12] '$load_files'(library(wordnet),user,[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2105
ERROR:   [11] load_files(user:library(wordnet),[if(not_loaded),...]) at /opt/local/lib/swipl/boot/init.pl:2085
ERROR:   [10] use_module(user:library(wordnet)) at /opt/local/lib/swipl/boot/init.pl:2023
ERROR:    [9] <user>

我被难住了。任何关于我可以在哪里看或我可以尝试什么的方向都将受到欢迎。谢谢!

【问题讨论】:

    标签: macos swi-prolog wordnet


    【解决方案1】:

    该模块位于名为wn.pl 的文件中,而不是wordnet.pl

    在我的机器上,运行 pack_install(wordnet). 后,发现:

    $HOME/.local/share/swi-prolog/pack/wordnet
    |
    ├── pack.pl
    ├── prolog
    │   ├── wn.pl
    │   └── wn_portray.pl
    └── README.md
    

    所以:

    ?- use_module(library(wn)).
    

    但是:

    ERROR: Cannot find WordNet data files.  Please set the environment
    ERROR: variable WNDB to point at the directory holding the WordNet files
    

    所以这些文件也需要安装。

    【讨论】:

    • 这是完美的。来自 python 和 js 我假设库名称与安装相同。我从来没有想过要加载特定的文件名。仅供参考,我将 wordnet 文件放在我的项目根目录中,并使用setenv('WNDB', 'wordnet'). 设置环境变量,一切正常。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-06-23
    • 1970-01-01
    • 2016-01-16
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多