New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

en-parse

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

en-parse - npm Package Compare versions

Comparing version 1.0.13 to 1.1.0

4

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const relating_1 = require("./relating");

@@ -37,3 +38,3 @@ const repairing_1 = require("./repairing");

if (pos !== jsonTree.index[1]) {
thisLabel = "MWE";
thisLabel = "EXT";
thisParent = jsonTree.index[1];

@@ -53,3 +54,2 @@ }

exports.toArray = toArray;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = exports.parse;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const relationships_1 = require("./rules/relationships");

@@ -9,37 +10,55 @@ const en_inflectors_1 = require("en-inflectors");

}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
;
function identifyRoot(nodes) {
let vbs = ["VP", "VB", "VBN"];
let pa = ["VBZ", "VB", "VBP", "VBD", "MD", "VBN"];
let oe = ["be", "have", "do", "will", "shall", "may", "can"];
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
let nx1 = nodes[i + 1];
let nx2 = nodes[i + 2];
let nx3 = nodes[i + 3];
if (!~vbs.indexOf(node.type))
let marked = false;
function markAsRoot(index) {
marked = true;
nodes[index].label = "ROOT";
}
const removedADs = [];
const roots = [];
for (var index = 0; index < nodes.length; index++) {
let node = nodes[index];
if (node.type === "AD")
continue;
if (~pa.indexOf(node.tags[0]) && nx1) {
if (~vbs.indexOf(nx1.type))
continue;
else if (nx1.tags[0] === "RB" && nx2) {
if (~vbs.indexOf(nx2.type))
continue;
else if (nx3 && nx2.type === "NP" && ~vbs.indexOf(nx3.type))
continue;
}
else if (nx2 && node.index[0] === 0) {
if (nx1.type === "NP" && ~vbs.indexOf(nx2.type))
continue;
else if (nx3 && nx1.type === "NP" && nx2.tags[0] === "RB" && ~vbs.indexOf(nx3.type))
continue;
}
else if (nx2 && ~oe.indexOf(new en_inflectors_1.Inflectors(deContract(nx1.tokens[0])).conjugate("VBP")) && ~vbs.indexOf(nx2.type))
continue;
removedADs.push({
index: index,
node: node
});
}
for (var index = 0; index < removedADs.length; index++) {
let node = removedADs[index];
if ((roots.length) && (index - roots[roots.length - 1].index > 4))
break;
if (node.node.tags[0].startsWith("V"))
roots.push({
base: new en_inflectors_1.Inflectors(node.node.tokens[0]).toPresent(),
token: node.node.tokens[0].toLowerCase(),
index: node.index
});
}
if (roots.length === 0)
return nodes;
if ((!marked) && roots.length > 3) {
if (roots[0].base === "will" && roots[1].base === "have" && roots[2].token === "been") {
markAsRoot(roots[3].index);
}
nodes[i].label = "ROOT";
break;
}
if ((!marked) && roots.length > 2) {
if (roots[0].base === "have" && roots[1].token === "been")
markAsRoot(roots[2].index);
else if (roots[0].base === "will" && roots[1].base === "have")
markAsRoot(roots[2].index);
else if (roots[0].base === "be" && roots[1].token === "going" && nodes[roots[1].index + 1].tokens[0] === "to") {
markAsRoot(roots[2].index);
}
}
if ((!marked) && roots.length > 1) {
if (roots[0].base === "do" || roots[0].base === "be" || roots[0].base === "have") {
markAsRoot(roots[1].index);
}
}
if ((!marked) && roots.length > 0)
markAsRoot(roots[0].index);
return nodes;

@@ -91,5 +110,5 @@ }

continue;
else if (rel.leftTokens.length && rel.leftTokens.indexOf(new en_inflectors_1.Inflectors(deContract(left.tokens[0])).conjugate("VBP")) === -1)
else if (rel.leftTokens.length && rel.leftTokens.indexOf(new en_inflectors_1.Inflectors(left.tokens[0]).conjugate("VBP")) === -1)
continue;
else if (rel.rightTokens.length && rel.rightTokens.indexOf(new en_inflectors_1.Inflectors(deContract(right.tokens[0])).conjugate("VBP")) === -1)
else if (rel.rightTokens.length && rel.rightTokens.indexOf(new en_inflectors_1.Inflectors(right.tokens[0]).conjugate("VBP")) === -1)
continue;

@@ -118,10 +137,1 @@ else {

};
const contractions = ["'m", "'s", "'d", "'ll", "'re", "'ve"];
const replacements = ["am", "is", "would", "will", "are", "have"];
function deContract(token) {
let ci = contractions.indexOf(token);
if (~ci)
return replacements[ci];
else
return token;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const repairs = require("./rules/repairs");

@@ -12,3 +13,2 @@ function default_1(nodes) {

}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;

@@ -15,0 +15,0 @@ ;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;

@@ -215,7 +216,7 @@ exports.relationships = [

{
left: ["VP", "VB"],
left: ["VP", "VB", "VBN"],
right: ["VP", "VB"],
leftTokens: ["be", "can", "do", "have", "may", "will", "shall"],
leftTokens: ["be", "can", "do", "have", "may", "will", "shall", "go"],
rightTokens: [],
maxDistance: 1,
maxDistance: 4,
delay: 0,

@@ -230,3 +231,3 @@ direction: "->",

rightTokens: [],
maxDistance: 1,
maxDistance: 4,
delay: 0,

@@ -241,3 +242,3 @@ direction: "->",

rightTokens: [],
maxDistance: 1,
maxDistance: 4,
delay: 0,

@@ -244,0 +245,0 @@ direction: "->",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const relating_1 = require("../relating");

@@ -3,0 +4,0 @@ exports.recursive = [

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.preUnique = [

@@ -3,0 +4,0 @@ ["NP", ['DT', 'PRP$', 'JJ', 'JJS', "JJR", '$', '$', 'NN', 'NNS']],

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types = require("./rules/types");

@@ -15,3 +16,2 @@ function default_1(nodes) {

}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;

@@ -18,0 +18,0 @@ ;

{
"name": "en-parse",
"version": "1.0.13",
"version": "1.1.0",
"description": "English language syntactic dependency parser",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -17,4 +17,2 @@ # English Parse

const parser = require("en-parse").default;
var tokens = ["The", "problem", "is", "that", "this", "has", "never", "been", "tried", "."];
var tags = ["DT","NN","VBZ","IN","DT","VBZ","RB","VBN","VBD","PUNCT"];
let parsed = parser(["PRP","VBP","TO","VBP"],["i","like","to","parse"]);

@@ -116,2 +114,3 @@ ```

**`INTERJ`** | Interjection | Pass me the sugar, `please`
**`EXT`** | Extension | My name is `Alex` Corvi
**`DEP`** | Unrecognized dependency | how `what`

@@ -118,0 +117,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc