Commit c9939d89 authored by Ludan Stoecklé's avatar Ludan Stoecklé

progressive tenses

parent 82efdcd5
{
"name": "english-verbs-gerund",
"version": "0.1.0",
"name": "english-verbs-gerunds",
"version": "0.0.1",
"description": "English irregular gerunds list (-ing), based on WordNet",
"main": "dist/gerunds.json",
"scripts": {
......
XXXXXXXXXXXXXX TODO
WILL
GOING_TO
use `english-verbs-irregular`
rules for `ing`
# English verbs
## Features
Agreement of English verbs, based on `compromise` lib.
......
export type EnglishTense = 'SIMPLE_PAST' | 'PAST' | 'SIMPLE_PRESENT' | 'PRESENT' | 'SIMPLE_FUTURE' | 'FUTURE';
const tenses = ['SIMPLE_PAST', 'PAST', 'SIMPLE_PRESENT', 'PRESENT', 'SIMPLE_FUTURE', 'FUTURE'];
import Gerunds from 'english-verbs-gerunds';
export type EnglishTense =
// SIMPLE
| 'SIMPLE_PAST'
| 'PAST'
| 'SIMPLE_PRESENT'
| 'PRESENT'
| 'SIMPLE_FUTURE'
| 'FUTURE'
// PROGRESSIVE
| 'PROGRESSIVE_PAST'
| 'PROGRESSIVE_PRESENT'
| 'PROGRESSIVE_FUTURE';
const tenses = [
// SIMPLE
'SIMPLE_PAST',
'PAST',
'SIMPLE_PRESENT',
'PRESENT',
'SIMPLE_FUTURE',
'FUTURE',
// PROGRESSIVE
'PROGRESSIVE_PAST',
'PROGRESSIVE_PRESENT',
'PROGRESSIVE_FUTURE',
];
export type Numbers = 'S' | 'P';
const modals = ['can', 'could', 'may', 'might', 'must', 'shall', 'should', 'will', 'would'];
......@@ -30,18 +55,12 @@ function getIrregularPreterit(verbsInfo: VerbsInfo, verb: string): string {
const consonants = 'bcdfghjklmnpqrstvxzw';
export function getIng(verb: string): string {
if (verb.match(new RegExp(`[${consonants}]e$`, 'g'))) {
if (Gerunds[verb]) {
return Gerunds[verb];
} else if (verb.match(new RegExp(`[${consonants}]e$`, 'g'))) {
// If the infinitive ends with a consonant followed by an –e,
// you have to take off the –e to form your present participle.
return verb.substring(0, verb.length - 1) + 'ing';
} else if (verb.match(new RegExp(`[aeiou][${consonants}]$`, 'g'))) {
// If the infinitive ends with one vowel followed by one consonant(except of –y),
// you have to double this consonant to form your present participle.
return verb + verb.charAt(verb.length - 1) + 'ing';
} else if (verb.endsWith('ie')) {
// If the infinitive ends with –ie,
// the letters are replaced by –y followed by –ing in the past participle form.
return verb.substring(0, verb.length - 2) + 'y' + 'ing';
} else {
return verb + 'ing';
}
......@@ -115,6 +134,18 @@ function getSimpleFuture(verb: string, number: Numbers, extraParams: ExtraParams
}
}
function getProgressivePast(verb: string, number: Numbers): string {
return (number === 'P' ? 'were ' : 'was ') + getIng(verb);
}
function getProgressivePresent(verb: string, number: Numbers): string {
return (number === 'P' ? 'are ' : 'is ') + getIng(verb);
}
function getProgressiveFuture(verb: string): string {
return 'will be ' + getIng(verb);
}
export function getConjugation(
verbsInfo: VerbsInfo,
verb: string,
......@@ -151,5 +182,11 @@ export function getConjugation(
case 'FUTURE':
case 'SIMPLE_FUTURE':
return getSimpleFuture(verb, number, extraParams);
case 'PROGRESSIVE_PAST':
return getProgressivePast(verb, number);
case 'PROGRESSIVE_PRESENT':
return getProgressivePresent(verb, number);
case 'PROGRESSIVE_FUTURE':
return getProgressiveFuture(verb);
}
}
......@@ -50,6 +50,9 @@
"typescript": "^3.7.2",
"english-verbs-irregular": "0.0.1"
},
"dependencies": {
"english-verbs-gerunds": "0.0.1"
},
"keywords": [
"verbs",
"conjugation",
......@@ -57,4 +60,4 @@
],
"author": "Ludan Stoecklé <[email protected]>",
"license": "MIT"
}
}
\ No newline at end of file
......@@ -49,9 +49,22 @@ const testCases = {
['sleep', 'S', 'will sleep', { WILL: true }],
],
FUTURE: [['rest', 'S', 'will rest']],
// PROGRESSIVE
PROGRESSIVE_PAST: [
['wonder', 'S', 'was wondering'],
['get', 'P', 'were getting'],
],
PROGRESSIVE_PRESENT: [
['get', 'S', 'is getting'],
['frap', 'P', 'are frapping'],
],
PROGRESSIVE_FUTURE: [
['sleep', 'S', 'will be sleeping'],
['save', 'P', 'will be saving'],
],
};
// https://www.usingenglish.com/reference/irregular-verbs/shoe.html
const testCasesIng = [
['find', 'finding'],
['laugh', 'laughing'],
......@@ -69,6 +82,21 @@ const testCasesIng = [
['fit', 'fitting'],
['shoe', 'shoeing'],
['pay', 'paying'],
['wonder', 'wondering'],
['begin', 'beginning'],
['stop', 'stopping'],
['plan', 'planning'],
['swim', 'swimming'],
['happen', 'happening'],
['suffer', 'suffering'],
['enter', 'entering'],
['fix', 'fixing'],
['enjoy', 'enjoying'],
['snow', 'snowing'],
['travel', 'travelling'],
['refer', 'referring'],
['defer', 'deferring'],
['whisper', 'whispering'],
];
describe('english-verbs', function() {
......
......@@ -9,6 +9,7 @@
"outDir": "dist",
"declaration": true,
"allowJs": false,
"resolveJsonModule": true,
"esModuleInterop": true
}
}
\ No newline at end of file
......@@ -7,13 +7,7 @@ import { getConjugation as libGetConjugationIt, ItalianTense, ItalianAux } from
import italianVerbsDict from 'italian-verbs-dict';
import { Languages, Numbers, GendersMF } from './NlgLib';
import { VerbsData } from 'rosaenlg-pug-code-gen';
import compromise from 'compromise';
//import * as Debug from "debug";
//const debug = Debug("rosaenlg");
type EnglishTense = 'PRESENT' | 'PAST' | 'FUTURE';
import { EnglishTense, getConjugation as libGetConjugationEn } from 'english-verbs';
type Tense = GermanTense | FrenchTense | EnglishTense | ItalianTense;
......@@ -268,28 +262,6 @@ export class VerbsManager {
);
}
private getConjugationEn(verb: string, tense: EnglishTense, number: Numbers): string {
// debug( compromise(verb).verbs().conjugate() );
// console.log('TENSE: ' + tense);
// console.log( compromise('he ' + verb).verbs().conjugate()[0]['PresentTense'] );
if (tense === 'PRESENT' && number === 'P') {
return verb;
}
const tenseMapping = {
PRESENT: 'PresentTense',
PAST: 'PastTense',
FUTURE: 'FutureTense',
};
const conjugated: any[] = compromise('he ' + verb)
.verbs()
.conjugate();
/* istanbul ignore else */
if (conjugated.length > 0) {
return conjugated[0][tenseMapping[tense]];
} else {
return null;
}
return libGetConjugationEn(verb, tense, number);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment