Getting started with WordNet

About

is a lexical database for English:

WordNet® is a large lexical database of English. Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets), each expressing a distinct concept. Synsets are interlinked by means of conceptual-semantic and lexical relations. The resulting network of meaningfully related words and concepts can be navigated with the browser. WordNet is also freely and publicly available for download. WordNet’s structure makes it a useful tool for computational linguistics and natural language processing.

Install WordNet

We can download WordNet related source and data from the official website:

The most recent Windows version of WordNet is 2.1, released in March 2005. Version 3.0 for Unix/Linux/Solaris/etc. was released in December, 2006. Version 3.1 is currently availalbe only online.

For example, we will use WordNet3.0 as the stable release version, which now supports UNIX-like systems, including Linux, Mac OS X and Solaris. Before install WordNet from the source code, we should download it first. Download a tar-gzipped version:

Install WordNet on Unbuntu 16.04:

tar -zxvf WordNet-3.0.tar.gz
cd WordNet-3.0/
./configure

After configure in WordNet3.0, we met a configure problem:


checking for style of include used by make… GNU
checking dependency style of gcc… gcc3
checking for Tcl configuration… configure: WARNING: Can’t find Tcl configuration definitions

Install tcl-dev on Ubuntu can resolve this problem:

sudo apt-get install tcl-dev

Configure wordnet again:

./configure

But met another tk problem:


checking for style of include used by make… GNU
checking dependency style of gcc… gcc3
checking for Tcl configuration… found /usr/lib/tclConfig.sh
checking for Tk configuration… configure: WARNING: Can’t find Tk configuration definitions

Install tk-dev on Ubuntu too:

sudo apt-get install tk-dev

Finally configure it successfully:

./configure

WordNet is now configured

Installation directory: /usr/local/WordNet-3.0

To build and install WordNet:

make
make install

To run, environment variables should be set as follows:

PATH – include ${exec_prefix}/bin
WNHOME – if not using default installation location, set to /usr/local/WordNet-3.0

See INSTALL file for details and additional environment variables
which may need to be set on your system.

Now make it:

make

But met a compile error:

……
then mv -f “.deps/wishwn-stubs.Tpo” “.deps/wishwn-stubs.Po”; else rm -f “.deps/wishwn-stubs.Tpo”; exit 1; fi
stubs.c: In function ‘wn_findvalidsearches’:
stubs.c:43:14: error: ‘Tcl_Interp {aka struct Tcl_Interp}’ has no member named ‘result’
interp -> result =

The reason is that “Tcl 8.5 deprecated interp->result and Tcl 8.6+ removed it.”, you should modified the original wordnet code:

sudo vim src/stubs.c

and add a line “#define USE_INTERP_RESULT 1” before “include tcl.h”, like this:

#ifdef _WINDOWS
#include <windows.h>
#endif
 
#define USE_INTERP_RESULT 1
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tcl.h>
#include <tk.h>
#include <wn.h>
......

Make it again:

make

make all-recursive
make[1]: Entering directory ‘/home/textminer/wordnet/WordNet-3.0’
……
gcc -g -O2 -o wishwn wishwn-tkAppInit.o wishwn-stubs.o -L../lib -lWN -L/usr/lib/x86_64-linux-gnu -ltk8.6 -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -lX11 -lXss -lXext -lXft -lfontconfig -lfreetype -lfontconfig -lpthread -ldl -lz -lpthread -lieee -lm
make[2]: Leaving directory ‘/home/textminer/wordnet/WordNet-3.0/src’
make[2]: Entering directory ‘/home/textminer/wordnet/WordNet-3.0’
make[2]: Leaving directory ‘/home/textminer/wordnet/WordNet-3.0’
make[1]: Leaving directory ‘/home/textminer/wordnet/WordNet-3.0’

Finally “make install” with it:

sudo make install

If everything is ok, you can find WordNew3.0 in the “/usr/local/WordNet-3.0/” directory, and in the binary subdirectory “/usr/local/WordNet-3.0/bin”, you can find the related binary files: wishwn wn wnb

After execute the wn:

./wn

We can get:

usage: wn word [-hgla] [-n#] -searchtype [-searchtype...]
       wn [-l]
 
	-h		Display help text before search output
	-g		Display gloss
	-l		Display license and copyright notice
	-a		Display lexicographer file information
	-o		Display synset offset
	-s		Display sense numbers in synsets
	-n#		Search only sense number #
 
searchtype is at least one of the following:
	-ants{n|v|a|r}		Antonyms
	-hype{n|v}		Hypernyms
	-hypo{n|v}, -tree{n|v}	Hyponyms & Hyponym Tree
	-entav			Verb Entailment
	-syns{n|v|a|r}		Synonyms (ordered by estimated frequency)
	-smemn			Member of Holonyms
	-ssubn			Substance of Holonyms
	-sprtn			Part of Holonyms
	-membn			Has Member Meronyms
	-subsn			Has Substance Meronyms
	-partn			Has Part Meronyms
	-meron			All Meronyms
	-holon			All Holonyms
	-causv			Cause to
	-pert{a|r}		Pertainyms
	-attr{n|a}		Attributes
	-deri{n|v}		Derived Forms
	-domn{n|v|a|r}		Domain
	-domt{n|v|a|r}		Domain Terms
	-faml{n|v|a|r}		Familiarity & Polysemy Count
	-framv			Verb Frames
	-coor{n|v}		Coordinate Terms (sisters)
	-simsv			Synonyms (grouped by similarity of meaning)
	-hmern			Hierarchical Meronyms
	-hholn			Hierarchical Holonyms
	-grep{n|v|a|r}		List of Compound Words
	-over			Overview of Senses

Now you can enjoy wordnet on your Ubuntu system.

Another simple way to install WordNet in Ubuntu is by apt-get:

sudo apt install wordnet

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
fontconfig-config fonts-dejavu-core libfontconfig1 libtcl8.5 libtk8.5
libxft2 libxrender1 libxss1 wordnet-base wordnet-gui x11-common
Suggested packages:
tcl8.5 tk8.5
The following NEW packages will be installed:
fontconfig-config fonts-dejavu-core libfontconfig1 libtcl8.5 libtk8.5
libxft2 libxrender1 libxss1 wordnet wordnet-base wordnet-gui x11-common
0 upgraded, 12 newly installed, 0 to remove and 94 not upgraded.
Need to get 9,177 kB of archives.
After this operation, 39.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
……
Setting up libxss1:amd64 (1:1.2.2-1) …
Setting up libtcl8.5:amd64 (8.5.19-1) …
Setting up libtk8.5:amd64 (8.5.19-1ubuntu1) …
Setting up wordnet-base (1:3.0-33) …
Setting up wordnet (1:3.0-33) …
Setting up wordnet-gui (1:3.0-33) …
Processing triggers for libc-bin (2.23-0ubuntu3) …
Processing triggers for systemd (229-4ubuntu8) …
Processing triggers for ureadahead (0.100.0-19) …

Now you can type “wn” to test WordNet same as before.

Install WordNet on Mac OS:

Install wordnet from the source on Mac OS is simpler, cause the tcl and tk dev is default on the Mac OS, you will met the same compile problem too:

But met a compile error:

……
stubs.c: In function ‘wn_findvalidsearches’:
stubs.c:43: error: ‘Tcl_Interp’ has no member named ‘result’
stubs.c:55: error: ‘Tcl_Interp’ has no member named ‘result’

The resolve method is still modify the original wordnet code:

sudo vim src/stubs.c

and add a line “#define USE_INTERP_RESULT 1” before “include tcl.h”, like this:

#ifdef _WINDOWS
#include <windows.h>
#endif
 
#define USE_INTERP_RESULT 1
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tcl.h>
#include <tk.h>
#include <wn.h>
......

Test WordNet
We test word “book” by WordNet:
wn book

Information available for noun book
	-hypen		Hypernyms
	-hypon, -treen	Hyponyms & Hyponym Tree
	-synsn		Synonyms (ordered by estimated frequency)
	-sprtn		Part of Holonyms
	-membn		Has Member Meronyms
	-partn		Has Part Meronyms
	-meron		All Meronyms
	-holon		All Holonyms
	-derin		Derived Forms
	-domnn		Domain
	-domtn		Domain Terms
	-famln		Familiarity & Polysemy Count
	-coorn		Coordinate Terms (sisters)
	-hmern		Hierarchical Meronyms
	-hholn		Hierarchical Holonyms
	-grepn		List of Compound Words
	-over		Overview of Senses
 
Information available for verb book
	-hypev		Hypernyms
	-hypov, -treev	Hyponyms & Hyponym Tree
	-entav		Verb Entailment
	-synsv		Synonyms (ordered by estimated frequency)
	-deriv		Derived Forms
	-famlv		Familiarity & Polysemy Count
	-framv		Verb Frames
	-coorv		Coordinate Terms (sisters)
	-simsv		Synonyms (grouped by similarity of meaning)
	-grepv		List of Compound Words
	-over		Overview of Senses
 
No information available for adj book
 
No information available for adv book

Continue:
wn book -hypen

Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun book
 
11 senses of book                                                       
 
Sense 1
book
       => publication
           => work, piece of work
               => product, production
                   => creation
                       => artifact, artefact
                           => whole, unit
                               => object, physical object
                                   => physical entity
                                       => entity
 
Sense 2
book, volume
       => product, production
           => creation
               => artifact, artefact
                   => whole, unit
                       => object, physical object
                           => physical entity
                               => entity
 
Sense 3
record, record book, book
       => fact
           => information, info
               => message, content, subject matter, substance
                   => communication
                       => abstraction, abstract entity
                           => entity
 
Sense 4
script, book, playscript
       => dramatic composition, dramatic work
           => writing, written material, piece of writing
               => written communication, written language, black and white
                   => communication
                       => abstraction, abstract entity
                           => entity
 
Sense 5
ledger, leger, account book, book of account, book
       => record
           => document
               => communication
                   => abstraction, abstract entity
                       => entity
 
Sense 6
book
       => collection, aggregation, accumulation, assemblage
           => group, grouping
               => abstraction, abstract entity
                   => entity
 
Sense 7
book, rule book
       => collection, aggregation, accumulation, assemblage
           => group, grouping
               => abstraction, abstract entity
                   => entity
 
Sense 8
Koran, Quran, al-Qur'an, Book
       INSTANCE OF=> sacred text, sacred writing, religious writing, religious text
           => writing, written material, piece of writing
               => written communication, written language, black and white
                   => communication
                       => abstraction, abstract entity
                           => entity
 
Sense 9
Bible, Christian Bible, Book, Good Book, Holy Scripture, Holy Writ, Scripture, Word of God, Word
       => sacred text, sacred writing, religious writing, religious text
           => writing, written material, piece of writing
               => written communication, written language, black and white
                   => communication
                       => abstraction, abstract entity
                           => entity
 
Sense 10
book
       => section, subdivision
           => writing, written material, piece of writing
               => written communication, written language, black and white
                   => communication
                       => abstraction, abstract entity
                           => entity
           => music
               => auditory communication
                   => communication
                       => abstraction, abstract entity
                           => entity
 
Sense 11
book
       => product, production
           => creation
               => artifact, artefact
                   => whole, unit
                       => object, physical object
                           => physical entity
                               => entity

Continue:
wn book -hypon

Hyponyms of noun book
 
7 of 11 senses of book                                                  
 
Sense 1
book
       => authority
       => curiosa
       => formulary, pharmacopeia
       => trade book, trade edition
       => bestiary
       => catechism
       => pop-up book, pop-up
       => storybook
       => tome
       => booklet, brochure, folder, leaflet, pamphlet
       => textbook, text, text edition, schoolbook, school text
       => workbook
       => copybook
       => appointment book, appointment calendar
       => catalog, catalogue
       => phrase book
       => playbook
       => prayer book, prayerbook
       => reference book, reference, reference work, book of facts
       => review copy
       => songbook
       => yearbook
       HAS INSTANCE=> Das Kapital, Capital
       HAS INSTANCE=> Erewhon
       HAS INSTANCE=> Utopia
 
Sense 2
book, volume
       => album
       => coffee-table book
       => folio
       => hardback, hardcover
       => journal
       => novel
       => order book
       => paperback book, paper-back book, paperback, softback book, softback, soft-cover book, soft-cover
       => picture book
       => sketchbook, sketch block, sketch pad
       => notebook
 
Sense 3
record, record book, book
       => logbook
       => won-lost record
       => card, scorecard
 
Sense 4
script, book, playscript
       => promptbook, prompt copy
       => continuity
       => dialogue, dialog
       => libretto
       => scenario
       => screenplay
       => shooting script
 
Sense 5
ledger, leger, account book, book of account, book
       => cost ledger
       => general ledger
       => subsidiary ledger
       => daybook, journal
 
Sense 9
Bible, Christian Bible, Book, Good Book, Holy Scripture, Holy Writ, Scripture, Word of God, Word
       => family Bible
       HAS INSTANCE=> Vulgate
       HAS INSTANCE=> Douay Bible, Douay Version, Douay-Rheims Bible, Douay-Rheims Version, Rheims-Douay Bible, Rheims-Douay Version
       HAS INSTANCE=> Authorized Version, King James Version, King James Bible
       HAS INSTANCE=> Revised Version
       HAS INSTANCE=> New English Bible
       HAS INSTANCE=> American Standard Version, American Revised Version
       HAS INSTANCE=> Revised Standard Version
 
Sense 10
book
       HAS INSTANCE=> Genesis, Book of Genesis
       HAS INSTANCE=> Exodus, Book of Exodus
       HAS INSTANCE=> Leviticus, Book of Leviticus
       HAS INSTANCE=> Numbers, Book of Numbers
       HAS INSTANCE=> Deuteronomy, Book of Deuteronomy
       HAS INSTANCE=> Joshua, Josue, Book of Joshua
       HAS INSTANCE=> Judges, Book of Judges
       HAS INSTANCE=> Ruth, Book of Ruth
       HAS INSTANCE=> I Samuel, 1 Samuel
       HAS INSTANCE=> II Samuel, 2 Samuel
       HAS INSTANCE=> I Kings, 1 Kings
       HAS INSTANCE=> II Kings, 2 Kings
       HAS INSTANCE=> I Chronicles, 1 Chronicles
       HAS INSTANCE=> II Chronicles, 2 Chronicles
       HAS INSTANCE=> Ezra, Book of Ezra
       HAS INSTANCE=> Nehemiah, Book of Nehemiah
       HAS INSTANCE=> Esther, Book of Esther
       HAS INSTANCE=> Job, Book of Job
       HAS INSTANCE=> Psalms, Book of Psalms
       HAS INSTANCE=> Proverbs, Book of Proverbs
       HAS INSTANCE=> Ecclesiastes, Book of Ecclesiastes
       HAS INSTANCE=> Song of Songs, Song of Solomon, Canticle of Canticles, Canticles
       HAS INSTANCE=> Isaiah, Book of Isaiah
       HAS INSTANCE=> Jeremiah, Book of Jeremiah
       HAS INSTANCE=> Lamentations, Book of Lamentations
       HAS INSTANCE=> Ezekiel, Ezechiel, Book of Ezekiel
       HAS INSTANCE=> Daniel, Book of Daniel, Book of the Prophet Daniel
       HAS INSTANCE=> Hosea, Book of Hosea
       HAS INSTANCE=> Joel, Book of Joel
       HAS INSTANCE=> Amos, Book of Amos
       HAS INSTANCE=> Obadiah, Abdias, Book of Obadiah
       HAS INSTANCE=> Jonah, Book of Jonah
       HAS INSTANCE=> Micah, Micheas, Book of Micah
       HAS INSTANCE=> Nahum, Book of Nahum
       HAS INSTANCE=> Habakkuk, Habacuc, Book of Habakkuk
       HAS INSTANCE=> Zephaniah, Sophonias, Book of Zephaniah
       HAS INSTANCE=> Haggai, Aggeus, Book of Haggai
       HAS INSTANCE=> Zechariah, Zacharias, Book of Zachariah
       HAS INSTANCE=> Malachi, Malachias, Book of Malachi
       HAS INSTANCE=> Matthew, Gospel According to Matthew
       HAS INSTANCE=> Mark, Gospel According to Mark
       HAS INSTANCE=> Luke, Gospel of Luke, Gospel According to Luke
       HAS INSTANCE=> John, Gospel According to John
       HAS INSTANCE=> Acts of the Apostles, Acts
       => Epistle
       HAS INSTANCE=> Revelation, Revelation of Saint John the Divine, Apocalypse, Book of Revelation
       HAS INSTANCE=> Additions to Esther
       HAS INSTANCE=> Prayer of Azariah and Song of the Three Children
       HAS INSTANCE=> Susanna, Book of Susanna
       HAS INSTANCE=> Bel and the Dragon
       HAS INSTANCE=> Baruch, Book of Baruch
       HAS INSTANCE=> Letter of Jeremiah, Epistle of Jeremiah
       HAS INSTANCE=> Tobit, Book of Tobit
       HAS INSTANCE=> Judith, Book of Judith
       HAS INSTANCE=> I Esdra, 1 Esdras
       HAS INSTANCE=> II Esdras, 2 Esdras
       HAS INSTANCE=> Ben Sira, Sirach, Ecclesiasticus, Wisdom of Jesus the Son of Sirach
       HAS INSTANCE=> Wisdom of Solomon, Wisdom
       HAS INSTANCE=> I Maccabees, 1 Maccabees
       HAS INSTANCE=> II Maccabees, 2 Maccabees

Let’s test the word “dog”:

wn dog

Information available for noun dog
	-hypen		Hypernyms
	-hypon, -treen	Hyponyms & Hyponym Tree
	-synsn		Synonyms (ordered by estimated frequency)
	-smemn		Member of Holonyms
	-sprtn		Part of Holonyms
	-partn		Has Part Meronyms
	-meron		All Meronyms
	-holon		All Holonyms
	-famln		Familiarity & Polysemy Count
	-coorn		Coordinate Terms (sisters)
	-hmern		Hierarchical Meronyms
	-hholn		Hierarchical Holonyms
	-grepn		List of Compound Words
	-over		Overview of Senses
 
Information available for verb dog
	-hypev		Hypernyms
	-hypov, -treev	Hyponyms & Hyponym Tree
	-synsv		Synonyms (ordered by estimated frequency)
	-famlv		Familiarity & Polysemy Count
	-framv		Verb Frames
	-coorv		Coordinate Terms (sisters)
	-simsv		Synonyms (grouped by similarity of meaning)
	-grepv		List of Compound Words
	-over		Overview of Senses
 
No information available for adj dog
 
No information available for adv dog

Let’s find the synset for noun dog:

wn dog -synsn

Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun dog
 
7 senses of dog                                                         
 
Sense 1
dog, domestic dog, Canis familiaris
       => canine, canid
       => domestic animal, domesticated animal
 
Sense 2
frump, dog
       => unpleasant woman, disagreeable woman
 
Sense 3
dog
       => chap, fellow, feller, fella, lad, gent, blighter, cuss, bloke
 
Sense 4
cad, bounder, blackguard, dog, hound, heel
       => villain, scoundrel
 
Sense 5
frank, frankfurter, hotdog, hot dog, dog, wiener, wienerwurst, weenie
       => sausage
 
Sense 6
pawl, detent, click, dog
       => catch, stop
 
Sense 7
andiron, firedog, dog, dog-iron
       => support

Let’s find the synset for verb dog:

wn dog -synsv

Synonyms/Hypernyms (Ordered by Estimated Frequency) of verb dog
 
1 sense of dog                                                          
 
Sense 1
chase, chase after, trail, tail, tag, give chase, dog, go after, track
       => pursue, follow

Just enjoy it.

Posted by TextProcessing


Leave a Reply

Your email address will not be published. Required fields are marked *