-
Notifications
You must be signed in to change notification settings - Fork 2
/
Data.hs
47 lines (36 loc) · 1.12 KB
/
Data.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module Data where
import Control.Applicative ((<$>), (<*>))
import Data.Binary (get, put, Binary)
import Data.Vector (Vector)
import Data.Vector.Binary ()
import Data.DAWG.Static (DAWG)
import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Text.Binary
import Grammem
type TagNum = Int
type ParadigmNum = Int
type Tag = ByteString
type Prefix = ByteString
type Suffix = ByteString
type Tags = Vector Tag
type Paradigms = Vector Paradigm
type TParadigms = Vector TParadigm
type Tegs = Vector [Teg]
type Paradigm = [(Prefix, Suffix, TagNum)]
type TParadigm = [(Text, Text, TagNum)]
data Morph = Morph
{ tags :: !Tegs
, paradigms :: !TParadigms
, dict :: !(DAWG Char () (Vector ParadigmNum))
}
instance Binary Morph where
put x = put (tags x) >> put (paradigms x) >> put (dict x)
get = Morph <$> get <*> get <*> get
--------------------------------- const ----------------------------------------
dictFile, tagsFile, paradigmsFile, wordsFile :: String
dictFile = "dict.opcorpora.txt"
tagsFile = "tags.bin"
paradigmsFile = "paradigms.bin"
wordsFile = "words.bin"
dawgDict = "dawg.dict"