darcs-2.4.4: a distributed, interactive, smart revision control systemSource codeContentsIndex
English
Description

This modules provides rudimentary natural language generation (NLG) utilities. That is, generating natural language from a machine representation. Initially, only English is supported at all. Representations are implemented for:

  • countable nouns (plurality); and * lists of clauses (foo, bar and/or baz).
Synopsis
englishNum :: Countable n => Int -> n -> ShowS
class Countable a where
plural :: a -> ShowS
singular :: a -> ShowS
newtype Noun = Noun String
data This = This Noun
orClauses :: [String] -> String
andClauses :: [String] -> String
intersperseLast :: String -> String -> [String] -> String
Documentation
englishNum :: Countable n => Int -> n -> ShowSSource
 englishNum 0 (Noun "watch") "" == "watches"
 englishNum 1 (Noun "watch") "" == "watch"
 englishNum 2 (Noun "watch") "" == "watches"
class Countable a whereSource
Things that have a plural and singular spelling
Methods
plural :: a -> ShowSSource
singular :: a -> ShowSSource
show/hide Instances
newtype Noun Source

This only distinguishes between nouns with a final -ch, and nouns which do not. More irregular nouns will just need to have their own type

 plural (Noun "batch") "" == "batches"
 plural (Noun "bat")   "" == "bats"
 plural (Noun "mouse") "" == "mouses" -- :-(
Constructors
Noun String
show/hide Instances
data This Source
 singular This (Noun "batch") "" == "this batch"
 plural   This (Noun "batch") "" == "these batches"
Constructors
This Noun
show/hide Instances
orClauses :: [String] -> StringSource

Given a list of things, combine them thusly:

 orClauses ["foo", "bar", "baz"] == "foo, bar or baz"
andClauses :: [String] -> StringSource
intersperseLast :: String -> String -> [String] -> StringSource
As intersperse, with a different separator for the last | interspersal.
Produced by Haddock version 2.6.1