compromise
Advanced tools
Comparing version 14.12.0 to 14.13.0
@@ -5,3 +5,3 @@ { | ||
"description": "modest natural language processing", | ||
"version": "14.12.0", | ||
"version": "14.13.0", | ||
"module": "./src/three.js", | ||
@@ -8,0 +8,0 @@ "main": "./src/three.js", |
@@ -1,1 +0,1 @@ | ||
export default '14.12.0' | ||
export default '14.13.0' |
@@ -6,3 +6,4 @@ import { cleanAppend, cleanPrepend } from './lib/insert.js' | ||
const expand = function (m) { | ||
if (m.has('@hasContraction') && typeof m.contractions === 'function') {//&& m.after('^.').has('@hasContraction') | ||
if (m.has('@hasContraction') && typeof m.contractions === 'function') { | ||
//&& m.after('^.').has('@hasContraction') | ||
let more = m.grow('@hasContraction') | ||
@@ -13,7 +14,7 @@ more.contractions().expand() | ||
const isArray = (arr) => Object.prototype.toString.call(arr) === '[object Array]' | ||
const isArray = arr => Object.prototype.toString.call(arr) === '[object Array]' | ||
// set new ids for each terms | ||
const addIds = function (terms) { | ||
terms = terms.map((term) => { | ||
terms = terms.map(term => { | ||
term.id = uuid(term) | ||
@@ -80,6 +81,7 @@ return term | ||
// try to tag them, too | ||
doc.compute(['id', 'index', 'lexicon']) | ||
doc.compute(['id', 'index', 'freeze', 'lexicon']) | ||
if (doc.world.compute.preTagger) { | ||
doc.compute('preTagger') | ||
} | ||
doc.compute('unfreeze') | ||
return doc | ||
@@ -95,3 +97,2 @@ } | ||
}, | ||
} | ||
@@ -98,0 +99,0 @@ fns.append = fns.insertAfter |
@@ -5,3 +5,3 @@ const dollarStub = /\$[0-9a-z]+/g | ||
const titleCase = function (str) { | ||
return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) | ||
return str.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) | ||
} | ||
@@ -24,3 +24,3 @@ | ||
let groups = main.groups() | ||
input = input.replace(dollarStub, (a) => { | ||
input = input.replace(dollarStub, a => { | ||
let num = a.replace(/\$/, '') | ||
@@ -70,4 +70,4 @@ if (groups.hasOwnProperty(num)) { | ||
if (!term.tags.has('Possessive')) { | ||
term.text += '\'s' | ||
term.normal += '\'s' | ||
term.text += "'s" | ||
term.normal += "'s" | ||
term.tags.add('Possessive') | ||
@@ -77,6 +77,7 @@ } | ||
// what should we return? | ||
let m = main.toView(ptrs).compute(['index', 'lexicon']) | ||
let m = main.toView(ptrs).compute(['index', 'freeze', 'lexicon']) | ||
if (m.world.compute.preTagger) { | ||
m.compute('preTagger') | ||
} | ||
m.compute('unfreeze') | ||
// replace any old tags | ||
@@ -83,0 +84,0 @@ if (keep.tags) { |
@@ -0,11 +1,15 @@ | ||
import compute from './compute.js' | ||
import debug from './debug.js' | ||
export default { | ||
// lib: { | ||
// freeze: function (obj) { | ||
// this.world().model.two.freeze = obj | ||
// }, | ||
// }, | ||
// add .compute('freeze') | ||
compute, | ||
mutate: world => { | ||
const methods = world.methods.one | ||
// add @isFrozen method | ||
world.methods.one.termMethods.isFrozen = term => term.frozen === true | ||
methods.termMethods.isFrozen = term => term.frozen === true | ||
// adds `.debug('frozen')` | ||
methods.debug.freeze = debug | ||
methods.debug.frozen = debug | ||
}, | ||
@@ -25,8 +29,3 @@ | ||
View.prototype.unfreeze = function () { | ||
this.docs.forEach(ts => { | ||
ts.forEach(term => { | ||
delete term.frozen | ||
}) | ||
}) | ||
return this | ||
this.compute('unfreeze') | ||
} | ||
@@ -38,2 +37,4 @@ // return all frozen terms | ||
}, | ||
// run it in init | ||
hooks: ['freeze'], | ||
} |
@@ -8,2 +8,3 @@ import multiWord from './multi-word.js' | ||
const world = view.world | ||
// loop through our terms | ||
view.docs.forEach(terms => { | ||
@@ -10,0 +11,0 @@ for (let i = 0; i < terms.length; i += 1) { |
@@ -6,3 +6,3 @@ // scan-ahead to match multiple-word terms - 'jack rabbit' | ||
const multi = model.one._multiCache || {} | ||
const { lexicon, frozenLex } = model.one || {} | ||
const { lexicon } = model.one || {} | ||
let t = terms[start_i] | ||
@@ -20,8 +20,2 @@ let word = t.machine || t.normal | ||
let str = words.map(term => term.machine || term.normal).join(' ') | ||
// lookup frozen lexicon | ||
if (frozenLex.hasOwnProperty(str) === true) { | ||
setTag(words, frozenLex[str], world, false, '1-frozen-multi-lexicon') | ||
words.forEach(term => (term.frozen = true)) | ||
return true | ||
} | ||
// lookup regular lexicon | ||
@@ -28,0 +22,0 @@ if (lexicon.hasOwnProperty(str) === true) { |
@@ -10,3 +10,3 @@ const prefix = /^(under|over|mis|re|un|dis|semi|pre|post)-?/ | ||
const setTag = methods.one.setTag | ||
const { lexicon, frozenLex } = model.one | ||
const { lexicon } = model.one | ||
@@ -16,8 +16,2 @@ // basic lexicon lookup | ||
let word = t.machine || t.normal | ||
// freeze lex | ||
if (frozenLex[word] !== undefined && frozenLex.hasOwnProperty(word)) { | ||
setTag([t], frozenLex[word], world, false, '1-freeze-lexicon') | ||
t.frozen = true | ||
return true | ||
} | ||
// normal lexicon lookup | ||
@@ -24,0 +18,0 @@ if (lexicon[word] !== undefined && lexicon.hasOwnProperty(word)) { |
@@ -19,3 +19,3 @@ const hasSlash = /\// | ||
// don't split urls and things | ||
if (arr.length <= 2) { | ||
if (arr.length <= 3) { | ||
arr.forEach(word => { | ||
@@ -22,0 +22,0 @@ word = word.trim() |
@@ -31,3 +31,3 @@ import splice from './_splice.js' | ||
tmp.ptrs = [[0, start, end]] | ||
tmp.compute(['lexicon', 'preTagger']) | ||
tmp.compute(['freeze', 'lexicon', 'preTagger', 'unfreeze']) | ||
// don't for a reindex of the whole document | ||
@@ -34,0 +34,0 @@ reIndex(terms) |
@@ -23,4 +23,4 @@ let net = null | ||
// helper function for compute('tagger') | ||
const tagger = view => view.compute(['lexicon', 'preTagger', 'postTagger']) | ||
const tagger = view => view.compute(['freeze', 'lexicon', 'preTagger', 'postTagger', 'unfreeze']) | ||
export default { postTagger, tagger } |
@@ -31,2 +31,3 @@ export default { | ||
'doctor who': 'Person', | ||
'dr who': 'Person', | ||
'he man': 'Person', | ||
@@ -33,0 +34,0 @@ 'iron man': 'Person', |
@@ -13,10 +13,10 @@ import fractions from './fractions/api.js' | ||
// add @greaterThan, @lessThan | ||
mutate: world => { | ||
let termMethods = world.methods.one.termMethods | ||
// mutate: world => { | ||
// let termMethods = world.methods.one.termMethods | ||
termMethods.lessThan = function (term) { | ||
console.log(term) | ||
// return /[aeiou]/.test(term.text) | ||
} | ||
}, | ||
// termMethods.lessThan = function (term) { | ||
// return false //TODO: implement | ||
// // return /[aeiou]/.test(term.text) | ||
// } | ||
// }, | ||
} |
@@ -27,5 +27,5 @@ import { doDoes, getTense } from '../lib.js' | ||
} | ||
vb.fullSentence().compute(['lexicon', 'preTagger', 'postTagger', 'chunks']) | ||
vb.fullSentence().compute(['freeze', 'lexicon', 'preTagger', 'postTagger', 'unfreeze', 'chunks']) | ||
return vb | ||
} | ||
export default toInf |
@@ -7,3 +7,3 @@ import world from './world.js' | ||
// invisible props | ||
[ | ||
let props = [ | ||
['document', document], | ||
@@ -13,4 +13,5 @@ ['world', world], | ||
['_cache', null], | ||
['viewType', 'View'] | ||
].forEach(a => { | ||
['viewType', 'View'], | ||
] | ||
props.forEach(a => { | ||
Object.defineProperty(this, a[0], { | ||
@@ -106,6 +107,7 @@ value: a[1], | ||
doc.world = this.world | ||
doc.compute(['normal', 'lexicon']) | ||
doc.compute(['normal', 'freeze', 'lexicon']) | ||
if (this.world.compute.preTagger) { | ||
doc.compute('preTagger') | ||
} | ||
doc.compute('unfreeze') | ||
return doc | ||
@@ -115,3 +117,3 @@ } | ||
// clone the whole document | ||
let document = this.document.slice(0) //node 17: structuredClone(document); | ||
let document = this.document.slice(0) //node 17: structuredClone(document); | ||
document = document.map(terms => { | ||
@@ -118,0 +120,0 @@ return terms.map(term => { |
@@ -23,4 +23,4 @@ import nlp from './nlp.js' // 5kb | ||
nlp.plugin(contractions) //~6kb | ||
nlp.extend(tokenize) //7kb | ||
nlp.extend(freeze) // | ||
nlp.extend(tokenize) //7kb | ||
nlp.plugin(cache) //~1kb | ||
@@ -27,0 +27,0 @@ nlp.extend(lookup) //7kb |
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
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
2569492
470
28936