Safe Haskell | None |
---|
The module provides functions for working with the binary representation of the historical dictionary of Polish.
It is intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.
import qualified NLP.HistPL as H
Use save
and load
functions to save/load
the entire dictionary in/from a given directory. They are
particularly useful when you want to convert the LMF
dictionary
to a binary format (see NLP.HistPL.LMF module).
To search the dictionary, open the binary directory with an
open
function. For example, during a GHCi
session:
>>>
hpl <- H.open "srpsdp.bin"
Set the OverloadedStrings extension for convenience:
>>>
:set -XOverloadedStrings
To search the dictionary use the lookup
function, e.g.
>>>
entries <- H.lookup hpl "dufliwego"
You can use functions defined in the NLP.HistPL.Types module to query the entries for a particular feature, e.g.
>>>
map (H.text . H.lemma) entries
[["dufliwy"]]
- data BinEntry = BinEntry {}
- data Key = Key {}
- proxyForm :: LexEntry -> Text
- binKey :: BinEntry -> Key
- data Rule = Rule {}
- between :: Text -> Key -> Rule
- apply :: Rule -> Text -> Key
- data HistPL
- tryOpen :: FilePath -> IO (Maybe HistPL)
- open :: FilePath -> IO HistPL
- lookup :: HistPL -> Text -> IO [LexEntry]
- lookupBin :: HistPL -> Text -> IO [BinEntry]
- getIndex :: HistPL -> IO [Key]
- withKey :: HistPL -> Key -> IO (Maybe BinEntry)
- save :: FilePath -> [LexEntry] -> IO ()
- load :: FilePath -> IO (Maybe [BinEntry])
- module NLP.HistPL.Types
Entries
Entry in the binary dictionary consists of the lexical entry and corresponding unique identifier.
A dictionary key which uniquely identifies the lexical entry.
Rules
A rule for translating a form into a binary dictionary key.
Dictionary
Open
tryOpen :: FilePath -> IO (Maybe HistPL)Source
Open the binary dictionary residing in the given directory. Return Nothing if the directory doesn't exist or if it doesn't constitute a dictionary.
open :: FilePath -> IO HistPLSource
Open the binary dictionary residing in the given directory. Raise an error if the directory doesn't exist or if it doesn't constitute a dictionary.
Query
Conversion
Save
Load
load :: FilePath -> IO (Maybe [BinEntry])Source
Load dictionary from a disk in a lazy manner. Return Nothing
if the path doesn't correspond to a binary representation of the
dictionary.
Modules
NLP.HistPL.Types module exports hierarchy of data types stored in the binary dictionary.
module NLP.HistPL.Types