Can anyone walk me through installing and using WordNet via SWI-Prolog? I’ve tried several sources:
None of these actually shows step by step how to install and query the database. Here is a Python example of what I’m looking for GitHub - goodmami/wn: A modern, interlingual wordnet interface for Python. There are many such examples floating around. How would I do it in Prolog? Do I need to consult every single *.pl file individually before issuing a query?
All I can say is that the package is merely a small layer around the DB that provides lazy loading and compilation to .qlf files to make loading a lot faster. This is barely needed on modern hardware with current SWI-Prolog. It used to be important , now it is no longer essential but just a moderate improvement. For the defined relations you must examine the wordnet Prolog documentation. I do not know where it is, but it used to be findable.
From prologdb(5WN) | WordNet : “The files wn_ * .pl contain the WordNet database in a prolog-readable format.”
So, does this mean I need to type consult(filename) for each Prolog file in the distribution (see photo below) or put all those consults at the top of a file?
@CapelliC , maybe my Prolog environment is the problem? I usually run SWI-Prolog via Visual Studio Code’s VSC-Prolog extension. When I open wordnet.pl and right-click to “load document” into SWI-Prolog, I see this in the interpreter:
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:132:48: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:144:29: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:157:92: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:166:34: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:192:27: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:200:19: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:209:49: Syntax error: Operator expected
ERROR: d:/documents/programming/prolog/wn-swipl-master/wordnet.pl:247:24: Syntax error: Operator expected
ERROR: Exported procedure wordnet:load_relation/2 is not defined
ERROR: Exported procedure wordnet:verb_tenses_load/0 is not defined
ERROR: Exported procedure wordnet:make_qlf_full/0 is not defined
ERROR: Exported procedure wordnet:make_qlf_full/1 is not defined
ERROR: Exported procedure wordnet:load_full_db/0 is not defined
ERROR: Exported procedure wordnet:compare_subset/0 is not defined
ERROR: Exported procedure wordnet:load_all_relations/1 is not defined
true.
?- gtrace,time(load_wn3_relations).
% load_wn3_relations
% schema_wn3_table(_8646,_8648)
% path_wn3_file(s,_9254)
% path_wn3_files(_9356)
% Compiling s->C:\Users\Carlo\test\wordnet\wn-swipl\WN/wn_s.qlf
Warning: c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:184585:
Warning: Clauses of wn3_db:s/6 are not together in the source-file
Warning: Earlier definition at c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:1
Warning: Current predicate: wn3_db:s/4
Warning: Use :- discontiguous wn3_db:s/6. to suppress this message
Warning: c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:184586:
Warning: Clauses of wn3_db:s/4 are not together in the source-file
Warning: Earlier definition at c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:184584
Warning: Current predicate: wn3_db:s/6
Warning: Use :- discontiguous wn3_db:s/4. to suppress this message
Warning: c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:184587:
Warning: Clauses of wn3_db:s/6 are not together in the source-file
Warning: Earlier definition at c:/users/carlo/test/wordnet/wn-swipl/wn/wn_s.pl:1
Warning: Current predicate: wn3_db:s/4
Warning: Use :- discontiguous wn3_db:s/6. to suppress this message
% path_wn3_file(sk,_20248)
% path_wn3_files(_20350)
% Compiling sk->C:\Users\Carlo\test\wordnet\wn-swipl\WN/wn_sk.qlf
% path_wn3_file(g,_22738)
...
% path_wn3_files(_6252)
% Compiling fr->C:\Users\Carlo\test\wordnet\wn-swipl\WN/wn_fr.qlf
% 130,646,623 inferences, 40.375 CPU in 41.123 seconds (98% CPU, 3235830 Lips)
...
I’m fixing the wn3 key to default, will push right now… edit
Note that the timing of 41 sec is wrong, I started with gtrace, the interactive debugger… it’s 18 sec really.