wordnet.lsp

Module index

source download

Module: wordnet

Queries a local copy of Wordnet 3.0 English lexical database from wordnet.princeton.edu

Version: 0.31
Author: Lutz Mueller, December 2007


WordNet® is a large lexical database of English, developed under the direction of George A. Miller. 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. (this paragraph copied from http://wordnet.princeton.edu)

This module has two interfaces to a local copy of WordNet-3.0. The simple interface works via the command line utility: wn part of the normal WordNet-3.0 installation. The alternate interface is a shared library interface to a specially adapted compilation of the wn utility source code. Queries made with the shared library interface are only about 25% faster than queries made through the simple wn commandline interface, but do not invoke a new process for every query. This module can be switched to use the simpleinterface editing the wn:SHARED_LIB setting at the beginning of this file.

Note that the function wn:morph is only available in the shared library interface.

Requirements

For the simple wn command line interface a standard installation of WordNet 3.0 is necessary. Source code and binaries for Windows and Unix can be obtained at: http://wordnet.princeton.edu/obtain . This module automatically adjusts to the standard Wordnet directory locations on Windows and UNIX. If non-standard locations are used, the environment settings at the beginning of this module file have to be adjusted.

For the shared library interface the file libwn.c needs to be compiled and the resulting library be placed in $WNHOME/lib as either libwn.dylib on Mac OS X or libwn.so on other UNIX. By default '$WNHOME is assumed to be /usr/local/WordNet-3.0> on Unix or %PROGRAMFILES%/WordNet-3.0/ on Win32.

The source and a shell script to compile the libaray is available from the author of this module at: http://newlisp.org/code/wordnet-nl-03.tgz The file libwn.c is an adaptation of the wn.c command line utility fromn the WordNet-3.0 source distribution.

Functions in the API

The names of the functions are chosen corresponding to the options used in the WordNet wn command line utility. This facilitates usage by users familiar with WordNet.

wn:morph - stem, variations (only on the shared library interface)
wn:hypen - verb hypernyms
wn:hypev - noun hypernyms
wn:synsn - noun synonyms ordered by estimated frequency
wn:synsv - verb synonyms ordered by estimated frequency
wn:hypon - noun hyponyms
wn:hypov - verb hyponyms
wn:coorn - noun coordinates
wn:coorv - verb coordinates
wn:antsn - nound antonymns
wn:antsv - verb antonyms
wn:antsa - adjective antonyms

wn:query - process iand returns an original wn quer (used internally)
wn:get-words -' extracts words from an original wn query (used internally)


Note that WordNet has many more possible queries, which easily can be entered using the wn:query and wn:get-words functions.

§

wn:morph

syntax: (wn:morph str-word [int-pos])
parameter: str-word - The word for which to seach the morph.
parameter: int-pos - The optional part of speech for which to search, wn:NOUN, wn:VERB, wn:ADJ, an:ADV.

return: The word variant for the part of speech given, or a list of found variants, if not int-pos is spceified.



Example:
 (wn:morph "shot") => (("shoot" wn:VERB))

 (wn:morph "shot" wn:VERB) => "shoot"

 (wn:morph "shot" wn:ADJ) => nil

 (wn:morph "forms") => (("form" wn:NOUN) ("form" wn:VERB))


§

wn:hypen

syntax: (wn:hypen str-word)
parameter: The - word for which to search hypernym nouns.

return: List of words.



This function does a -hypen query returning noun synonyms for the word entered.

Example:
 (wn:hypen "motor") => 

 ("machine" "device" "instrumentality" "instrumentation" "artifact" "artefact" "whole" 
  "unit" "object" "physical object" "physical entity" "entity" "agent" "causal agent" 
  "cause" "causal agency" "physical entity" "entity")


§

wn:hypev

syntax: (wn:hypev str-word)
parameter: The - word for which to search hypernym verbs.

return: List of words.



This function does a -hypev query returning verb synonyms for the word entered.

Example:
 (wn:hypev "motor") => ("travel" "go" "move" "locomote")


§

wn:synsn

syntax: (wn:synsn str-word)
parameter: The - word for which to search synonym nouns.

return: List of words.



This function does a -synsn query returning noun synonyms for the word entered.

Example:
 (wn:synsn "program") 

 => ("idea" "thought" "system" "system of rules" "show" "document" "written document" 
  "papers" "announcement" "promulgation" "information" "info" "software" "software program" 
  "computer software" "software system" "software package" "package" "performance")


§

wn:synsv

syntax: (wn:synsv str-word)
parameter: The - word for which to search synonym verbs.

return: List of words.



This function does a -synsv query returning verb synonyms for the word entered.

Example:
 (wn:synsv "program") 

 => ("schedule" "create by mental act" "create mentally")


§

wn:hypon

syntax: (wn:hypon str-word)
parameter: The - word for which to search hyponym nouns.

return: List of words.



This function does a -hypon query returning noun hyponyms for the word entered.

Example:
 (wn:hypon "train") 

 => ("boat train" "car train" "freight train" "rattler" "hospital train" "mail train" 
 "passenger train" "streamliner" "subway train" "epicyclic train" "epicyclic gear train" 
 "reduction gear")


§

wn:hypov

syntax: (wn:hypov str-word)
parameter: The - word for which to search hyponym verbs.

return: List of words.



This function does a -hypov query returning verb hyponyms for the word entered.

Example:
 (wn:hypovv "program") 

 => ("hack" "hack on")


§

wn:coorn

syntax: (wn:coorn str-word)
parameter: The - word for which to search coordinate nouns..

return: List of words.



This function does a -coorn query returning noun coordinates for the word entered.

Example:
 (wn:coorn "breakfast") 

 => ("mess" "square meal" "potluck" "refection" "breakfast" "brunch" "lunch" "luncheon" 
  "tiffin" "dejeuner" "tea" "afternoon tea" "teatime" "dinner" "supper" "buffet" "picnic" 
  "bite" "collation" "snack" "nosh-up" "ploughman's lunch" "banquet" "feast" "spread")


§

wn:coorv

syntax: (wn:coorv str-word)
parameter: The - word for which to search coordinate verbs.

return: List of words.



This function does a -coorv query returning verb coordinates for the word entered.

Example:
 (wn:synsv "sleep") 

 => ("sleep" "kip" "slumber" "log Z's" "catch some Z's" "drowse" "sleep" "house" "seat")


§

wn:antsn

syntax: (wn:antsn str-word)
parameter: The - word for which to search antonym nouns.

return: List of words.



This function does a -antsn query returning noun antonyms for the word entered.

Example:
 (wn:antsn "love")  => ("love" "hatred")


§

wn:antsv

syntax: (wn:antsv str-word)
parameter: The - word for which to search antonym nouns.

return: List of words.



This function does a -antsv query returning verb antonyms for the word entered.

Example:
 (wn:antsv "love")  => ("hate" "detes")t


§

wn:antsa

syntax: (wn:antsa str-word)
parameter: The - word for which to search antonym nouns.

return: List of words.



This function does a -antsa query returning adjective antonyms for the word entered.

Example:
 (wn:antsa "cool") => ("lukewarm" "tepid" "warmed" "warming" "hot" "cordial" "hearty")
- § -

Utility Functions



§

wn:query

syntax: (wn:query str-query)
parameter: str-query - A query string exactly as used for the WordNet wn command.


This command is normally only used internally by this module, but can also be used to add new functions to this module or make queries not covered by the other functions.

Example:
 (wn:query "book -synsn") 
 
 => generates same output as 'wn book -synsn' on command line


§

wn:get-words

syntax: (wn:get-words str-query-result)
parameter: Parse - out the wordsfrom a wn:query results and return them in a list.

return: List of words.



This command is normally only used internally by this module, but can also be used to add new functions to this module or make queries not covered by the other functions. Example:
 (wn:get-words (wn:query "old -synsn"))

 => ("past" "past times" "yesteryear")


- ∂ -

generated with newLISP  and newLISPdoc