------------------------------------------------------------------------------- |-- Module : NLP.WordNet.Types-- Copyright : (c) Hal Daume III 2003-2004-- License : BSD-style---- Maintainer : hdaume@isi.edu-- Stability : experimental-- Portability : non-portable (H98 + implicit parameters)---- This module is maintained at:-- <http://www.isi.edu/~hdaume/HWordNet/>.---- This module describes the types used in the purely functional interface.---- More information about WordNet is available at:-- <http://http://www.cogsci.princeton.edu/~wn/>.-------------------------------------------------------------------------------moduleNLP.WordNet.Types(-- * The wrapper type for wordnet functions.WN(),-- * The basic Word type (just a 'String').Word,-- * The part of speech type.POS(..),-- * The type, and functions dealing with overview searches.Overview(),numNounSenses,numVerbSenses,numAdjSenses,numAdvSenses,taggedCountNounSenses,taggedCountVerbSenses,taggedCountAdjSenses,taggedCountAdvSenses,-- * The type, and functions dealing with the word net environment.WordNetEnv(),getReleaseVersion,getDataDirectory,-- The type, and functions dealing with senses.-- SenseKey(),-- senseKeyPOS,-- senseKeyWord,-- * The type to control which sense a search is looking at.SenseType(..),-- * The type, and functions dealing with search results.SearchResult(),srOverview,srSenseNum,srPOS,srDefinition,srSenses,srWords,srForms,srFormKeys,srToKey,-- The type, and functions dealing with indices.-- Index(),-- indexWord,-- indexPOS,-- * A sum type of the different relations which can hold between words.Form(..),-- * A simple key into the database.Key(),)whereimportSystem.IO.UnsafeimportData.ListimportData.MaybeimportNLP.WordNet.PrimTypesimportNLP.WordNet.Util-- | In actuality this type is:---- > type WN a = (?wne :: WordNetEnv) => a-- -- but Haddock cannot parse this at this time.-- type WN a = atypeWNa=(?wne::WordNetEnv)=>a-- | A Word is just a String.typeWord=String-- basically, all we do is wrap the SenseKey, Synset and WordNetEnv-- datatypes in a bunch of useful functions-- | This will give you the current release of the WordNet databases-- we are using (if we know).getReleaseVersion::WN(MaybeString)getReleaseVersion=wnReleaseVersion?wne-- | This will give you the directory from which the databases are being read.getDataDirectory::WNFilePathgetDataDirectory=dataDirectory?wne-- | Given an 'Overview', this will tell you how many noun senses the searched-for word has.numNounSenses::Overview->IntnumNounSenses=maybe0indexSenseCount.nounIndex-- | Given an 'Overview', this will tell you how many verb senses the searched-for word has.numVerbSenses::Overview->IntnumVerbSenses=maybe0indexSenseCount.verbIndex-- | Given an 'Overview', this will tell you how many adjective senses the searched-for word has.numAdjSenses::Overview->IntnumAdjSenses=maybe0indexSenseCount.adjIndex-- | Given an 'Overview', this will tell you how many adverb senses the searched-for word has.numAdvSenses::Overview->IntnumAdvSenses=maybe0indexSenseCount.advIndex-- | Given an 'Overview', this will tell you how many times this word was tagged as a noun.taggedCountNounSenses::Overview->InttaggedCountNounSenses=maybe0indexTaggedCount.nounIndex-- | Given an 'Overview', this will tell you how many times this word was tagged as a verb.taggedCountVerbSenses::Overview->InttaggedCountVerbSenses=maybe0indexTaggedCount.verbIndex-- | Given an 'Overview', this will tell you how many times this word was tagged as an adjective.taggedCountAdjSenses::Overview->InttaggedCountAdjSenses=maybe0indexTaggedCount.adjIndex-- | Given an 'Overview', this will tell you how many times this word was tagged as an adverb.taggedCountAdvSenses::Overview->InttaggedCountAdvSenses=maybe0indexTaggedCount.advIndex-- | This gives the part of speech of a 'SearchResult'srPOS::SearchResult->POSsrPOSsr=casepos(srSynsetsr)of{POSp->p;_->Adj}-- | This gives the definition of the sense of a word in a 'SearchResult'.srDefinition::SearchResult->StringsrDefinition=defn.srSynset-- | This gives a list of senses the word has.srSenses::SearchResult->[SenseType]srSenses=nub.mapthr3.ssWords.srSynset-- | This gives the actual words used to describe the Synset of a search result.srWords::SearchResult->SenseType->[Word]srWordssrt=nub.mapfst3.filter((isTypet).thr3).ssWords.srSynset$srwhereisTypeAllSenses_=TrueisType_AllSenses=TrueisType(SenseNumbern)(SenseNumberm)=n==m-- | This gives all the 'Form's a word has (i.e., what sort of relations hold between-- it and other words.srForms::SearchResult->[Form]srForms=nub.map(\(f,_,_,_,_)->f).forms.srSynset-- | This provides a 'Key' (which can be searched for using 'lookupKey') for-- a 'SearchResult' under a given form. For instance, it can be used to-- get all 'Hypernym's of a given word.srFormKeys::SearchResult->Form->[Key]srFormKeyssrf=nub.mapMaybemkKey.filter(\(f',_,_,_,_)->f==f').forms.srSynset$srwheremkKey(_,o,POSp,_,_)=Just$Key(o,p)mkKey(_,o,_,_,_)=casesrSenseKeysrofNothing->NothingJustsk->Just$Key(o,senseKeyPOSsk)-- | This converts a 'SearchResult' into a 'Key'.srToKey::SearchResult->Key-- returns the key associated with this search resultsrToKeysr=Key(hereIAm$srSynsetsr,p)wherep=casesrSenseKeysrofJustsk->senseKeyPOSskNothing->casepos(srSynsetsr)ofPOSpp->pp_->casessType(srSynsetsr)ofPOSpp->pp_->AdjinstanceShowSearchResultwhereshowsPreci(SearchResult{srSynset=ss})=showChar'<'.showString(unwords$mapfst3$ssWordsss).showChar'>'