| ||||||||||||||||||
| ||||||||||||||||||
| ||||||||||||||||||
Description | ||||||||||||||||||
This is the top level module to the Haskell WordNet interface. This module is maintained at: http://www.isi.edu/~hdaume/HWordNet/. This is the only module in the WordNet package you need to import. The others provide utility functions and primitives that this module is based on. More information about WordNet is available at: http://http://www.cogsci.princeton.edu/~wn/. | ||||||||||||||||||
Synopsis | ||||||||||||||||||
The basic type system | ||||||||||||||||||
module NLP.WordNet.Types | ||||||||||||||||||
Top level execution functions | ||||||||||||||||||
runWordNet :: WN a -> IO a | ||||||||||||||||||
Takes a WordNet command, initializes the environment and returns the results in the IO monad. WordNet warnings are printed to stderr. | ||||||||||||||||||
runWordNetQuiet :: WN a -> IO a | ||||||||||||||||||
Takes a WordNet command, initializes the environment and returns the results in the IO monad. WordNet warnings are ignored. | ||||||||||||||||||
runWordNetWithOptions :: Maybe FilePath -> Maybe (String -> Exception -> IO ()) -> WN a -> IO a | ||||||||||||||||||
Takes a FilePath to the directory holding WordNet and a function to do with warnings and a WordNet command, initializes the environment and returns the results in the IO monad. | ||||||||||||||||||
Functions to manually initialize the WordNet system; these are not | ||||||||||||||||||
initializeWordNet :: IO WordNetEnv | ||||||||||||||||||
Gives you a WordNetEnv which can be passed to runs or used as the implicit parameter to the other WordNet functions. | ||||||||||||||||||
initializeWordNetWithOptions :: Maybe FilePath -> Maybe (String -> Exception -> IO ()) -> IO WordNetEnv | ||||||||||||||||||
Takes a FilePath to the directory holding WordNet and a function to do with warnings, initializes the environment and returns a WordNetEnv as in initializeWordNet. | ||||||||||||||||||
closeWordNet :: WordNetEnv -> IO () | ||||||||||||||||||
Closes all the handles associated with the WordNetEnv. Since the functions provided in the NLP.WordNet.WordNet module are lazy, you shouldn't do this until you're really done. Or perhaps not at all (GC will eventually kick in). | ||||||||||||||||||
runs :: WordNetEnv -> WN a -> a | ||||||||||||||||||
This simply takes a WordNetEnv and provides it as the implicit parameter to the WordNet command. | ||||||||||||||||||
The basic database access functions. | ||||||||||||||||||
getOverview :: WN (Word -> Overview) | ||||||||||||||||||
This takes a word and returns an Overview of all its senses for all parts of speech. | ||||||||||||||||||
searchByOverview :: WN (Overview -> POS -> SenseType -> [SearchResult]) | ||||||||||||||||||
This takes an Overview (see getOverview), a POS and a SenseType and returns a list of search results. If SenseType is AllSenses, there will be one SearchResult in the results for each valid sense. If SenseType is a single sense number, there will be at most one element in the result list. | ||||||||||||||||||
search :: WN (Word -> POS -> SenseType -> [SearchResult]) | ||||||||||||||||||
This takes a Word, a POS and a SenseType and returns the equivalent of first running getOverview and then searchByOverview. | ||||||||||||||||||
lookupKey :: WN (Key -> SearchResult) | ||||||||||||||||||
This takes a Key (see srToKey and srFormKeys) and looks it up in the databse. | ||||||||||||||||||
The agglomeration functions | ||||||||||||||||||
relatedBy :: WN (Form -> SearchResult -> [SearchResult]) | ||||||||||||||||||
This takes a Form and a SearchResult and returns all SearchResult related to the given one by the given Form. For example: relatedBy Antonym (head (search "happy" Adj 1)) [<unhappy>] relatedBy Hypernym (head (search "dog" Noun 1)) [<canine canid>] | ||||||||||||||||||
closure :: (a -> [a]) -> a -> Tree a | ||||||||||||||||||
This is a utility function to build lazy trees from a function and a root. | ||||||||||||||||||
closureOn :: WN (Form -> SearchResult -> Tree SearchResult) | ||||||||||||||||||
This enables Form-based trees to be built. For example: take 5 $ flatten $ closureOn Antonym (head (search "happy" Adj AllSenses))) [<happy>,<unhappy>,<happy>,<unhappy>,<happy>] closureOn Hypernym (head (search "dog" Noun 1))) - <dog domestic_dog Canis_familiaris> --- <canine canid> --- <carnivore>\\ --- <placental placental_mammal eutherian eutherian_mammal> --- <mammal>\\ --- <vertebrate craniate> --- <chordate> --- <animal animate_being beast\\ brute creature fauna> --- <organism being> --- <living_thing animate_thing>\\ --- <object physical_object> --- <entity> | ||||||||||||||||||
Computing lowest-common ancestor functions; the implementation | ||||||||||||||||||
meet :: (Bag b (Tree SearchResult)) => WN (b (Tree SearchResult) -> SearchResult -> SearchResult -> Maybe SearchResult) | ||||||||||||||||||
This function takes an empty bag (in particular, this is to specify what type of search to perform), and the results of two search. It returns (maybe) the lowest point at which the two terms meet in the WordNet hierarchy. For example: meet emptyQueue (head $ search "cat" Noun 1) (head $ search "dog" Noun 1) Just <carnivore> meet emptyQueue (head $ search "run" Verb 1) (head $ search "walk" Verb 1) Just <travel go move locomote> | ||||||||||||||||||
meetPaths :: (Bag b (Tree SearchResult)) => WN (b (Tree SearchResult) -> SearchResult -> SearchResult -> Maybe ([SearchResult], SearchResult, [SearchResult])) | ||||||||||||||||||
This function takes an empty bag (see meet), and the results of two searches. It returns (maybe) the lowest point at which the two terms meet in the WordNet hierarchy, as well as the paths leading from each term to this common term. For example: meetPaths emptyQueue (head $ search "cat" Noun 1) (head $ search "dog" Noun 1) Just ([<cat true_cat>,<feline felid>],<carnivore>,[<canine canid>,<dog domestic_dog Canis_familiaris>]) meetPaths emptyQueue (head $ search "run" Verb 1) (head $ search "walk" Verb 1) Just ([<run>,<travel_rapidly speed hurry zip>],<travel go move locomote>,[<walk>]) This is marginally less efficient than just using meet, since it uses linear-time lookup for the visited sets, whereas meet uses log-time lookup. | ||||||||||||||||||
class Bag b a where | ||||||||||||||||||
| ||||||||||||||||||
emptyQueue :: Queue a | ||||||||||||||||||
An empty queue. | ||||||||||||||||||
emptyStack :: [a] | ||||||||||||||||||
An empty stack. | ||||||||||||||||||
Produced by Haddock version 0.5 |