Socket
Socket
Sign inDemoInstall

compromise

Package Overview
Dependencies
Maintainers
3
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compromise - npm Package Compare versions

Comparing version 14.2.0-rc2 to 14.2.0

changelog.md

10

package.json

@@ -5,3 +5,3 @@ {

"description": "modest natural language processing",
"version": "14.2.0-rc2",
"version": "14.2.0",
"main": "./src/three.js",

@@ -99,8 +99,8 @@ "unpkg": "./builds/compromise.js",

"@rollup/plugin-alias": "3.1.9",
"@rollup/plugin-node-resolve": "13.2.1",
"@rollup/plugin-node-resolve": "13.3.0",
"amble": "1.3.0",
"eslint": "8.14.0",
"eslint": "8.16.0",
"eslint-plugin-regexp": "1.7.0",
"nlp-corpus": "^4.2.0",
"rollup": "2.70.2",
"nlp-corpus": "4.3.0",
"rollup": "2.75.5",
"rollup-plugin-filesize-check": "0.0.1",

@@ -107,0 +107,0 @@ "rollup-plugin-terser": "7.0.2",

@@ -1,1 +0,1 @@

export default '14.2.0-rc2'
export default '14.2.0'

@@ -79,2 +79,3 @@ import pluckOutTerm from './lib/remove.js'

}
// self._cache = null
let res = self.toView(ptrs) //return new document

@@ -81,0 +82,0 @@ return res

@@ -11,5 +11,14 @@ import splice from './_splice.js'

// run tagger on our new implicit terms
const reTag = function (terms, view) {
const reTag = function (terms, view, start, len) {
let tmp = view.update()
tmp.document = [terms]
// offer to re-tag neighbours, too
let end = start + len
if (start > 0) {
start -= 1
}
if (terms[end]) {
end += 1
}
tmp.ptrs = [[0, start, end]]
tmp.compute(['lexicon', 'preTagger', 'index'])

@@ -87,3 +96,3 @@ }

splice(document, [n, i], words)
reTag(document[n], view)
reTag(document[n], view, i, words.length)
continue

@@ -102,3 +111,3 @@ }

}
reTag(document[n], view)
reTag(document[n], view, i, words.length)
}

@@ -105,0 +114,0 @@ }

@@ -34,1 +34,14 @@ export const relPointer = function (ptrs, parent) {

export const isNet = val => val && isObject(val) && val.isNet === true
// is the pointer the full sentence?
// export const isFull = function (ptr, document) {
// let [n, start, end] = ptr
// if (start !== 0) {
// return false
// }
// if (document[n] && document[n][end - 1] && !document[n][end]) {
// return true
// }
// return false
// }

@@ -23,2 +23,11 @@ import { fixPointers, isView, isNet } from './_lib.js'

view._groups = byGroup
// try to keep some of the cache
// if (this._cache) {
// view._cache = view.ptrs.map(ptr => {
// if (isFull(ptr, this.document)) {
// return this._cache[ptr[0]]
// }
// return null
// })
// }
return view

@@ -93,3 +102,8 @@ }

})
return this.update(ptrs)
let view = this.update(ptrs)
// try and reconstruct the cache
if (this._cache) {
view._cache = ptrs.map(ptr => cache[ptr[0]])
}
return view
}

@@ -115,3 +129,3 @@

let cache = this._cache || []
return this.filter((m, i) => {
let view = this.filter((m, i) => {
let todo = { regs, group, justOne: true }

@@ -121,4 +135,9 @@ let ptrs = one.match(m.docs, todo, cache[i]).ptrs

})
// try to reconstruct the cache
if (this._cache) {
view._cache = view.ptrs.map(ptr => cache[ptr[0]])
}
return view
}
export default { matchOne, match, has, if: ifFn, ifNo }

@@ -13,3 +13,3 @@ const anyIntersection = function (setA, setB) {

let reg = regs[i]
if (reg.optional === true || reg.negative === true) {
if (reg.optional === true || reg.negative === true || reg.fuzzy === true) {
continue

@@ -16,0 +16,0 @@ }

const hasMinMax = /\{([0-9]+)?(, *[0-9]*)?\}/
const andSign = /&&/
// const hasDash = /\p{Letter}-\p{Letter}/u
const captureName = new RegExp(/^<\s*(\S+)\s*>/)

@@ -213,2 +214,5 @@ /* break-down a match expression into this:

}
// if (hasDash.test(w) === true) {
// w = w.replace(/-/g, '')
// }
obj.word = w

@@ -215,0 +219,0 @@ }

@@ -7,7 +7,7 @@ const api = function (View) {

const { methods } = world
let found = methods.two.bulkMatch(docs, net, this.methods, opts)
let found = methods.one.bulkMatch(docs, net, this.methods, opts)
// apply any changes
if (opts.tagger !== false) {
methods.two.bulkTagger(found, docs, this.world)
methods.one.bulkTagger(found, docs, this.world)
}

@@ -14,0 +14,0 @@ // fix the pointers

@@ -5,3 +5,3 @@ export default {

const methods = this.methods()
let { index, always } = methods.two.makeNet(matches, methods)
let { index, always } = methods.one.buildNet(matches, methods)
return {

@@ -8,0 +8,0 @@ isNet: true,

@@ -1,60 +0,1 @@

// const growFastOr = function (obj, index) {
// let or = obj.regs[index]
// return Array.from(or.fastOr).map(str => {
// let cpy = Object.assign({}, or)
// delete cpy.fastOr
// delete cpy.operator
// cpy.word = str
// return cpy
// })
// }
// const growSlowOr = function (obj, index) {
// let or = obj.regs[index]
// return or.choices.map(regs => {
// if (regs.length === 1) {
// return regs[0]
// }
// return { choices: regs, operator: or.operator }
// })
// }
// multiply matches with OR options, for cache-purposes
// const Old = function (matches) {
// let all = []
// matches.forEach(obj => {
// console.log(obj)
// // expand simple '(one|two)' matches
// let foundOr = obj.regs.findIndex(reg => reg.operator === 'or' && reg.fastOr && !reg.optional && !reg.negative)
// if (foundOr !== -1) {
// let more = growFastOr(obj, foundOr)
// more.forEach(mo => {
// let newObj = Object.assign({}, obj) //clone
// newObj.regs = obj.regs.slice(0) //clone
// newObj.regs[foundOr] = mo
// newObj._expanded = true
// all.push(newObj)
// })
// return
// }
// // expand '(#Foo|two three)' matches
// foundOr = obj.regs.findIndex(reg => reg.operator === 'or' && reg.choices && !reg.optional && !reg.negative)
// if (foundOr !== -1) {
// // obj.regs[foundOr]
// let more = growSlowOr(obj, foundOr)
// more.forEach(mo => {
// let newObj = Object.assign({}, obj) //clone
// newObj.regs = obj.regs.slice(0) //clone
// newObj.regs[foundOr] = mo
// newObj._expanded = true
// all.push(newObj)
// })
// return
// }
// all.push(obj)
// })
// // console.dir(all, { depth: 7 })
// return all
// }
// stich an array into another, replacing one element

@@ -90,3 +31,4 @@ function spliceArray(main, index, arrayToInsert) {

let reg = obj.regs[i]
if (reg.operator === 'or') {
// (negative or is un-multipliable) - !(a|b|c) -> "a" matches !b
if (reg.operator === 'or' && !reg.negative === true) {
let more = getORs(reg)

@@ -93,0 +35,0 @@ more.forEach(r => {

@@ -13,2 +13,5 @@ // extract the clear needs for an individual match token

}
if (reg.switch) {
return `%${reg.switch}%`
}
return null

@@ -46,2 +49,4 @@ }

obj.needs = Array.from(findNeeds(obj.regs))
// get rid of tiny sentences
obj.minWords = obj.regs.filter(o => !o.optional).length
})

@@ -48,0 +53,0 @@ return matches

@@ -1,2 +0,2 @@

import makeNet from './buildNet/index.js'
import buildNet from './buildNet/index.js'
import bulkMatch from './sweep/index.js'

@@ -6,5 +6,5 @@ import bulkTagger from './tagger/index.js'

export default {
makeNet,
buildNet,
bulkMatch,
bulkTagger
}

@@ -5,2 +5,21 @@ import getCandidates from './01-candidates.js'

// const counts = {}
// setInterval(() => {
// let res = Object.keys(counts).map(k => [k, counts[k]])
// res = res.sort((a, b) => (a[1] > b[1] ? -1 : 0))
// console.log(res)
// }, 5000)
const tooSmall = function (maybeList, document) {
return maybeList.map((arr, i) => {
let termCount = document[i].length
arr = arr.filter(o => {
return termCount >= o.minWords
})
return arr
})
}
const sweep = function (document, net, methods, opts = {}) {

@@ -17,2 +36,11 @@ // find suitable matches to attempt, on each sentence

}
// if we don't have enough words
maybeList = tooSmall(maybeList, document)
// console.log(maybeList)
// maybeList.forEach(list => {
// list.forEach(o => {
// counts[o.match] = counts[o.match] || 0
// counts[o.match] += 1
// })
// })
// now actually run the matches

@@ -19,0 +47,0 @@ let results = runMatch(maybeList, document, methods, opts)

@@ -9,4 +9,4 @@ import lib from './lib.js'

methods: {
two: methods
one: methods,
}
}

@@ -0,1 +1,2 @@

const hasDash = /^\p{Letter}+-\p{Letter}+$/u
// 'machine' is a normalized form that looses human-readability

@@ -10,6 +11,5 @@ const doMachine = function (term) {

//turn re-enactment to reenactment
if (/^(re|un)-?[^aeiou]./.test(str) === true) {
str = str.replace('-', '')
if (hasDash.test(str)) {
str = str.replace(/-/g, '')
}
//#tags, @mentions

@@ -16,0 +16,0 @@ str = str.replace(/^[#@]/, '')

@@ -8,3 +8,3 @@ // dashed prefixes that are not independent words

'contra',
'counter',
// 'counter',
'de',

@@ -21,6 +21,6 @@ 'extra',

'multi',
'non',
'over',
// 'non',
// 'over',
'peri',
'post',
// 'post',
'pre',

@@ -31,3 +31,3 @@ 'pro',

're',
'semi',
// 'semi',
'sub',

@@ -34,0 +34,0 @@ // 'super', //'super-cool'

@@ -10,5 +10,14 @@ import splice from './_splice.js'

// run tagger on our new implicit terms
const reTag = function (terms, view) {
const reTag = function (terms, view, start, len) {
let tmp = view.update()
tmp.document = [terms]
// offer to re-tag neighbours, too
let end = start + len
if (start > 0) {
start -= 1
}
if (terms[end]) {
end += 1
}
tmp.ptrs = [[0, start, end]]
tmp.compute(['lexicon', 'preTagger', 'index'])

@@ -15,0 +24,0 @@ }

@@ -53,2 +53,10 @@ const banList = {

}
// the chair's his
if (nextTerm.tags.has('Possessive')) {
return false
}
// the captain's John
if (nextTerm.tags.has('ProperNoun') && !term.tags.has('ProperNoun')) {
return false
}
return true

@@ -55,0 +63,0 @@ }

const round = n => Math.round(n * 100) / 100
export default function (View) {
// average tagger score
View.prototype.confidence = function () {

@@ -18,2 +19,7 @@ let sum = 0

}
// (re-) run the POS-tagger
View.prototype.tagger = function () {
return this.compute(['preTagger', 'contractionTwo', 'postTagger'])
}
}

@@ -8,5 +8,4 @@ let net = null

net = net || methods.two.makeNet(model.two.matches, methods)
net = net || methods.one.buildNet(model.two.matches, methods)
// perform these matches on a comma-seperated document
// let clauses = view.clauses()
let document = methods.two.quickSplit(view.document)

@@ -18,4 +17,6 @@ let ptrs = document.map(terms => {

let m = view.update(ptrs)
m.cache()
m.sweep(net)
view.uncache()
// view.cache()
return view

@@ -22,0 +23,0 @@ }

@@ -23,3 +23,3 @@ export default [

// the amusing world
{ match: '(#Determiner|#Possessive) [%Adj|Gerund%] #Noun', group: 0, tag: 'Adjective', reason: 'amusing-world' },
// { match: '(#Determiner|#Possessive) [%Adj|Gerund%] #Noun', group: 0, tag: 'Adjective', reason: 'amusing-world' },
]

@@ -39,10 +39,10 @@ const infNouns =

//linear algebra
{
match: '(#Determiner|#Value) [(linear|binary|mobile|lexical|technical|computer|scientific|formal)] #Noun',
group: 0,
tag: 'Noun',
reason: 'technical-noun',
},
// {
// match: '(#Determiner|#Value) [(linear|binary|mobile|lexical|technical|computer|scientific|formal)] #Noun',
// group: 0,
// tag: 'Noun',
// reason: 'technical-noun',
// },
//air-flow
{ match: '(#Noun && @hasHyphen) #PresentTense', tag: 'Noun', reason: 'hyphen-verb' },
{ match: '(#Singular && @hasHyphen) #PresentTense', tag: 'Noun', reason: 'hyphen-verb' },
//is no walk

@@ -77,3 +77,3 @@ { match: 'is no [#Verb]', group: 0, tag: 'Noun', reason: 'is-no-verb' },

// co-founder
{ match: `co #Noun`, tag: 'Actor', reason: 'co-noun' },
{ match: `co #Singular`, tag: 'Actor', reason: 'co-noun' },

@@ -105,3 +105,3 @@ // ==== Singular ====

//the repairer said
{ match: '#Determiner [#Noun] said', group: 0, tag: 'Actor', reason: 'the-actor-said' },
{ match: '#Determiner [#Singular] said', group: 0, tag: 'Actor', reason: 'the-actor-said' },
//the euro sense

@@ -127,3 +127,3 @@ {

// visit houses
{ match: '^[%Noun|Verb%] #Noun', group: 0, tag: 'Verb', reason: 'visit-boards' },
// { match: '^[%Noun|Verb%] #Noun', group: 0, tag: 'Verb', reason: 'visit-boards' },
]

@@ -22,3 +22,3 @@ export default [

// ten bucks
{ match: '(#Value|a) [(buck|bucks|grand)]', group: 0, tag: 'Currency', reason: 'value-bucks' },
{ match: '#Value [(buck|bucks|grand)]', group: 0, tag: 'Currency', reason: 'value-bucks' },
// ==== Money ====

@@ -25,0 +25,0 @@ { match: '[#Value+] #Currency', group: 0, tag: 'Money', reason: '15 usd' },

@@ -41,8 +41,3 @@ // these are some of our heaviest-used matches

// was being walked
{
match: '#Copula (#Adverb|not)+? [(be|being|been)] #Adverb+? #PastTense',
group: 0,
tag: 'Auxiliary',
reason: 'being-walked',
},
{ match: '#Copula (#Adverb|not)+? [(be|being|been)] #Adverb+? #PastTense', group: 0, tag: 'Auxiliary', reason: 'being-walked' },
// will be walked

@@ -49,0 +44,0 @@ { match: 'will [be] #PastTense', group: 0, tag: 'Auxiliary', reason: 'will-be-x' },

@@ -24,2 +24,4 @@ // this is really hard to do

{ match: '^[#Infinitive] (him|her|it|us|me)', group: 0, tag: 'Imperative', reason: 'tell-him' },
// avoid loud noises
{ match: '^[#Infinitive] #Adjective #Noun$', group: 0, tag: 'Imperative', reason: 'avoid-loud-noises' },
// one-word imperatives

@@ -26,0 +28,0 @@ { match: '^(go|stop|wait|hurry) please?$', tag: 'Imperative', reason: 'go' },

@@ -1,10 +0,8 @@

import fastTag from '../_fastTag.js'
const isTitleCase = (str) => /^\p{Lu}[\p{Ll}'’]/u.test(str)
const isOrg = function (term) {
const isOrg = function (term, i) {
if (!term) {
return false
}
if (term.tags.has('Person') || term.tags.has('Place')) {
if (term.tags.has('FirstName') || term.tags.has('Place')) {
return false

@@ -17,2 +15,6 @@ }

if (isTitleCase(term.text)) {
// only tag a titlecased first-word, if it checks-out
if (i === 0) {
return term.tags.has('Singular')
}
return true

@@ -23,12 +25,13 @@ }

const tagOrgs = function (terms, i, model) {
const orgWords = model.two.orgWords
const tagOrgs = function (terms, i, world) {
const orgWords = world.model.two.orgWords
const setTag = world.methods.one.setTag
let term = terms[i]
let str = term.machine || term.normal
if (orgWords[str] === true && isOrg(terms[i - 1])) {
fastTag(terms[i], 'Organization', '3-[org-word]')
setTag([terms[i]], 'Organization', world, null, '3-[org-word]')
// loop backwards, tag organization-like things
for (let t = i; t >= 0; t -= 1) {
if (isOrg(terms[t])) {
fastTag(terms[t], 'Organization', '3-[org-word]')
if (isOrg(terms[t], t)) {
setTag([terms[t]], 'Organization', world, null, '3-[org-word]')
} else {

@@ -35,0 +38,0 @@ break

@@ -67,3 +67,3 @@

// Johnson LLC
third.orgWords(terms, i, model)
third.orgWords(terms, i, world)
// support 'out-lived'

@@ -70,0 +70,0 @@ second.checkHyphen(terms, i, model)

@@ -58,2 +58,10 @@ const n = 'Singular'

weekly: n,//
linear: n,//
binary: n,//
mobile: n,//
lexical: n,//
technical: n,//
computer: n,//
scientific: n,//
formal: n
},

@@ -60,0 +68,0 @@ afterWords: {

@@ -60,3 +60,3 @@ // generated in ./lib/lexicon

"Participle": "true¦f4g3h2less6s1w0;ors5ritt5;e4h5;ast3e2;iv2one;l2r0;ight0;en;own",
"Adj|Gerund": "true¦0:2C;1:2E;2:22;3:20;4:24;5:1X;a1Zb1Uc1Cd0Ze0Uf0Kg0Eh0Di07jud1Sl04m01oXpTrNsCt7up6veWw0Lyiel5;lif0sZ;aUe9hr7i3ouc22r6wis0;eZoub2us0yi1;ea0Ji6;l2vi1;l2mp0;atisf28creec1Xhoc0Bkyrocke0lo0ZoEpDt9u7we6;e0Yl2;pp1Gr6;gi1pri4roun5;a7ea1Zi6ri07un18;mula0r3;gge3r6;t2vi1;ark2ee5;a6ot1O;ki1ri1;aAe7ive0o6us1M;a3l2;defi0Zfres1Kig0ZlaCs0v6war5;ea2itali6ol0M;si1zi1;gi1ll1Smb2vi1;a1Rerple8ier19r6un1F;e6o0X;ce5s4vai2;xi1;ffs8pKut7ver6wi1;arc1Blap0Dri5whel1H;goi1l1Lst0U;et0;eande3i7o0Bu6;mb2;s4tiga0;a7i6o08;fesa07mi0vi1;cHg0Rs0;mAn6rri08;c8s7te13vi6;go1Cti1;pi3ul0;orpo1Area4;po4;arrowi1ea2orrif17umilia0;lAr6;a0ipWo7uel6;i1li1;undbrea6wi1;ki1;a3ea0W;aEetc0Pit0lBo9r7ulf6;il2;ee0Vigh6ust0Z;te01;r6un5;ebo5th0E;a7o6;a0we3;mi1tte3;di1scina0;m9n7x6;ac0ci0is0;ab2c6du3ga01sQ;han0oura00;barras4erZpowe3;aHeAi6;s6zz0K;appoin0gus0sen0t6;r6u0L;ac0es4;biliBcAfiKgra5m9pres4ser8v6;asAelo6;pi1;vi1;an5eaG;a0BliF;ta0;maMri1sYun0;aMhJlo4o6ripp2ut0;mCn6rrespon5;cerAf9spi3t6vinO;in7r6;as0ibu0ol2;ui1;lic0u4;ni1;fAm9p6;e7ro6;mi4;l2ti1;an5;or0;a6ea0il2;llen6rO;gi1;lMptiva0;e9in5lin5o7rui4u6;d5st2;i2oJri1un6;ci1;coH;bsoOcJgonHlarGmEppea2rCs6;pi3su3to6;n7un5;di1;is6;hi1;ri1;res0;li1;a9u4;si1;mi1;i6zi1;zi1;c6hi1;ele7ompan6;yi1;ra0;ti1;rbi1;ng",
"Adj|Gerund": "true¦0:2C;1:2E;2:22;3:20;4:1X;5:24;a1Zb1Uc1Cd0Ze0Uf0Kg0Eh0Di07jud1Sl04m01oXpTrNsCt7up6veWw0Lyiel4;lif0sZ;aUe9hr7i3ouc22r6wis0;eZoub2us0yi1;ea0Ji6;l2vi1;l2mp0;atisf28creec1Xhoc0Bkyrocke0lo0ZoEpDt9u7we6;e0Yl2;pp1Gr6;gi1pri5roun4;a7ea1Zi6ri07un18;mula0r3;gge3r6;t2vi1;ark2ee4;a6ot1O;ki1ri1;aAe7ive0o6us1M;a3l2;defi0Zfres1Kig0ZlaCs0v6war4;ea2itali6ol0M;si1zi1;gi1ll1Smb2vi1;a1Rerple8ier19lun14r6un1F;e6o0X;ce4s5vai2;xi1;ffs8pKut7ver6wi1;arc1Blap0Dri4whel1H;goi1l1Lst0U;et0;eande3i7o0Bu6;mb2;s5tiga0;a7i6o08;fesa07mi0vi1;cHg0Rs0;mAn6rri08;c8s7te13vi6;go1Cti1;pi3ul0;orpo1Area5;po5;arrowi1ea2orrif17umilia0;lAr6;a0ipWo7uel6;i1li1;undbrea6wi1;ki1;a3ea0W;aEetc0Pit0lBo9r7ulf6;il2;ee0Vigh6ust0Z;te01;r6un4;ebo4th0E;a7o6;a0we3;mi1tte3;di1scina0;m9n7x6;ac0ci0is0plo4;ab2c6du3ga01sQ;han0oura00;barras5erZpowe3;aHeAi6;s6zz0K;appoin0gus0sen0t6;r6u0L;ac0es5;biliBcAfiKgra4m9pres5ser8v6;asAelo6;pi1;vi1;an4eaG;a0BliF;ta0;maMri1sYun0;aMhJlo5o6ripp2ut0;mCn6rrespon4;cerAf9spi3t6vinO;in7r6;as0ibu0ol2;ui1;lic0u5;ni1;fAm9p6;e7ro6;mi5;l2ti1;an4;or0;a6ea0il2;llen6rO;gi1;lMptiva0;e9in4lin4o7rui5u6;d4st2;i2oJri1un6;ci1;coH;bsoOcJgonHlarGmEppea2rCs6;pi3su3to6;n7un4;di1;is6;hi1;ri1;res0;li1;a9u5;si1;mi1;i6zi1;zi1;c6hi1;ele7ompan6;yi1;ra0;ti1;rbi1;ng",
"Adj|Past": "true¦0:2T;1:2K;2:2N;3:23;a2Db28c1Qd1Ae14f0Zgift0h0Wi0Pj0Oknown,l0Lm0Gn0Eo0Bp04qua03rUsEtAu8v6w4;arp0ea4or6;kIth2N;a4e0V;ri0;ni4pd1s0;fi0t0;ar6hreatDr4wi2M;a4ou18;ck0in0pp0;get0ni1K;aHcaGeFhEimDm01oak0pBt7u4;bsid23gge2Hs4;pe4ta1O;ct0nd0;at0e6r4uV;ength4ip0;en0;am0reotyp0;eci4ik0ott0;al1Vfi0;pIul1;ar0ut;al0c1Fle2t1N;r0tt21;t4ut0;is3ur1;aBe4;c8duc0f19g7l1new0qu6s4;pe2t4;or0ri2;e1Yir0;ist1Tul1;eiv0o4;mme0Ard0v1R;lli0ti3;li3;arallel0l8o7r4ump0;e5o4;c0Ilo0Hnou1Ppos0te2;fe0Koc9pZ;i1Cli0P;a4e15;nn0;c5rgan17verlo4;ok0;cupi0;e4ot0;ed0gle2;a6e5ix0o4;di3t0E;as0Nlt0;n4rk0;ag0ufact0L;eft,i5o4;ad0st;cens0mit0st0;agg0us0K;mp9n4sol1;br0debt0f7t4volv0;e4ox0C;gr1n4re14;d0si3;e2oW;li0oMrov0;amm0We1o4;ok0r4;ri3;aNe7i6lavo06ocus0r4;a4i0;ct04g0Im0;niVx0;ar0;duc1n8quipp0stabliTx4;p4te6;a5e4;ct0rie0O;nd0;ha0MsW;aIeAi4;gni3miniMre2s4;a7c6grun01t4;o4rBurb0;rt0;iplPou05;bl0;cenTdMf8lay0pr7ra6t4velop0;a4ermM;il0;ng0;ess0;e5o4;rm0;rr0;mag0t0;alcul1eHharg0lGo9r6u4;lt4stomR;iv1;a5owd0u4;sh0;ck0mp0;d0lo9m6n4ok0vW;centr1s4troll0;idUolid1;b5pl4;ic1;in0;ur0;assi3os0;lebr1n6r4;ti3;fi0;tralB;a7i6o4urn0;il0r0t4und;tl0;as0;laJs0;bandon0cKdHffe2lEnCppAss8u4ward0;g5thor4;iz0;me4;nt0;o6u4;m0r0;li0re4;ci1;im1ticip1;at0;leg0t4;er0;ct0;ju5o7va4;nc0;st0;ce4knowledg0;pt0;ed",

@@ -63,0 +63,0 @@ "Person|Verb": "true¦b1chu2drew,grant,ja2ma0ollie,pat,rob,sue,wade;ck,rk;ob,u0;ck",

@@ -42,5 +42,5 @@ export default {

Duration: {
is: 'Noun',
also: ['Date'],
is: 'Date',
also: ['Noun'],
},
}

@@ -0,1 +1,5 @@

const byWord = {
this: 'Noun',
then: 'Pivot'
}

@@ -7,2 +11,7 @@ // simply chunk Nouns as <Noun>

let term = document[n][t]
if (byWord.hasOwnProperty(term.normal) === true) {
term.chunk = byWord[term.normal]
continue
}
if (term.tags.has('Verb')) {

@@ -12,3 +21,3 @@ term.chunk = 'Verb'

}
if (term.tags.has('Noun')) {
if (term.tags.has('Noun') || term.tags.has('Determiner')) {
term.chunk = 'Noun'

@@ -27,2 +36,3 @@ continue

}
}

@@ -29,0 +39,0 @@ }

import easyMode from './01-easy.js'
import matcher from './02-matcher.js'
import fallback from './03-fallback.js'
import fixUp from './04-fixUp.js'
import byNeighbour from './02-neighbours.js'
import matcher from './03-matcher.js'
import fallback from './04-fallback.js'
import fixUp from './05-fixUp.js'
/* Chunks:

@@ -15,4 +16,5 @@ Noun

easyMode(document)
byNeighbour(document)
matcher(view, document, world)
matcher(view, document, world) //run it 2nd time
// matcher(view, document, world) //run it 2nd time
fallback(document, world)

@@ -19,0 +21,0 @@ fixUp(document, world)

@@ -28,3 +28,3 @@ import find from '../find.js'

json(opts, n) {
let m = getNth(this, n).reverse()
let m = getNth(this, n)
let arr = m.map(vb => {

@@ -35,3 +35,3 @@ let json = vb.toView().json(opts)[0] || {}

}, [])
return arr.reverse()
return arr
}

@@ -38,0 +38,0 @@ subjects(n) {

@@ -16,5 +16,3 @@ import { doDoes, getTense } from '../lib.js'

if (aux.found) {
aux.reverse().forEach(m => {
vb.remove(m)
})
vb.remove(aux)
}

@@ -21,0 +19,0 @@ // there is no real way to do this

@@ -12,4 +12,6 @@ const forEach = function (cb) {

let ptrs = this.fullPointer
// let cache = this._cache || []
let res = ptrs.map((ptr, i) => {
let view = this.update([ptr])
// view._cache = cache[i]
return cb(view, i)

@@ -42,7 +44,11 @@ })

let ptrs = this.fullPointer
// let cache = this._cache || []
ptrs = ptrs.filter((ptr, i) => {
let view = this.update([ptr])
// view._cache = cache[i]
return cb(view, i)
})
return this.update(ptrs)
let res = this.update(ptrs) //TODO: keep caches automatically
// res._cache = ptrs.map(ptr => cache[ptr[0]])
return res
}

@@ -52,4 +58,6 @@

let ptrs = this.fullPointer
// let cache = this._cache || []
let found = ptrs.find((ptr, i) => {
let view = this.update([ptr])
// view._cache = cache[i]
return cb(view, i)

@@ -62,4 +70,6 @@ })

let ptrs = this.fullPointer
// let cache = this._cache || []
return ptrs.some((ptr, i) => {
let view = this.update([ptr])
// view._cache = cache[i]
return cb(view, i)

@@ -66,0 +76,0 @@ })

@@ -36,2 +36,3 @@ const utils = {

let ptr = this.pointer
let cache = this._cache || []
if (!ptr) {

@@ -41,3 +42,5 @@ ptr = this.docs.map((_doc, i) => [i])

if (ptr[n]) {
return this.update([ptr[n]])
let view = this.update([ptr[n]])
view._cache = cache[n]
return view
}

@@ -44,0 +47,0 @@ return this.none()

@@ -83,2 +83,6 @@ import world from './world.js'

}
// let [n, start, end] = ptr
// if (start === 0 && this.document[n][end - 1] && !this.document[n][end]) {
// console.log('=-=-=-= here -=-=-=-')
// }
})

@@ -85,0 +89,0 @@ m._cache = cache

@@ -37,2 +37,4 @@ import { Lexicon, Plugin, matchOptions } from './misc'

export function typeahead(words: Lexicon): any
/** export internal methods for plugins */
export interface TypedPlugin<Methods extends object> extends Plugin { methods: Methods }
}

@@ -39,0 +41,0 @@

@@ -5,3 +5,3 @@ import { Lexicon, Plugin, matchOptions } from './misc'

/** parse a given text */
declare function nlp(text: string, lexicon?: Lexicon): View
declare function nlp<PluginTypes = {}>(text: string, lexicon?: Lexicon): View & PluginTypes

@@ -36,2 +36,4 @@ // Constructor

export function typeahead(words: Lexicon): any
/** export library for extending with plugins */
export interface TypedPlugin<Methods extends object> extends Plugin { methods: Methods }
}

@@ -38,0 +40,0 @@

@@ -35,2 +35,4 @@ import { Lexicon, Plugin, matchOptions } from './misc'

export function typeahead(words: Lexicon): any
/** export internal methods for plugins */
export interface TypedPlugin<Methods extends object> extends Plugin { methods: Methods }
}

@@ -37,0 +39,0 @@

@@ -44,3 +44,3 @@ import { Document, Pointer, Groups, JsonProps, outMethods, matchOptions, Term } from '../misc'

/** run each phrase through a function, and create a new document */
map: (fn: (m: View) => any, emptyResult?: any) => View | any
map: (fn: (m: View) => any, emptyResult?: any) => View | []
/** return only the phrases that return true */

@@ -112,2 +112,4 @@ filter: (fn: (m: View) => boolean) => View

splitAfter: (match?: string, group?: string | number) => View
/** splitAfter() alias */
split: (match?: string, group?: string | number) => View

@@ -127,8 +129,16 @@ // Case

concat: (input: string | View) => View
/** .prepend() [alias] */
/** add these words before each match */
insertBefore: (input: string | View) => View
/** .append() [alias] */
/** insertBefore() alias */
prepend: (input: string | View) => View
/** add these words after each match */
insertAfter: (text: string | View) => View
/** insertAfter() alias */
append: (text: string | View) => View
/** insertAfter() alias */
insert: (text: string | View) => View
/** fully remove these terms from the document */
remove: (match: string | View) => View
/** alias for .remove() */
delete: (match: string | View) => View
/** search and replace match with new content */

@@ -157,4 +167,8 @@ replace: (from: string | View, to?: string | Function, keep?: object) => View

dehyphenate: () => View
/** alias for .dehyphenate() */
deHyphenate: () => View
/** add quotation marks around selections */
toQuotations: (start?: string, end?: string) => View
/** alias for toQuotations() */
toQuotation: (start?: string, end?: string) => View
/** add parentheses around selections */

@@ -182,2 +196,4 @@ toParentheses: (start?: string, end?: string) => View

union: (match: string | View) => View
/** .union() alias */
and: (match: string | View) => View
/** return only duplicate matches */

@@ -187,2 +203,4 @@ intersection: (match: string | View) => View

not: (match: string | View, options?: any) => View
/** .not() alias */
difference: (match: string | View, options?: any) => View
/** get everything that is not a match */

@@ -189,0 +207,0 @@ complement: (match: string | View) => View

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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