Skip to content

Commit

Permalink
13.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Feb 4, 2021
1 parent 39590ad commit a1b6a12
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 26 deletions.
2 changes: 1 addition & 1 deletion builds/compromise-tokenize.js

Large diffs are not rendered by default.

43 changes: 33 additions & 10 deletions builds/compromise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* compromise 13.9.0 MIT */
/* compromise 13.9.1 MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
Expand Down Expand Up @@ -1558,6 +1558,13 @@
implicit: true,
reduced: true
};
} else if (options === 'implicit') {
options = {
punctuation: true,
implicit: true,
whitespace: true,
trim: true
};
} else if (options === 'root') {
options = {
titlecase: false,
Expand All @@ -1582,6 +1589,11 @@
}

var text = terms.reduce(function (str, t, i) {
// don't output intro space for a contraction-match i'm good => "[am] good"
if (i === 0 && t.text === '' && t.implicit !== null && !options.implicit) {
return str;
}

options.last = isLast && i === terms.length - 1;
var showPre = true;
var showPost = true;
Expand All @@ -1598,7 +1610,8 @@
}
}

var txt = t.textOut(options, showPre, showPost); // if (options.titlecase && i === 0) {
var txt = t.textOut(options, showPre, showPost); // console.log(terms)
// if (options.titlecase && i === 0) {
// txt = titleCase(txt)
// }

Expand Down Expand Up @@ -1978,6 +1991,10 @@
res.reduced = this.text('reduced');
}

if (options.implicit) {
res.implicit = this.text('implicit');
}

if (options.root) {
res.root = this.text('root');
}
Expand Down Expand Up @@ -2480,7 +2497,13 @@


if (state.terms[state.t].isImplicit() && regs[state.r - 1] && state.terms[state.t + 1]) {
// if the last match was implicit too, we're missing a word.
if (state.terms[state.t - 1] && state.terms[state.t - 1].implicit === regs[state.r - 1].word) {
return null;
} // console.log(state.terms[state.t])
// does the next one match?


if (state.terms[state.t + 1].doesMatch(reg, state.start_i + state.t, state.phrase_length)) {
state.t += 2;
continue;
Expand Down Expand Up @@ -3796,7 +3819,7 @@

var fromJSON_1 = fromJSON;

var _version = '13.9.0';
var _version = '13.9.1';

var _data = {
"Comparative": "true¦better",
Expand Down Expand Up @@ -8398,7 +8421,7 @@
var list = [].concat(this.list);
var obj = {};
list = list.filter(function (p) {
var str = p.text('reduced').trim();
var str = p.text('reduced').trim() || p.text('implicit').trim();

if (obj.hasOwnProperty(str) === true) {
return false;
Expand Down Expand Up @@ -13011,9 +13034,9 @@

_createClass(Lists, [{
key: "conjunctions",

value:
/** coordinating conjunction */
value: function conjunctions() {
function conjunctions() {
return this.match('(and|or)');
}
/** split-up by list object */
Expand Down Expand Up @@ -13493,9 +13516,9 @@

_createClass(Parentheses, [{
key: "unwrap",

value:
/** remove the parentheses characters */
value: function unwrap() {
function unwrap() {
this.list.forEach(function (p) {
var first = p.terms(0);
first.pre = first.pre.replace(open, '');
Expand Down Expand Up @@ -13667,9 +13690,9 @@

_createClass(Quotations, [{
key: "unwrap",

value:
/** remove the quote characters */
value: function unwrap() {
function unwrap() {
return this;
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion builds/compromise.min.js

Large diffs are not rendered by default.

43 changes: 33 additions & 10 deletions builds/compromise.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* compromise 13.9.0 MIT */
/* compromise 13.9.1 MIT */
function _typeof(obj) {
"@babel/helpers - typeof";

Expand Down Expand Up @@ -1552,6 +1552,13 @@ var text = function text() {
implicit: true,
reduced: true
};
} else if (options === 'implicit') {
options = {
punctuation: true,
implicit: true,
whitespace: true,
trim: true
};
} else if (options === 'root') {
options = {
titlecase: false,
Expand All @@ -1576,6 +1583,11 @@ var text = function text() {
}

var text = terms.reduce(function (str, t, i) {
// don't output intro space for a contraction-match i'm good => "[am] good"
if (i === 0 && t.text === '' && t.implicit !== null && !options.implicit) {
return str;
}

options.last = isLast && i === terms.length - 1;
var showPre = true;
var showPost = true;
Expand All @@ -1592,7 +1604,8 @@ var text = function text() {
}
}

var txt = t.textOut(options, showPre, showPost); // if (options.titlecase && i === 0) {
var txt = t.textOut(options, showPre, showPost); // console.log(terms)
// if (options.titlecase && i === 0) {
// txt = titleCase(txt)
// }

Expand Down Expand Up @@ -1972,6 +1985,10 @@ var json$1 = function json() {
res.reduced = this.text('reduced');
}

if (options.implicit) {
res.implicit = this.text('implicit');
}

if (options.root) {
res.root = this.text('root');
}
Expand Down Expand Up @@ -2474,7 +2491,13 @@ var tryHere = function tryHere(terms, regs, start_i, phrase_length) {


if (state.terms[state.t].isImplicit() && regs[state.r - 1] && state.terms[state.t + 1]) {
// if the last match was implicit too, we're missing a word.
if (state.terms[state.t - 1] && state.terms[state.t - 1].implicit === regs[state.r - 1].word) {
return null;
} // console.log(state.terms[state.t])
// does the next one match?


if (state.terms[state.t + 1].doesMatch(reg, state.start_i + state.t, state.phrase_length)) {
state.t += 2;
continue;
Expand Down Expand Up @@ -3790,7 +3813,7 @@ var fromJSON = function fromJSON(json, world) {

var fromJSON_1 = fromJSON;

var _version = '13.9.0';
var _version = '13.9.1';

var _data = {
"Comparative": "true¦better",
Expand Down Expand Up @@ -8392,7 +8415,7 @@ var unique$4 = function unique() {
var list = [].concat(this.list);
var obj = {};
list = list.filter(function (p) {
var str = p.text('reduced').trim();
var str = p.text('reduced').trim() || p.text('implicit').trim();

if (obj.hasOwnProperty(str) === true) {
return false;
Expand Down Expand Up @@ -13005,9 +13028,9 @@ var addMethod$4 = function addMethod(Doc) {

_createClass(Lists, [{
key: "conjunctions",

value:
/** coordinating conjunction */
value: function conjunctions() {
function conjunctions() {
return this.match('(and|or)');
}
/** split-up by list object */
Expand Down Expand Up @@ -13487,9 +13510,9 @@ var addMethod$6 = function addMethod(Doc) {

_createClass(Parentheses, [{
key: "unwrap",

value:
/** remove the parentheses characters */
value: function unwrap() {
function unwrap() {
this.list.forEach(function (p) {
var first = p.terms(0);
first.pre = first.pre.replace(open, '');
Expand Down Expand Up @@ -13661,9 +13684,9 @@ var addMethod$8 = function addMethod(Doc) {

_createClass(Quotations, [{
key: "unwrap",

value:
/** remove the quote characters */
value: function unwrap() {
function unwrap() {
return this;
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)",
"name": "compromise",
"description": "modest natural language processing",
"version": "13.9.0",
"version": "13.9.1",
"main": "./builds/compromise.js",
"unpkg": "./builds/compromise.min.js",
"module": "./builds/compromise.mjs",
Expand Down
8 changes: 6 additions & 2 deletions scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ nlp.extend(require('./plugins/penn-tags/src'))
// console.log(`|${m.text()}|`)
// m.debug()

let doc = nlp(`is not foobar isn't`)
doc = doc.terms().unique().debug()
let str = `Leonard's was Randall`
let doc = nlp(str)
console.log(doc.match('#Noun').text())

// let doc = nlp(`is not foobar isn't`)
// doc = doc.terms().unique().debug()
// console.log('|' + nlp(`isn't`).text('implicit') + '|')

// console.log(`|${doc.text()}|`)
Expand Down
2 changes: 1 addition & 1 deletion src/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '13.9.0'
module.exports = '13.9.1'

0 comments on commit a1b6a12

Please sign in to comment.