Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
RosaeNLG
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
RosaeNLG projects
RosaeNLG
Commits
9afad9f5
Commit
9afad9f5
authored
Feb 03, 2020
by
Ludan Stoecklé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ing stuff
parent
9838a3ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
packages/english-verbs/lib/index.ts
packages/english-verbs/lib/index.ts
+23
-0
packages/english-verbs/test/test.js
packages/english-verbs/test/test.js
+30
-0
No files found.
packages/english-verbs/lib/index.ts
View file @
9afad9f5
...
...
@@ -13,6 +13,8 @@ export interface ExtraParams {
WILL
?:
boolean
;
}
// helpers
function
getIrregularPreterit
(
verbsInfo
:
VerbsInfo
,
verb
:
string
):
string
{
if
(
verbsInfo
&&
verbsInfo
[
verb
]
&&
verbsInfo
[
verb
].
length
!=
0
)
{
const
verbInfo
=
verbsInfo
[
verb
];
...
...
@@ -26,6 +28,27 @@ 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 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
'
;
}
}
// 1 per tense
function
getSimplePast
(
verbsInfo
:
VerbsInfo
,
verb
:
string
,
number
:
Numbers
):
string
{
let
irregular
:
string
;
if
(
verb
===
'
be
'
)
{
...
...
packages/english-verbs/test/test.js
View file @
9afad9f5
...
...
@@ -51,6 +51,26 @@ const testCases = {
FUTURE
:
[[
'
rest
'
,
'
S
'
,
'
will rest
'
]],
};
// https://www.usingenglish.com/reference/irregular-verbs/shoe.html
const
testCasesIng
=
[
[
'
find
'
,
'
finding
'
],
[
'
laugh
'
,
'
laughing
'
],
[
'
wash
'
,
'
washing
'
],
[
'
arise
'
,
'
arising
'
],
[
'
become
'
,
'
becoming
'
],
[
'
have
'
,
'
having
'
],
[
'
get
'
,
'
getting
'
],
[
'
let
'
,
'
letting
'
],
[
'
plan
'
,
'
planning
'
],
[
'
die
'
,
'
dying
'
],
[
'
lie
'
,
'
lying
'
],
[
'
dare
'
,
'
daring
'
],
[
'
ban
'
,
'
banning
'
],
[
'
fit
'
,
'
fitting
'
],
[
'
shoe
'
,
'
shoeing
'
],
[
'
pay
'
,
'
paying
'
],
];
describe
(
'
english-verbs
'
,
function
()
{
describe
(
'
#getConjugation()
'
,
function
()
{
describe
(
'
nominal cases
'
,
function
()
{
...
...
@@ -86,6 +106,16 @@ describe('english-verbs', function() {
});
}
});
describe
(
'
ing form
'
,
function
()
{
for
(
let
i
=
0
;
i
<
testCasesIng
.
length
;
i
++
)
{
const
testCase
=
testCasesIng
[
i
];
const
verb
=
testCase
[
0
];
const
expected
=
testCase
[
1
];
it
(
`
${
verb
}
=>
${
expected
}
`
,
function
()
{
assert
.
equal
(
EnglishVerbs
.
getIng
(
verb
),
expected
);
});
}
});
describe
(
'
edge cases
'
,
function
()
{
it
(
`null verb`
,
function
()
{
assert
.
throws
(()
=>
EnglishVerbs
.
getConjugation
(
null
,
null
,
'
PRESENT
'
,
'
S
'
),
/verb/
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment