hist-pl-lexicon-0.4.0: A binary representation of the historical dictionary of Polish

Safe HaskellNone

NLP.HistPL.Lexicon

Contents

Description

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.Lexicon 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"]]

Synopsis

Dictionary

data HistPL Source

A binary dictionary holds additional info of type a for every entry and additional info of type b for every word form.

data Code Source

Code of word form origin.

Constructors

Orig

only from historical dictionary

Both

from both historical and another dictionary

Copy

only from another dictionary

Instances

Key

type Key = Key UIDSource

A dictionary key which uniquely identifies the lexical entry.

type UID = IntSource

A unique identifier among entries with the same keyForm.

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

lookup :: HistPL -> Text -> IO [(LexEntry, Code)]Source

Lookup the form in the dictionary.

lookupMany :: HistPL -> [Text] -> IO [(LexEntry, Code)]Source

Lookup a set of forms in the dictionary.

getIndex :: HistPL -> IO [Key]Source

List of dictionary keys.

tryWithKey :: HistPL -> Key -> IO (Maybe LexEntry)Source

Extract lexical entry with a given key. Return Nothing if there is no entry with such a key.

withKey :: HistPL -> Key -> IO LexEntrySource

Extract lexical entry with a given key. Raise error if there is no entry with such a key.

Conversion

Save

save :: FilePath -> [(LexEntry, Set Text)] -> IO HistPLSource

Construct dictionary from a list of lexical entries and save it in the given directory. To each entry an additional set of forms can be assigned.

Load

load :: HistPL -> IO [(Key, LexEntry)]Source

Load all lexical entries in a lazy manner.

Modules

NLP.HistPL.Types module exports hierarchy of data types stored in the binary dictionary.