drasil-lang-0.1.60.0: A framework for code and document generation for scientific software - Language SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Drasil.NounPhrase

Synopsis

Types

class NounPhrase n where Source #

Methods

phraseNP :: n -> Sentence Source #

Retrieves singular form of term. Ex. "the quick brown fox".

pluralNP :: n -> PluralForm Source #

Retrieves plural form of term. Ex. "the quick brown foxes".

sentenceCase :: n -> (NP -> Sentence) -> Capitalization Source #

Retrieves the singular form and applies a captalization rule (usually capitalizes the first word) to produce a Sentence. Ex. "The quick brown fox".

titleCase :: n -> (NP -> Sentence) -> Capitalization Source #

Retrieves the singular form and applies a captalization rule (usually capitalizes all words) to produce a Sentence. Ex. "The Quick Brown Fox".

Instances

Instances details
NounPhrase NP Source #

Defines NP as a NounPhrase. Default capitalization rules for proper and common nouns are CapFirst for sentence case and CapWords for title case. Also accepts a Phrase where the capitalization case may be specified.

Instance details

Defined in Language.Drasil.NounPhrase

Methods

phraseNP :: NP -> Sentence Source #

pluralNP :: NP -> PluralForm Source #

sentenceCase :: NP -> (NP -> Sentence) -> Capitalization Source #

titleCase :: NP -> (NP -> Sentence) -> Capitalization Source #

data NP Source #

For nouns and NounPhrases. May be constructed from a proper noun, common noun, or phrase (Sentence) and their respective pluralization and capitalization rules.

Instances

Instances details
NounPhrase NP Source #

Defines NP as a NounPhrase. Default capitalization rules for proper and common nouns are CapFirst for sentence case and CapWords for title case. Also accepts a Phrase where the capitalization case may be specified.

Instance details

Defined in Language.Drasil.NounPhrase

Methods

phraseNP :: NP -> Sentence Source #

pluralNP :: NP -> PluralForm Source #

sentenceCase :: NP -> (NP -> Sentence) -> Capitalization Source #

titleCase :: NP -> (NP -> Sentence) -> Capitalization Source #

Phrase Accessors

atStartNP :: NounPhrase n => n -> Capitalization Source #

Singular sentence case.

Helper function for getting the sentence case of a noun phrase.

atStartNP' :: NounPhrase n => n -> Capitalization Source #

Plural sentence case.

Helper function for getting the sentence case of a noun phrase.

titleizeNP :: NounPhrase n => n -> Capitalization Source #

Singular title case.

Helper function for getting the title case of a noun phrase.

titleizeNP' :: NounPhrase n => n -> Capitalization Source #

Plural title case.

Helper function for getting the title case of a noun phrase.

Constructors

Common Noun Constructors

cn :: String -> NP Source #

Self plural.

Constructs a common noun which capitalizes the first letter of the first word at the beginning of a sentence.

cn' :: String -> NP Source #

Plural form simply adds "s" (ex. dog -> dogs).

Constructs a common noun which capitalizes the first letter of the first word at the beginning of a sentence.

cn'' :: String -> NP Source #

Plural form adds "e" (ex. formula -> formulae).

Constructs a common noun which capitalizes the first letter of the first word at the beginning of a sentence.

cn''' :: String -> NP Source #

Plural form adds "es" (ex. bush -> bushes).

Constructs a common noun which capitalizes the first letter of the first word at the beginning of a sentence.

cnICES :: String -> NP Source #

Construct a common noun that pluralizes by dropping the last two letters and adding an "ices" ending (ex. matrix -> matrices).

cnIES :: String -> NP Source #

Constructs a common noun that pluralizes by dropping the last letter and adding an "ies" ending (ex. body -> bodies).

cnIP :: String -> PluralRule -> NP Source #

Constructs a common noun that allows you to specify the pluralization rule (as in pnIrr).

cnIS :: String -> NP Source #

Constructs a common noun that pluralizes by dropping the last two letters and adding "es" (ex. analysis -> analyses).

cnIrr :: String -> PluralRule -> CapitalizationRule -> NP Source #

Common noun that allows you to specify both the pluralization rule and the capitalization rule for sentence case (if the noun is used at the beginning of a sentence).

cnUM :: String -> NP Source #

Constructs a common noun that pluralizes by dropping the last two letters and adding "a" (ex. datum -> data).

Proper Noun Constructors

pn :: String -> NP Source #

Self plural.

Constructs a Proper Noun, it is always capitalized as written.

pn' :: String -> NP Source #

Plural form simply adds "s" (ex. Henderson -> Hendersons).

Constructs a Proper Noun, it is always capitalized as written.

pn'' :: String -> NP Source #

Plural form adds "e".

Constructs a Proper Noun, it is always capitalized as written.

pn''' :: String -> NP Source #

Plural form adds "es" (ex. Bush -> Bushes).

Constructs a Proper Noun, it is always capitalized as written.

pnIrr :: String -> PluralRule -> NP Source #

Constructs a ProperNoun with a custom plural rule (using IrregPlur from PluralRule). First argument is the String representing the noun, second is the rule.

Noun Phrase Constructors

nounPhrase :: String -> PluralString -> NP Source #

Creates a NP with a given singular and plural form (as Strings) that capitalizes the first letter of the first word for sentence case.

nounPhrase' :: String -> PluralString -> CapitalizationRule -> NP Source #

Similar to nounPhrase, but takes a specified capitalization rule for the sentence case.

nounPhrase'' :: Sentence -> PluralForm -> CapitalizationRule -> CapitalizationRule -> NP Source #

Custom noun phrase constructor that takes a singular form (Sentence), plural form (Sentence), sentence case capitalization rule, and title case capitalization rule.

nounPhraseSP :: String -> NP Source #

For things that should not be pluralized (or are self-plural). Works like nounPhrase, but with only the first argument.

nounPhraseSent :: Sentence -> NP Source #

Similar to nounPhrase, except it only accepts one Sentence. Used for Requirements, Assumptions, LikelyChanges, etc. to allow for referencing. Plural case is just AddS.

Combinators

compoundPhrase :: (NounPhrase a, NounPhrase b) => a -> b -> NP Source #

Combine two noun phrases. The singular form becomes phrase from t1 followed by phrase of t2. The plural becomes phrase of t1 followed by plural of t2. Uses standard CapFirst sentence case and CapWords title case. For example: compoundPhrase system constraint will have singular form "system constraint" and plural "system constraints".

compoundPhrase' :: NP -> NP -> NP Source #

Similar to compoundPhrase, but the sentence case is the same as the title case (CapWords).

compoundPhrase'' :: (NP -> Sentence) -> (NP -> Sentence) -> NP -> NP -> NP Source #

Similar to compoundPhrase', but accepts two functions that will be used to construct the plural form. For example, compoundPhrase'' plural phrase system constraint would have the plural form "systems constraint".

compoundPhrase''' :: (NP -> Sentence) -> NP -> NP -> NP Source #

Similar to compoundPhrase, but used when you need a special function applied to the first term of both singular and pluralcases (eg. short or plural).

compoundPhraseP1 :: NP -> NP -> NP Source #

Similar to compoundPhrase, but pluralizes the first NP for both singular and plural cases.

Re-exported Types

data CapitalizationRule Source #

Capitalization rules.

Constructors

CapFirst

Capitalize the first letter of the first word only.

CapWords

Capitalize the first letter of each word.

Replace Sentence

Replace the noun phrase with the given Sentence. Used for custom capitalization.

data PluralRule Source #

Pluralization rules.

Constructors

AddS

Add "s" to the end of the noun phrase.

AddE

Add "e" to the end of the noun phrase.

AddES

Add "es" to the end of the noun phrase.

SelfPlur

The noun phrase is already plural.

IrregPlur (String -> String)

Apply the given function to the noun phrase to get the plural.