rsgrammar.js

About

A JavaScript library used for generative writing — both narrative and poetry.
General notes about the project can be found below.

Nouns

  • NOUN CONSTRUCTOR: Noun(wordsingular, wordplural, gender, category);
    • // wordsingular – singular of term to be used
    • // wordplural – plural of term to be used
    • // gender – feminine; masculine; neuter
    • // categories – (arbitrary criterion) people, place, action, abstract…
  • var nounList = [array of nouns from constructor]; 
  • //Noun Functions
    • function MakePlural(nounChoice); //RETURNS nounChoice + “s” or “es”
      • This function is redundant…
    • AddArticle(nounChoice); // RETURNS chooseArticle + nounChoice;

Pronouns

  • PRONOUN CONSTRUCTOR: Pronoun(word, person, gender, number, case)
    • // word – term to be used
    • // person – 1st person (the one(s) speaking); 2nd person (the one(s) spoken to); 3rd person (the one(s) spoken about)
    • // gender – feminine; masculine; neuter
    • // number – singular; plural
    • // case – subjective, objective, dual (subjective or objective), possessive, possessive2, reflexive
  • pronounList = [array of pronouns from constructor];
    • //personal, reflexive/intensive, and possessive pronouns [array indices 0-38]
    • //demonstratives [array indices 39-42]
    • //all others (indefinite, relative, interrogative…) [array indices 43-88]

Verbs

  • Be
    • //word: “be”
    • //firstpresent: “am”
    • //secondpresent: “is”
    • //thirdpresent: “are”
    • //firstpast: “was”
    • //pasttense: “were”
    • //pastparticiple: “been”
  • auxillaryverbs = [array];
  • modalverbs = [array];
  • Regular Verbs
    • regularverbs = [array];
    • [CHOOSE RANDOM] var VerbChoiceReg = (regularverbs[Math.floor(Math.random()*regularverbs.length)]);
  • Irregular Verbs
    • irregularverbs = [array, 50];
      • CONSTRUCTOR: VerbIrregular(word, wordsingular, pasttense, pastparticiple); 
    • [CHOOSE RANDOM] var VerbChoiceIrreg = (irregularverbs[Math.floor(Math.random()* irregularverbs.length)]);
  • //Verb functions
    • MakeSingular(chooseVerb) // RETURNS chooseVerb + “s”, “es”, or “ies”
    • MakePast(chooseVerb) // RETURNS chooseVerb + “ed”
    • MakeInfinitive(chooseVerb) // RETURNS “to” + ” ” + chooseVerb;
    • MakeNoun(chooseVerb) // RETURNS chooseVerb + “ing”

Adjectives

  • CONSTRUCTOR: Adjective (word, type);
    • //word
    • //type – irregular, regular(er,est), comparative superlative
  • var qualifa = [array];
  • var compara = “more”;
  • var superla = “most”;
  • ComparativeAdjective() // RETURNS 
  • SuperlativeAdjective() // RETURNS
  • QualatativeAdjective () // RETURNS

Adverbs

  • //adverbs of manner
    • var advmanner = [array];
  • //adverbs of time
    • var advtime = [array];
  • //adverbs of place
    • var advplace = [array];
  • //adverbs from adjectives

Prepositions 

  • prepositions = [array];

Conjunctions

  • coordconj = [array];
  • adverbconj = [array];
  • subordconj = [array];

SENTENCE FORMATION

TYPES

  • Simple Sentence
  • Compound Sentence
  • Complex Sentence
  • Compound-Complex Sentence

PATTERNS

  • Subject + Action Verb
  • Subject + Action Verb + Direct Object
  • Subject + Action Verb + Indirect Object+ Direct Object
  • Subject + Action Verb + Adverb
  • Subject + Linking Verb + Predicate Nominative
  • Subject + Linking Verb + Predicate Adjective

CONSIDERATIONS

  • Any noun or pronoun may be modified by an article, adjective, or prepositional phrase (adjectival), including the noun in a prepositional phrase.
  • Any adjective may be modified by an adverb.
  • Any verb may be modified by an adverb or a prepositional phrase (adverbial).
  • Any adverb may be modified by an adverb.
  • Each sentence/clause can have up to three subjects.
  • Each sentence/clause can have up to three verbs.