Two questions on using WordNet with SWI-Prolog
# 1)
I downloaded wn.pl. I look inside the code and saw that on Windows
platforms it looks for the WordNet data files in "C:\Program
Files\WordNet\2.0". So I created and then copied the WordNet 2.0
Prolog data files into that directory.
When I run SWI-Prolog 5.6.17 on my Win2k box and consult wn.pl, it says
it compiled the file and no errors are shown or any other messages. If
I execute a "listing" command however, nothing is displayed.
I then tried calling "load_wordnet" directly from the interpreter and
got the message:
"ERROR: source_sink `prolog_wn(wn_s)' does not exist"
I'm guessing that I'm doing something fairly dumb, I just don't know
what it is. I don't know why the top-level "module" predicate is
running properly. What can I do to fix this?
# 2)
On the WN.PL page there is this comment by Jan:
"It is also desirable to define some additional tables to speed up
finding synsets from words, which is now a non-indexed query."
Pardon my procedural programming tendencies, but is the "indexing"
referred to here Prolog's standard clause indexing, or is it in
reference to a full text index like those in MySQL and other databases?
If it's the former, would simply creating a new Prolog predicate that
has the most frequently used synsets already assembled with their
glosses attached do the trick, assuming the target word is the first
argument in the predicate? (Rather than having to assemble the relevant
information by searching through the synset tables each query.)
Thanks,
Robert
Default is to find wordnet in C:\\Program Files\WordNet\\2.0 and the
Prolog files in C:\\Program Files\WordNet\\2.0\\prolog.
> I'm guessing that I'm doing something fairly dumb, I just don't know
> what it is. I don't know why the top-level "module" predicate is
> running properly. What can I do to fix this?
?- set_prolog_flag(verbose_file_search, true). makes it print messages
while searching for files.
> On the WN.PL page there is this comment by Jan:
>
> "It is also desirable to define some additional tables to speed up
> finding synsets from words, which is now a non-indexed query."
>
> Pardon my procedural programming tendencies, but is the "indexing"
> referred to here Prolog's standard clause indexing, or is it in
> reference to a full text index like those in MySQL and other databases?
> If it's the former, would simply creating a new Prolog predicate that
> has the most frequently used synsets already assembled with their
> glosses attached do the trick, assuming the target word is the first
> argument in the predicate? (Rather than having to assemble the relevant
> information by searching through the synset tables each query.)
By default SWI-Prolog, and most other Prolog systems, index on the first
argument only. This means foo(x, X) is an indexed query and foo(X, x) is
not. The latter results in costly scan. In some cases it can be handy to
have a reverse table as well to speedup access.
Cheers --- Jan
> ?- set_prolog_flag(verbose_file_search, true). makes it print messages
> while searching for files.
Jan,
Once I set verbose messages on I found the problem quickly. On line 66
in WN.PL there is a problem. If you look at the line that executes if
it's a Windows computer and the WNHOME environment variable is not set,
it only has a single backslash between "Program Files" and "WordNet".
Here is the relevant code block from WN.PL:
user:file_search_path(wordnet, WNHOME) :-
( getenv('WNHOME', WNHOME) -> true
; current_prolog_flag(windows, true)
-> WNHOME = 'C:\\Program Files\WordNet\\2.0'
; WNHOME = '/usr/local/WordNet-2.0'
).
This was causing the path to resolve to:
C:\Program FilesWordNet\2
which is not a valid path. Why other Windows users have not seen it is
probably because they have WNHOME set in their environment where I
don't. What's slightly ironic is that it is easy to look at that path
and mistake the leading stroke of the capital 'W' in WordNet as a
backslash.
Everything works now. I look forward to doing fast lookups with
WordNet and SWI-Prolog.
> By default SWI-Prolog, and most other Prolog systems, index on the first
> argument only. This means foo(x, X) is an indexed query and foo(X, x) is
> not. The latter results in costly scan. In some cases it can be handy to
> have a reverse table as well to speedup access.
Are you referring to the tables that are basically synset ID pairs? If
so, then all I would have to do is create complementary tables that
have the synset ID's in reverse order, yes?
BTW, how can I set a spypoint that lets me debug/trace a module as it
is being initialized, so I can trace the initialization goals?
Thanks,
Robert
One more item. I happened to type 'make' into the interpreter after
successfully loading and processing the WordNet files from SWI-Prolog,
via WN.PL. I got the following warnings:
% Scanning references for 3 possibly undefined predicates
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning:
Warning: wordnet:der/2, which is referenced by
Warning: 1-st clause of wordnet:wn_der/2
Warning: wordnet:vgp/2, which is referenced by
Warning: 1-st clause of wordnet:wn_vgp/2
Do I need to be concerned about this?
Thanks,
Robert