"Toy grammatical words:"
{ $subsections a/an ?plural-article a10n comma-list }
-
-"An example application:"
-{ $subsections or-markup-example $or-markup-example } ;
+;
{ pluralize ?pluralize plural? count-of-things singularize singular? } related-words
-{ a/an ?plural-article a10n comma-list $or-markup-example or-markup-example } related-words
+{ a/an ?plural-article a10n comma-list } related-words
HELP: singularize
{ $values { "word" string } { "singular" string } }
} ;
HELP: a/an
-{ $values { "word" string } { "article" { $or-markup-example "\"a\"" "\"an\"" } } }
+{ $values { "word" string } { "article" { $or "\"a\"" "\"an\"" } } }
{ $description "Gives the proper indefinite singular article (" { $emphasis "a" } " or " { $emphasis "an" } ") for the word. For words which begin with a vowel sound, " { $emphasis "an" } " is used, whereas " { $emphasis "a" } " is used for words which begin with a consonant sound." }
{ $notes "The output does not contain the input. The output of this word is always a singular article, regardless of the plurality of the input." }
{ $examples
} ;
HELP: ?plural-article
-{ $values { "word" string } { "article" { $or-markup-example "\"a\"" "\"an\"" "\"the\"" } } }
+{ $values { "word" string } { "article" { $or "\"a\"" "\"an\"" "\"the\"" } } }
{ $description "Output the proper article given the plurality and first letter of the input. Unlike " { $link a/an } " this word handles plural inputs by outputting the definite " { $emphasis "\"the\"" } ". If the input is singular as determined by " { $link singular? } " this word operates like " { $link a/an } "." }
{ $notes { $list "English lacks a plural indefinite article, so the plural definite is used here instead." $keep-case $0-plurality } }
{ $examples
"a cat, a peach, or an object"
}
} ;
-
-HELP: or-markup-example
-{ $values { "classes" "a sequence of words" } { "markup" "a sequence of markup elements" } }
-{ $description "Used to implement " { $link $or-markup-example } " and demonstrate " { $link comma-list } "." }
-{ $examples { "See the examples in " { $link $or-markup-example } "." } } ;
-
-HELP: $or-markup-example
-{ $values { "classes" "a sequence of words" } }
-{ $description "An example to demonstrate a use-case for " { $link comma-list } ". Works like the " { $link $or } " and " { $link ($instance) } " words from " { $vocab-link "help.markup" } "." }
-{ $examples
- { $markup-example
- { $or-markup-example "cat" "octopus" "animal" object pair number array string sequence assoc "bird" } print-element
- }
-} ;
{ { "a" ", " "b" ", " "x" ", and " "c" } }
[ { "a" "b" "x" "c" } "and" comma-list ] unit-test
-
-{ {
- { "an " { $link object } } ", "
- { "a " { $link pair } } ", "
- { "a " { $link number } } ", "
- { "an " { $link array } } ", "
- { "a " { $link string } } ", "
- { "a " { $link sequence } } ", or "
- { "an " { $link assoc } }
-} } [
- { object pair number array string sequence assoc }
- or-markup-example
- ! an object, a pair, a number, an array, a string, a sequence, or an assoc
-] unit-test
-
-{ {
- { "an " { $link object } }
-} } [ { object } or-markup-example ] unit-test
-
-{ {
- { "an " { $link object } } " or "
- { "a " { $link pair } }
-} } [ { object pair } or-markup-example ] unit-test
-
-{ {
- { "an " { $link object } } ", "
- { "a " { $link pair } } ", or "
- { "a " { $snippet "thing" } }
-} } [ { object pair "thing" } or-markup-example ] unit-test
! Copyright (C) 2015, 2018 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: accessors arrays assocs combinators help.markup kernel
-literals math math.order math.parser sequences splitting unicode
-words ;
+USING: arrays assocs combinators kernel literals math math.order
+math.parser sequences splitting unicode ;
IN: english
<PRIVATE
] dip over length dup 3 >= [
[ 3 > ", " " " ? " " surround ] [ 2 - pick set-nth ] bi
] [ 2drop ] if ;
-
-: or-markup-example ( classes -- markup )
- [
- dup word? [
- [ name>> ] keep \ $link
- ] [
- dup \ $snippet
- ] if swap 2array [ a/an " " append ] dip 2array
- ] map "or" comma-list ;
-
-: $or-markup-example ( classes -- )
- or-markup-example print-element ;
{ $example
"USING: help.lint.coverage ;"
"\"english\" vocab-help-coverage."
-"[english] $or-markup-example: full help coverage
-[english] ?plural-article: full help coverage
+"[english] ?plural-article: full help coverage
[english] ?pluralize: full help coverage
[english] a/an: full help coverage
[english] a10n: full help coverage
[english] comma-list: full help coverage
[english] count-of-things: full help coverage
-[english] or-markup-example: full help coverage
[english] plural?: full help coverage
[english] pluralize: full help coverage
[english] singular?: full help coverage
{ $example
"USING: help.lint.coverage ;"
"\"english\" t prefix-help-coverage."
-"[english] $or-markup-example: full help coverage
-[english] ?plural-article: full help coverage
+"[english] ?plural-article: full help coverage
[english] ?pluralize: full help coverage
[english] a/an: full help coverage
[english] a10n: full help coverage
[english] comma-list: full help coverage
[english] count-of-things: full help coverage
-[english] or-markup-example: full help coverage
[english] plural?: full help coverage
[english] pluralize: full help coverage
[english] singular?: full help coverage
"USING: help.lint.coverage prettyprint ;"
"\"english\" t <prefix-help-coverage> ..."
"{
- T{ word-help-coverage
- { word-name $or-markup-example }
- { 100%-coverage? t }
- }
T{ word-help-coverage
{ word-name ?plural-article }
{ 100%-coverage? t }
{ word-name count-of-things }
{ 100%-coverage? t }
}
- T{ word-help-coverage
- { word-name or-markup-example }
- { 100%-coverage? t }
- }
T{ word-help-coverage
{ word-name plural? }
{ 100%-coverage? t }
"USING: help.lint.coverage prettyprint ;"
"\"english\" <vocab-help-coverage> ..."
"{
- T{ word-help-coverage
- { word-name $or-markup-example }
- { 100%-coverage? t }
- }
T{ word-help-coverage
{ word-name ?plural-article }
{ 100%-coverage? t }
{ word-name count-of-things }
{ 100%-coverage? t }
}
- T{ word-help-coverage
- { word-name or-markup-example }
- { 100%-coverage? t }
- }
T{ word-help-coverage
{ word-name plural? }
{ 100%-coverage? t }