Setting up the use of this module.

§1. This section simoly sets up the module in ways expected by foundation, and contains no code of interest. The following constant exists only in tools which use this module:

define LINGUISTICS_MODULE TRUE

§2. This module defines the following classes:

enum adjective_CLASS
enum article_CLASS
enum quantifier_CLASS
enum determiner_CLASS
enum grammatical_category_CLASS
enum linguistic_stock_item_CLASS
enum grammatical_usage_CLASS
enum verb_CLASS
enum verb_form_CLASS
enum verb_meaning_CLASS
enum verb_sense_CLASS
enum verb_usage_CLASS
enum verb_usage_tier_CLASS
enum preposition_CLASS
enum time_period_CLASS
enum noun_CLASS
enum noun_usage_CLASS
enum pronoun_CLASS
enum pronoun_usage_CLASS
enum small_word_set_CLASS
DECLARE_CLASS(adjective)
DECLARE_CLASS(article)
DECLARE_CLASS(quantifier)
DECLARE_CLASS(determiner)
DECLARE_CLASS(grammatical_category)
DECLARE_CLASS(linguistic_stock_item)
DECLARE_CLASS(grammatical_usage)
DECLARE_CLASS(verb)
DECLARE_CLASS(verb_form)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(verb_meaning, 100)
DECLARE_CLASS(verb_sense)
DECLARE_CLASS(verb_usage)
DECLARE_CLASS(verb_usage_tier)
DECLARE_CLASS(preposition)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(time_period, 100)
DECLARE_CLASS(noun)
DECLARE_CLASS(noun_usage)
DECLARE_CLASS(pronoun)
DECLARE_CLASS(pronoun_usage)
DECLARE_CLASS(small_word_set)

§3. Like all modules, this one must define a start and end function:

enum LINGUISTIC_STOCK_DA
enum TIME_PERIODS_DA
enum VERB_USAGES_DA
enum VERB_FORMS_DA
void LinguisticsModule::start(void) {
    Register this module's debugging log aspects3.1;
    Register this module's debugging log writers3.2;
    Declare new memory allocation reasons3.4;
    Stock::create_categories();
    Cardinals::enable_in_word_form();
    Articles::mark_for_preform();
    Prepositions::mark_for_preform();
}
void LinguisticsModule::end(void) {
}

§3.1. Register this module's debugging log aspects3.1 =

    Log::declare_aspect(LINGUISTIC_STOCK_DA, L"linguistic stock", FALSE, FALSE);
    Log::declare_aspect(TIME_PERIODS_DA, L"time periods", FALSE, FALSE);
    Log::declare_aspect(VERB_USAGES_DA, L"verb usages", FALSE, TRUE);
    Log::declare_aspect(VERB_FORMS_DA, L"verb forms", FALSE, TRUE);

§3.2. Register this module's debugging log writers3.2 =

    Writers::register_logger('t', Occurrence::log);
    Writers::register_logger('p', Prepositions::log);
    Writers::register_logger('w', Verbs::log_verb);
    Writers::register_logger('y', VerbMeanings::log);

§3.3. Not all of our memory will be claimed in the form of structures: now and then we need to use the equivalent of traditional malloc and calloc routines.

enum STOCK_MREASON
enum SWS_MREASON

§3.4. Declare new memory allocation reasons3.4 =

    Memory::reason_name(STOCK_MREASON, "linguistic stock array");
    Memory::reason_name(SWS_MREASON, "small word set array");

§4. This module uses syntax, and adds the following annotations to the syntax tree.

enum verbal_certainty_ANNOT         int: certainty level if known
enum sentence_is_existential_ANNOT  int: such as "there is a man"
enum linguistic_error_here_ANNOT    int: one of the errors occurred here
enum inverted_verb_ANNOT            int: an inversion of subject and object has occurred
enum possessive_verb_ANNOT          int: this is a non-relative use of "to have"
enum verb_ANNOT                     verb_usage: what's being done here
enum noun_ANNOT                     noun_usage: what's being done here
enum pronoun_ANNOT                  pronoun_usage: what's being done here
enum preposition_ANNOT              preposition: which preposition, if any, qualifies it
enum second_preposition_ANNOT       preposition: which further preposition, if any, qualifies it
enum verb_meaning_ANNOT             verb_meaning: what it means
enum nounphrase_article_ANNOT       int: definite or indefinite article: see below
enum plural_reference_ANNOT         int: used by PROPER NOUN nodes for evident plurals
enum gender_reference_ANNOT         int: used by PROPER NOUN nodes for evident genders
enum relationship_node_type_ANNOT   int: what kind of inference this assertion makes
enum implicitly_refers_to_ANNOT     int: this will implicitly refer to something
DECLARE_ANNOTATION_FUNCTIONS(verb, verb_usage)
DECLARE_ANNOTATION_FUNCTIONS(noun, noun_usage)
DECLARE_ANNOTATION_FUNCTIONS(pronoun, pronoun_usage)
DECLARE_ANNOTATION_FUNCTIONS(preposition, preposition)
DECLARE_ANNOTATION_FUNCTIONS(second_preposition, preposition)
DECLARE_ANNOTATION_FUNCTIONS(verb_meaning, verb_meaning)

MAKE_ANNOTATION_FUNCTIONS(verb, verb_usage)
MAKE_ANNOTATION_FUNCTIONS(noun, noun_usage)
MAKE_ANNOTATION_FUNCTIONS(pronoun, pronoun_usage)
MAKE_ANNOTATION_FUNCTIONS(preposition, preposition)
MAKE_ANNOTATION_FUNCTIONS(second_preposition, preposition)
MAKE_ANNOTATION_FUNCTIONS(verb_meaning, verb_meaning)

§5. This module requires words, which contains the Preform parser. When that initialises, it calls the following routine to improve its performance.

define PREFORM_OPTIMISER_WORDS_CALLBACK LinguisticsModule::preform_optimiser
int first_round_of_nt_optimisation_made = FALSE;
void LinguisticsModule::preform_optimiser(void) {
    Cardinals::preform_optimiser();
    VerbUsages::preform_optimiser();
    Prepositions::preform_optimiser();
    if (first_round_of_nt_optimisation_made == FALSE) {
        first_round_of_nt_optimisation_made = TRUE;
        Quantifiers::make_built_in();
    }
}