Java utility to generate SQL database from WordNet standard database as released by the WordNet Project.
use Wordnet's hypernym / hyponym relationship to suggest alternative
search terms. If you're familiar with Wordnet then you know that for
the word 'dog', one hypernym is 'canine' and a possible hyponym is
'dalmatian'. One important factor is that this is for the first sense
of the word only. Have you thought about how you would choose the
correct sense of a word in order suggest synonyms?
In my sample application I only work with the most popular sense, i.e.
the first sense of a word. I used these postgresql commands to copy
the wordnet database into postgresql and then I formed SQL statements
to pull the relevant hypernyms and hyponyms from the database.
I use Wordnet in a postrgesql database form. You can easily copy
Wordnet into either Postgresql or MySql by downloading the relevant
scripts from http://sourceforge.net/project/showfiles.php?group_id=135112.
Instead of synsets, I use Wordnet's hypernym/hyponym relationship to
suggest narrower or broader search terms. For you to get an idea of
what the SQL for your function may look like, I include the SQL
statements that I have written for my application.
I wrap my SQL statement up in a postgres function so that I call it
with the simple SQL statement: SELECT get_hyponyms_for_nouns('dog');
Here is the function:
CREATE FUNCTION get_hyponyms_for_nouns(text) RETURNS SETOF text AS $$
SELECT lemma FROM word w
JOIN sense s USING (wordid)
JOIN (
SELECT DISTINCT synset2id FROM semlinkref slr JOIN
(
SELECT sense.synsetid FROM sense JOIN word USING (wordid) JOIN synset
ON sense.synsetid = synset.synsetid WHERE lemma = $1 AND rank = 1 AND
categoryid BETWEEN 3 AND 28
)
sense ON slr.synset1id = sense.synsetid WHERE linkid = 2
) syns ON s.synsetid = syns.synset2id
$$ LANGUAGE SQL;
Here, the linkid selects the hyponyms. A linkid of 1 would select the
hypernyms. For synonyms, I think it result in a much shorter SQL
statement.
Nick Rowlands -- nick tocka rowlands at googsmail
by
otis
2008-01-02 17:25
wordnet
·
sql
·
database
·
tool