data-named-0.6.1: Data types for named entities

Safe HaskellSafe
LanguageHaskell98

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

Instances

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

Methods

showsPrec :: Int -> IOB w a -> ShowS #

show :: IOB w a -> String #

showList :: [IOB w a] -> ShowS #

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

Functor Atom Source # 

Methods

fmap :: (a -> b) -> Atom a -> Atom b #

(<$) :: a -> Atom b -> Atom a #

Eq a => Eq (Atom a) Source # 

Methods

(==) :: Atom a -> Atom a -> Bool #

(/=) :: Atom a -> Atom a -> Bool #

Ord a => Ord (Atom a) Source # 

Methods

compare :: Atom a -> Atom a -> Ordering #

(<) :: Atom a -> Atom a -> Bool #

(<=) :: Atom a -> Atom a -> Bool #

(>) :: Atom a -> Atom a -> Bool #

(>=) :: Atom a -> Atom a -> Bool #

max :: Atom a -> Atom a -> Atom a #

min :: Atom a -> Atom a -> Atom a #

Show a => Show (Atom a) Source # 

Methods

showsPrec :: Int -> Atom a -> ShowS #

show :: Atom a -> String #

showList :: [Atom a] -> ShowS #

Binary a => Binary (Atom a) Source # 

Methods

put :: Atom a -> Put #

get :: Get (Atom a) #

putList :: [Atom a] -> Put #

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

Encode the forest with the IOB method.

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

Decode the forest using the IOB method.