data-named-0.4.0: Data types for named entities

Safe HaskellSafe-Inferred

Data.Named.IOB

Description

IOB encoding method extended to forests.

Example:

>>> :m Data.Named.IOB Data.Named.Tree Text.Named.Enamex Data.Text.Lazy
>>> let enamex = pack "<x>w1.1\\ w1.2</x> w2 <y><z>w3</z> w4</y>"
>>> putStr . drawForest . mapForest show . parseForest $ enamex
Left "x"
|
`- Right "w1.1 w1.2"
,
Right "w2"
,
Left "y"
|
+- Left "z"
|  |
|  `- Right "w3"
|
`- Right "w4"
>>> mapM_ print . encodeForest . parseForest $ enamex
IOB {word = "w1.1 w1.2", label = [B "x"]}
IOB {word = "w2", label = []}
IOB {word = "w3", label = [B "y",B "z"]}
IOB {word = "w4", label = [I "y"]}

Synopsis

Documentation

data IOB w a Source

An IOB data structure consists of a word with a corresponding compound label.

Constructors

IOB 

Fields

word :: w
 
label :: Label a
 

Instances

(Show w, Show a) => Show (IOB w a) 

type Label a = [Atom a]Source

A Label consists of a list of atomic Atom labels.

data Atom a Source

An Atom is the atomic label with additional marker.

Constructors

B a

Beginning marker

I a

Inside marker

Instances

Eq a => Eq (Atom a) 
(Eq (Atom a), Ord a) => Ord (Atom a) 
Show a => Show (Atom a) 

encodeForest :: NeForest a w -> [IOB w a]Source

Encode the forest with the IOB method.

decodeForest :: Eq a => [IOB w a] -> NeForest a wSource

Decode the forest using the IOB method.