partage-0.1.0.1: Parsing factorized

Safe HaskellNone
LanguageHaskell2010

NLP.Partage.Earley

Contents

Description

Earley-style TAG parsing based on automata, with a distinction between active and passive items.

Synopsis

Earley-style parsing

All the parsing functions described below employ the NLP.Partage.Auto.DAWG grammar representation. You can also pre-compile your own automaton and use it with e.g. parseAuto.

recognize Source

Arguments

:: (Ord t, Ord n) 
=> FactGram n t

The grammar (set of rules)

-> [Set t]

Input sentence

-> IO Bool 

Does the given grammar generate the given sentence? Uses the earley algorithm under the hood.

recognizeFrom Source

Arguments

:: (Ord t, Ord n) 
=> FactGram n t

The grammar (set of rules)

-> n

The start symbol

-> [Set t]

Input sentence

-> IO Bool 

Does the given grammar generate the given sentence from the given non-terminal symbol (i.e. from an initial tree with this symbol in its root)? Uses the earley algorithm under the hood.

parse Source

Arguments

:: (Ord t, Ord n) 
=> FactGram n t

The grammar (set of rules)

-> n

The start symbol

-> [Set t]

Input sentence

-> IO (Set (Tree n t)) 

Parse the given sentence and return the set of parsed trees.

earley Source

Arguments

:: (Ord t, Ord n) 
=> FactGram n t

The grammar (set of rules)

-> [Set t]

Input sentence

-> IO (Hype n t) 

Perform the earley-style computation given the grammar and the input sentence.

With automata precompiled

recognizeAuto Source

Arguments

:: (Ord t, Ord n) 
=> GramAuto n t

Grammar automaton

-> [Set t]

Input sentence

-> IO Bool 

recognizeFromAuto Source

Arguments

:: (Ord t, Ord n) 
=> GramAuto n t

Grammar automaton

-> n

The start symbol

-> [Set t]

Input sentence

-> IO Bool 

parseAuto Source

Arguments

:: (Ord t, Ord n) 
=> GramAuto n t

Grammar automaton

-> n

The start symbol

-> [Set t]

Input sentence

-> IO (Set (Tree n t)) 

See parse.

earleyAuto Source

Arguments

:: (Ord t, Ord n) 
=> GramAuto n t

Grammar automaton

-> [Set t]

Input sentence

-> IO (Hype n t) 

See earley.

Parsing trace (hypergraph)

data Hype n t Source

A hypergraph dynamically constructed during parsing.

Extracting parsed trees

parsedTrees Source

Arguments

:: (Ord n, Ord t) 
=> Hype n t

Final state of the earley parser

-> n

The start symbol

-> Int

Length of the input sentence

-> Set (Tree n t) 

Extract the set of parsed trees obtained on the given input sentence. Should be run on the result of the earley algorithm.

Stats

hyperNodesNum :: Hype n t -> Int Source

Number of nodes in the parsing hypergraph.

hyperEdgesNum :: forall n t. Hype n t -> Int Source

Number of edges in the parsing hypergraph.

Printing

printHype :: (Show n, Show t) => Hype n t -> IO () Source

Print the hypergraph edges.

Sentence position

type Pos = Int Source

A position in the input sentence.