darcs-2.16.4: a distributed, interactive, smart revision control system
Copyright2008 Eric Kow
LicenseGPL
Maintainerdarcs-devel@darcs.net
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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

Documentation

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

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

class Countable a where Source #

Things that have a plural and singular spelling

Methods

plural :: a -> ShowS Source #

singular :: a -> ShowS Source #

Instances

Instances details
Countable This Source # 
Instance details

Defined in Darcs.Util.English

Countable Pronoun Source # 
Instance details

Defined in Darcs.Util.English

Countable Noun Source # 
Instance details

Defined in Darcs.Util.English

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 

Instances

Instances details
Countable Noun Source # 
Instance details

Defined in Darcs.Util.English

data Pronoun Source #

Constructors

It 

Instances

Instances details
Countable Pronoun Source # 
Instance details

Defined in Darcs.Util.English

data This Source #

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

Constructors

This Noun 

Instances

Instances details
Countable This Source # 
Instance details

Defined in Darcs.Util.English

andClauses :: [String] -> String Source #

Given a list of things, combine them thusly:

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

orClauses :: [String] -> String Source #

Given a list of things, combine them thusly:

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

capitalize :: String -> String Source #

Capitalize the first letter of a word