Comparing version 0.2.0 to 0.2.1
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"licenses": [ | ||
@@ -23,0 +23,0 @@ { |
@@ -29,3 +29,3 @@ /*! | ||
function endsWith($this, string){ | ||
if (!string || string.length > $this.length) | ||
if (!string || string.length > $this.length) | ||
return false; | ||
@@ -37,8 +37,8 @@ return $this.indexOf(string) == $this.length - string.length; | ||
var ss = this.lexicon[word]; | ||
if (ss != null) | ||
if (ss != null) | ||
return true; | ||
// 1/22/2002 mod (from Lisp code): if not in hash, try lower case: | ||
if (!ss) | ||
if (!ss) | ||
ss = this.lexicon[word.toLowerCase()]; | ||
if (ss) | ||
if (ss) | ||
return true; | ||
@@ -53,14 +53,14 @@ return false; | ||
// 1/22/2002 mod (from Lisp code): if not in hash, try lower case: | ||
if (!ss) | ||
if (!ss) | ||
ss = this.lexicon[words[i].toLowerCase()]; | ||
if (!ss && words[i].length == 1) | ||
if (!ss && words[i].length == 1) | ||
ret[i] = words[i] + "^"; | ||
// We need to catch scenarios where we pass things on the prototype | ||
// that aren't in the lexicon: "constructor" breaks this otherwise | ||
if (!ss || typeof ss === "function") | ||
if (!ss || typeof ss === "function") | ||
ret[i] = "NN"; | ||
else | ||
else | ||
ret[i] = ss[0]; | ||
} | ||
/** | ||
@@ -94,6 +94,6 @@ * Apply transformational rules | ||
// rule 3: convert a noun to a past participle if words[i] ends with "ed" | ||
if (startsWith(ret[i], "N") && endsWith(words[i], "ed")) | ||
if (startsWith(ret[i], "N") && endsWith(words[i], "ed")) | ||
ret[i] = "VBN"; | ||
// rule 4: convert any type to adverb if it ends in "ly"; | ||
if (endsWith(words[i], "ly")) | ||
if (endsWith(words[i], "ly")) | ||
ret[i] = "RB"; | ||
@@ -103,4 +103,4 @@ // rule 5: convert a common noun (NN or NNS) to a adjective if it ends with "al" | ||
// bug: it said here: endsWith(word, "al"), this should be: endsWith(words[i], "al") | ||
//if (startsWith(ret[i], "NN") && endsWith(word, "al")) | ||
if (((ret[i] === "NN") || (ret[i] === "NNS")) && endsWith(words[i], "al")) | ||
//if (startsWith(ret[i], "NN") && endsWith(word, "al")) | ||
if (((ret[i] === "NN") || (ret[i] === "NNS")) && endsWith(words[i], "al")) | ||
//ret[i] = i, "JJ"; | ||
@@ -113,3 +113,3 @@ ret[i] = "JJ"; | ||
// then set its type to plural common noun (NNS) | ||
if (ret[i] == "NN" && endsWith(words[i], "s")) | ||
if (ret[i] == "NN" && endsWith(words[i], "s")) | ||
ret[i] = "NNS"; | ||
@@ -133,2 +133,10 @@ // rule 8: convert a common noun to a present participle verb (i.e., a gerund) | ||
POSTagger.prototype.extendLexicon = function(lexicon) { | ||
for (var word in lexicon) { | ||
if (!this.lexicon.hasOwnProperty(word)) { | ||
this.lexicon[word] = lexicon[word]; | ||
} | ||
} | ||
} | ||
//print(new POSTagger().tag(["i", "went", "to", "the", "store", "to", "buy", "5.2", "gallons", "of", "milk"])); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4038439
13
298113