|
|
|
|
|
Description |
NLP.WordNet.Prims provides primitive operations over the word net database.
The general scheme of things is to call initializeWordNet to get a WordNetEnv.
Once you have this, you can start querying. A query usually looks like (suppose
we want Dog as a Noun: getIndexString on Dog. This will give us back a cannonicalized string, in this
case, still dog. We then use indexLookup to get back an index for this string.
Then, we call indexToSenseKey to with the index and the sense number (the Index
contains the number of senses) to get back a SenseKey. We finally call
getSynsetForSense on the sense key to get back a Synset. We can continue to query like this or we can use the offsets provided in the
various fields of the Synset to query directly on an offset. Given an offset
and a part of speech, we can use readSynset directly to get a synset (instead
of going through all this business with indices and sensekeys. |
|
Synopsis |
|
|
|
Documentation |
|
initializeWordNet :: IO WordNetEnv |
initializeWordNet looks for the word net data files in the
default directories, starting with environment variables WNSEARCHDIR
and WNHOME, and then falling back to defaultPath as defined in
NLP.WordNet.Consts. |
|
initializeWordNetWithOptions :: Maybe FilePath -> Maybe (String -> Exception -> IO ()) -> IO WordNetEnv |
initializeWordNetWithOptions looks for the word net data files in the
specified directory. Use this if wordnet is installed in a non-standard
place on your machine and you don't have the appropriate env vars set up. |
|
closeWordNet :: WordNetEnv -> IO () |
closeWordNet is not strictly necessary. However, a WordNetEnv tends to
hog a few Handles, so if you run out of Handles and won't be using
your WordNetEnv for a while, you can close it and always create a new
one later. |
|
getIndexString :: WordNetEnv -> String -> POS -> IO (Maybe String) |
getIndexString takes a string and a part of speech and tries to find
that string (or something like it) in the database. It is essentially
a cannonicalization routine and should be used before querying the
database, to ensure that your string is in the right form. |
|
getSynsetForSense :: WordNetEnv -> SenseKey -> IO (Maybe Synset) |
getSynsetForSense takes a sensekey and finds the appropriate Synset. SenseKeys can
be built using indexToSenseKey. |
|
readSynset :: WordNetEnv -> POS -> Offset -> String -> IO Synset |
readSynset takes a part of speech, and an offset (the offset can be found
in another Synset) and (perhaps) a word we're looking for (this is optional)
and will return its Synset. |
|
indexToSenseKey :: WordNetEnv -> Index -> Int -> IO (Maybe SenseKey) |
indexToSenseKey takes an Index (as returned by, ex., indexLookup) and a sense
number and returns a SenseKey for that sense. |
|
indexLookup :: WordNetEnv -> String -> POS -> IO (Maybe Index) |
|
Produced by Haddock version 0.5 |