hist-pl-types (empty) → 0.1.0
raw patch · 4 files changed
+216/−0 lines, 4 filesdep +basedep +binarydep +textsetup-changed
Dependencies added: base, binary, text, text-binary
Files
- LICENSE +26/−0
- Setup.lhs +4/−0
- hist-pl-types.cabal +31/−0
- src/NLP/HistPL/Types.hs +155/−0
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright (c) 2012, IPI PAN+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ hist-pl-types.cabal view
@@ -0,0 +1,31 @@+name: hist-pl-types+version: 0.1.0+synopsis: Types in the historical dictionary of Polish+description:+ The library provides a data type hierarchy which mirrors the hierarchy+ of elements present in the original, LMF representation of the+ historical dictionary of Polish.+license: BSD3+license-file: LICENSE+cabal-version: >= 1.6+copyright: Copyright (c) 2012 IPI PAN+author: Jakub Waszczuk+maintainer: waszczuk.kuba@gmail.com+stability: experimental+category: Natural Language Processing+homepage: https://github.com/kawu/hist-pl/tree/master/types+build-type: Simple++library+ hs-source-dirs: src+ exposed-modules: NLP.HistPL.Types+ build-depends: base >= 4 && < 5 + , text+ , binary+ , text-binary >= 0.1 && < 0.2++ ghc-options: -Wall++source-repository head+ type: git+ location: https://github.com/kawu/hist-pl.git
+ src/NLP/HistPL/Types.hs view
@@ -0,0 +1,155 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances #-}++-- | A data type hierarchy provided by this module mirrors+-- the hierarchy of elements present in the original, LMF+-- representation of the historical dictionary of Polish.++module NLP.HistPL.Types+( Repr (..)+, HasRepr (..)+, text+, WordForm (..)+, Lemma (..)+, RelForm (..)+, Definition (..)+, Context (..)+, SynBehaviour (..)+, Sense (..)+, LexEntry (..)+) where++import Control.Applicative ((<$>), (<*>))+import Data.Binary (Binary, put, get)+import qualified Data.Text as T+import Data.Text.Binary ()++-- | Written representation of a form or a text.+data Repr = Repr+ { writtenForm :: T.Text+ , language :: T.Text+ , sourceID :: Maybe T.Text }+ deriving (Show, Read, Eq, Ord)++instance Binary Repr where+ put Repr{..} = do+ put writtenForm+ put language+ put sourceID+ get = Repr <$> get <*> get <*> get++-- | A class of objects with a written representation.+class HasRepr t where+ repr :: t -> [Repr]++instance HasRepr [Repr] where+ repr = id++-- | Get textual representations of an object.+text :: HasRepr t => t -> [T.Text]+text = map writtenForm . repr+{-# INLINE text #-}++-- | A word form.+newtype WordForm = WordForm [Repr]+ deriving (Show, Read, Eq, Ord, Binary, HasRepr)++-- | A related form.+data RelForm = RelForm+ { relRepr :: [Repr]+ , relTo :: T.Text }+ deriving (Show, Read, Eq, Ord)++instance Binary RelForm where+ put RelForm{..} = do+ put relRepr+ put relTo+ get = RelForm <$> get <*> get++instance HasRepr RelForm where+ repr = relRepr++-- | A lemma (base) form.+newtype Lemma = Lemma [Repr]+ deriving (Show, Read, Eq, Ord, Binary, HasRepr)++-- | A definition of the lexeme sense.+newtype Definition = Definition [Repr]+ deriving (Show, Read, Eq, Ord, Binary, HasRepr)++-- | A context in which a given sense is illustrated.+newtype Context = Context [Repr]+ deriving (Show, Read, Eq, Ord, Binary, HasRepr)++-- | A description of a syntactic behaviour.+data SynBehaviour = SynBehaviour+ { synRepr :: [Repr]+ , synSenseIds :: [T.Text] }+ deriving (Show, Read, Eq, Ord)++instance HasRepr SynBehaviour where+ repr = synRepr++instance Binary SynBehaviour where+ put SynBehaviour{..} = do+ put synRepr+ put synSenseIds+ get = SynBehaviour <$> get <*> get++-- | A potential sense of a given lexeme.+data Sense = Sense+ { senseId :: Maybe T.Text+ , style :: [T.Text]+ , defs :: [Definition]+ , cxts :: [Context] }+ deriving (Show, Read, Eq, Ord)++instance Binary Sense where+ put Sense{..} = do+ put senseId+ put style+ put defs+ put cxts+ get = Sense <$> get <*> get <*> get <*> get++-- | A description of a lexeme.+data LexEntry = LexEntry {+ -- | An ID of the lexical entry.+ lexID :: T.Text+ -- | A line reference number. Provisional field.+ , lineRef :: Maybe T.Text+ -- | A status of the lexeme. Provisional field.+ , status :: Maybe T.Text+ -- | Potential parts of speech.+ , pos :: [T.Text]+ -- | A base form.+ , lemma :: Lemma+ -- | Word forms of the lexeme.+ , forms :: [WordForm]+ -- | A list of component identifiers (only when the entry+ -- represents a compound lexeme).+ , components :: [T.Text]+ -- | A list of potential syntactic behaviours of the lexeme.+ , syntactic :: [SynBehaviour]+ -- | A list of potential semantic descriptions.+ , senses :: [Sense]+ -- | Forma related to the lexeme.+ , related :: [RelForm] }+ deriving (Show, Read, Eq, Ord)++instance Binary LexEntry where+ put LexEntry{..} = do+ put lexID+ put lineRef+ put status+ put pos+ put lemma+ put forms+ put components+ put syntactic+ put senses+ put related+ get = LexEntry <$> get <*> get <*> get <*> get <*> get+ <*> get <*> get <*> get <*> get <*> get