pikajude / WordNet-ghc74

Haskell WordNet for ghc 7.4+
Other
2 stars 2 forks source link

Which WordNet database version does WordNet work with? #1

Open aBathologist opened 9 years ago

aBathologist commented 9 years ago

Hi! I'm hoping to use your package for a hobby project. But I'm having trouble figuring out how to initialize the database. The description of the package description indicates that only the WordNet database is needed:

A pure-Haskell interface to the WordNet lexical database of English. Depends on the WordNet database, but not on the WordNet source code.

However, when I tried to call initializeWordNetWithOptions (Just wordNetDictPath) Nothing I received the following errors:

Warning: initializeWordNet: cannot open file index.key
dict/index.key: openBinaryFile: does not exist (No such file or directory)
Warning: initializeWordNet: cannot open file index.key.rev
dict/index.key.rev: openBinaryFile: does not exist (No such file or directory)

And, indeed, those files are not present in the WordNet databases I've downloaded. I have tried both the database for WordNet 3.0 and that for 3.1, downloaded from here: http://wordnet.princeton.edu/wordnet/download/current-version/#nix

In case it is relevant, I am running OS X 10.9.5 and GHC 7.8.3. Any help would be greatly appreciated! But in the event you advise me against using this library and finding another way, I'll be okay with that too.

Thanks in advance.

andrewufrank commented 9 years ago

These warnings are not relevant - wordnet works without these files (probably old versions of wordnet used these). The source code of wn.h can be changed not to use these files (manually in Prisms.hs) as follows:

-- the following are unnecessary sense <- tryMaybeWarn (warn "Warning: initializeWordNet: cannot open file index.sense") $ openFileEx (makePath [searchdir, "index.sense"]) (BinaryMode ReadMode) cntlst <- tryMaybeWarn (warn "Warning: initializeWordNet: cannot open file cntlist.rev") $ openFileEx (makePath [searchdir, "cntlist.rev"]) (BinaryMode ReadMode) -- keyidx <- tryMaybeWarn (warn "Warning: initializeWordNet: cannot open file index.key") -- $ openFileEx (makePath [searchdir, "index.key" ]) (BinaryMode ReadMode) -- rkeyidx <- tryMaybeWarn (warn "Warning: initializeWordNet: cannot open file index.key.rev") -- $ openFileEx (makePath [searchdir, "index.key.rev"]) (BinaryMode ReadMode) vsent <- tryMaybeWarn (warn "Warning: initializeWordNet: cannot open sentence files (sentidx.vrb and sents.vrb)") $ do idx <- openFileEx (makePath [searchdir, "sentidx.vrb"]) (BinaryMode ReadMode) snt <- openFileEx (makePath [searchdir, "sents.vrb" ]) (BinaryMode ReadMode) return (idx, snt) mHands <- mapM (\pos' -> openFileEx (makePath [searchdir, partName pos' ++ ".exc"]) (BinaryMode ReadMode)) allPOS return WordNetEnv { dataHandles = listArray (Noun, Adv) dHands, excHandles = listArray (Noun, Adv) mHands, senseHandle = sense, countListHandle = cntlst, keyIndexHandle = Nothing, -- keyidx, revKeyIndexHandle = Nothing, -- rkeyidx, vSentHandle = vsent, wnReleaseVersion = version, dataDirectory = searchdir, warnAbout = warn }

the installation of wn.h does not automatically set the search path for the wordnet database and this must be done separately with

wnenv <- initializeWordNetWithOptions 
        (Just "/usr/share/wordnet") Nothing 

(or wherever the wordnet files are found).

here some example code (for "dog")

runWN :: IO () runWN = do

wnenv <- initializeWordNetWithOptions 
        (Just "/usr/share/wordnet") Nothing 
let a = runs wnenv $ search "dog" Noun AllSenses
let k = map srDefinition a 
putStr . unwords $  ["result is " , show k]

return ()