• Jump To … +
    abbreviations.js adjectives.js convertables.js dates.js demonyms.js firstnames.js honourifics.js irregular_nouns.js irregular_verbs.js misc.js multiples.js numbers.js organisations.js phrasal_verbs.js places.js uncountables.js verbs.js fns.js index.js lexicon.js negate.js passive_voice.js contractions.js fancy_lumping.js grammar_rules.js parts_of_speech.js phrasal_verbs.js tagger.js word_rules.js question.js sentence.js statement.js tense.js adjective.js to_adverb.js to_comparative.js to_noun.js to_superlative.js adverb.js to_adjective.js is_acronym.js article.js date.js date_rules.js is_date.js parse_date.js is_plural.js is_uncountable.js noun.js is_organisation.js organisation.js gender.js is_person.js parse_name.js person.js is_place.js place.js pluralize.js pronoun.js singularize.js is_value.js numbers.js to_number.js units.js value.js term.js conjugate.js from_infinitive.js predict_form.js suffix_rules.js to_actor.js to_infinitive.js negate.js verb.js sentence_parser.js text.js
  • verb.js

  • ¶
    'use strict';
    const Term = require('../term.js');
    const conjugate = require('./conjugate/conjugate.js');
    const negate = require('./negate.js');
    
    const verbTags = {
      infinitive: 'Infinitive',
      present: 'PresentTense',
      past: 'PastTense',
      gerund: 'Gerund',
      actor: 'Actor',
      future: 'FutureTense',
      pluperfect: 'PluperfectTense',
      perfect: 'PerfectTense',
    
      PerfectTense: 'PerfectTense',
      PluperfectTense: 'PluperfectTense',
      FutureTense: 'FutureTense',
      PastTense: 'PastTense',
      PresentTense: 'PresentTense',
    };
    
    class Verb extends Term {
      constructor(str, tag) {
        super(str);
        this.tag = tag;
        this.pos['Verb'] = true;
        this.conjugations = {}; //cached conjugations
  • ¶

    if we’ve been told which

        this.pos[tag] = true;
        if (tag && verbTags[tag]) {
          this.conjugations[tag] = this.normal;
        }
      }
  • ¶

    retrieve a specific form

      conjugation() {
  • ¶

    check cached conjugations

        this.conjugations = this.conjugate();
        let keys = Object.keys(this.conjugations);
        for(let i = 0; i < keys.length; i++) {
          if (this.conjugations[keys[i]] === this.normal) {
            return verbTags[keys[i]];
          }
        }
        return verbTags[predict(this.normal)];
      }
    
      conjugate() {
        this.conjugations = conjugate(this.normal);
        return this.conjugations;
      }
      to_past() {
        let tense = 'past';
        if (!this.conjugations[tense]) {
          this.conjugate(this.normal);
        }
        this.tag = verbTags[tense];
        this.changeTo(this.conjugations[tense]);
        return this.conjugations[tense];
      }
      to_present() {
        let tense = 'present';
        if (!this.conjugations[tense]) {
          this.conjugate(this.normal);
        }
        this.tag = verbTags[tense];
        this.changeTo(this.conjugations[tense]);
        return this.conjugations[tense];
      }
      to_future() {
        let tense = 'future';
        if (!this.conjugations[tense]) {
          this.conjugate(this.normal);
        }
        this.tag = verbTags[tense];
        this.changeTo(this.conjugations[tense]);
        return this.conjugations[tense];
      }
  • ¶

    is this verb negative already?

      isNegative() {
        const str = this.normal;
        if (str.match(/(n't|\bnot\b)/)) {
          return true;
        }
        return false;
      }
    
      negate(form) {
        if (this.isNegative()) {
          return this.text;
        }
        this.changeTo(negate(this, form));
        return this.text;
    
      }
    
    }
    Verb.fn = Verb.prototype;
  • ¶

    let v = new Verb(“walk”, “asdf”) console.log(v.form())

    module.exports = Verb;