Skip to content

Commit

Permalink
Merge pull request #810 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain authored Feb 4, 2021
2 parents 551909b + a1b6a12 commit 33683ce
Show file tree
Hide file tree
Showing 16 changed files with 796 additions and 569 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
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ While all _Major_ releases should be reviewed, our only two _large_ releases are
<!-- #### [Unreleased]
-->

#### 13.9.1 [Feb 2021]
- **[fix]** - matches over a contraction
- **[new]** - add 'implicit' text output

#### 13.9.0 [Feb 2021]
- **[new]** - World.addConjugations() method
- **[new]** - World.addPlurals() method
Expand Down
Loading

0 comments on commit 33683ce

Please sign in to comment.