Skip to content

Commit

Permalink
regex transforms for compar/superlatives
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed May 2, 2015
1 parent d04494d commit 29e70c1
Show file tree
Hide file tree
Showing 5 changed files with 3,486 additions and 3,477 deletions.
5 changes: 0 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,3 @@ if (typeof module !== "undefined" && module.exports) {
}
// console.log( nlp.pos('she sells seashells by the seashore').sentences[0].negate().text() )
// console.log( nlp.pos('i will slouch').to_past().text() );

//TODAY
// console.log(verb_conjugate("overtake"))
// adjective conjugate("pretty")
// upper-case months and demonyms
12 changes: 7 additions & 5 deletions src/parents/adjective/conjugate/to_comparative.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var to_comparative = (function() {
return null
}

for (i = 0; i < transforms.length; i++) {
if (str.match(transforms[i].reg)) {
return str.replace(transforms[i].reg, transforms[i].repl)
}
}

if (convertables.hasOwnProperty(str)) {
if (str.match(/e$/)) {
return str + "r"
Expand All @@ -71,6 +77,7 @@ var to_comparative = (function() {
}
}


if (irregulars.hasOwnProperty(str)) {
return irregulars[str]
}
Expand All @@ -82,11 +89,6 @@ var to_comparative = (function() {
}
}

for (i = 0; i < transforms.length; i++) {
if (str.match(transforms[i].reg)) {
return str.replace(transforms[i].reg, transforms[i].repl)
}
}

for (i = 0; i < matches.length; i++) {
if (str.match(matches[i])) {
Expand Down
12 changes: 6 additions & 6 deletions src/parents/adjective/conjugate/to_superlative.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ var to_superlative = (function() {
}
}

for (i = 0; i < transforms.length; i++) {
if (str.match(transforms[i].reg)) {
return str.replace(transforms[i].reg, transforms[i].repl)
}
}

if (convertables.hasOwnProperty(str)) {
return generic_transformation(str)
}
Expand All @@ -79,12 +85,6 @@ var to_superlative = (function() {
}
}

for (i = 0; i < transforms.length; i++) {
if (str.match(transforms[i].reg)) {
return str.replace(transforms[i].reg, transforms[i].repl)
}
}

for (i = 0; i < matches.length; i++) {
if (str.match(matches[i])) {
return generic_transformation(str)
Expand Down
1 change: 1 addition & 0 deletions src/parents/verb/conjugate/conjugate.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,4 @@ var verb_conjugate = (function() {

// console.log(verb_conjugate("swing"))
// console.log(verb_conjugate("walking"))
// console.log(verb_conjugate("overtook"))
Loading

0 comments on commit 29e70c1

Please sign in to comment.