darcs-2.18.5: a distributed, interactive, smart revision control system

Copyright | 2008 Eric Kow
License | GPL
Maintainer | darcs-devel@darcs.net
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Darcs.Util.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 Pronoun = It
- data This = This Noun
- andClauses :: [String] -> String
- orClauses :: [String] -> String
- anyOfClause :: [String] -> Doc
- itemizeVertical :: Int -> [String] -> Doc
- itemize :: String -> [String] -> String
- presentParticiple :: String -> String
- capitalize :: String -> String

# Documentation

englishNum :: Countable n => Int -> n -> ShowS #

    englishNum 0 (Noun "watch") "" == "watches"
    englishNum 1 (Noun "watch") "" == "watch"
    englishNum 2 (Noun "watch") "" == "watches"

class Countable a where #

Things that have a plural and singular spelling

Methods

plural :: a -> ShowS #

singular :: a -> ShowS #

#### Instances

Instances details

Countable Noun # |
Instance details Defined in Darcs.Util.English Methods plural :: Noun -> ShowS # singular :: Noun -> ShowS #
Countable Pronoun # |
Instance details Defined in Darcs.Util.English Methods plural :: Pronoun -> ShowS # singular :: Pronoun -> ShowS #
Countable This # |
Instance details Defined in Darcs.Util.English Methods plural :: This -> ShowS # singular :: This -> ShowS #

newtype Noun #

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 |

#### Instances

Instances details

Countable Noun # |
Instance details Defined in Darcs.Util.English Methods plural :: Noun -> ShowS # singular :: Noun -> ShowS #

data Pronoun #

Constructors

It |

#### Instances

Instances details

Countable Pronoun # |
Instance details Defined in Darcs.Util.English Methods plural :: Pronoun -> ShowS # singular :: Pronoun -> ShowS #

data This #

    singular This (Noun "batch") "" == "this batch"
    plural   This (Noun "batch") "" == "these batches"

Constructors

This Noun |

#### Instances

Instances details

Countable This # |
Instance details Defined in Darcs.Util.English Methods plural :: This -> ShowS # singular :: This -> ShowS #

andClauses :: [String] -> String #

Given a list of things, combine them thusly:

    orClauses ["foo", "bar", "baz"] == "foo, bar or baz"

orClauses :: [String] -> String #

Given a list of things, combine them thusly:

    orClauses ["foo", "bar", "baz"] == "foo, bar or baz"

anyOfClause :: [String] -> Doc #

itemizeVertical :: Int -> [String] -> Doc #

itemize :: String -> [String] -> String #

presentParticiple :: String -> String #

capitalize :: String -> String #

Capitalize the first letter of a word