Copyright(c) Greg Kobele 2019
Maintainergkobele@uni-leipzig.de
Safe HaskellSafe

TSL

Description

This module implements Tier-based Strictly local string grammars, and parsing, generation, and learning algorithms for them:

Parsing
How could we use a grammar to understand (recognize) language data?
Generation
How could we use a grammar to construct a sentence?
Learning
How could we learn a grammar from language data?
Synopsis

Documentation

type Sentence a = [a] Source #

a sentence is a list of symbols

type Text a = [Sentence a] Source #

a text is a list of sentences

type TSL a = (Tier a, Grammar a) Source #

a TSL grammar consists of

  1. a tier, and
  2. an SL grammar

acceptTSL :: Eq a => TSL a -> Int -> Sentence a -> Bool Source #

determining whether a sentence is generated by the grammar is a matter of checking that its factors are permitted by the grammar

generateTSL :: Eq a => [a] -> Int -> TSL a -> [Sentence a] Source #

The generation algorithm first makes a tree of all the grammatical ways of adding a next letter to what we had before, then enumerates the nodes of this tree in a breadth-first fashion. The unfinished sentences are filtered out of this list of nodes, and then the remaining sentences are made pretty.

learnTSL :: Eq a => Int -> Text a -> TSL a Source #

The TSL learner works by first identifying the elements on a tier, and then by running the usual SL learner on the tier-projection of the input text. This implements the algorithm described by Jardine and McMullin.