compromise-sentences
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -151,3 +151,3 @@ (function (global, factory) { | ||
vb = vb.verbs().toNegative(); | ||
obj.verb.replaceWith(vb, false, true); | ||
obj.verb.replaceWith(vb, false); | ||
}); | ||
@@ -164,3 +164,3 @@ return this; | ||
vb = vb.verbs().toPositive(); | ||
obj.verb.replaceWith(vb, false, true); | ||
obj.verb.replaceWith(vb, false); | ||
}); | ||
@@ -239,3 +239,3 @@ return this; | ||
vb = vb.verbs().toPastTense(); | ||
obj.verb.replaceWith(vb, false, true); // trailing gerund/future/present are okay, but 'walked and eats' is not | ||
obj.verb.replaceWith(vb, false); // trailing gerund/future/present are okay, but 'walked and eats' is not | ||
@@ -270,3 +270,3 @@ if (obj.object && obj.object.found && obj.object.has('#PresentTense')) { | ||
obj.verb.replaceWith(vb, false, true); // future is okay, but 'walks and ate' -> 'walks and eats' | ||
obj.verb.replaceWith(vb, false); // future is okay, but 'walks and ate' -> 'walks and eats' | ||
@@ -288,3 +288,3 @@ if (obj.object && obj.object.found && obj.object.has('#PastTense')) { | ||
vb = vb.verbs().toFutureTense(); | ||
obj.verb.replaceWith(vb, false, true); //Present is okay, but 'will walk and ate' -> 'will walk and eat' | ||
obj.verb.replaceWith(vb, false); //Present is okay, but 'will walk and ate' -> 'will walk and eat' | ||
@@ -291,0 +291,0 @@ if (obj.object && obj.object.found && obj.object.has('(#PastTense|#PresentTense)')) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).compromiseSentences=t()}(this,(function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e){return(t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}var o=function(e){var t=e.clone(!0);return 1===t.length?t:1===(t=t.if("#Verb")).length?t:1===(t=(t=(t=(t=(t=t.ifNo("(after|although|as|because|before|if|since|than|that|though|when|whenever|where|whereas|wherever|whether|while|why|unless|until|once)")).ifNo("^even (if|though)")).ifNo("^so that")).ifNo("^rather than")).ifNo("^provided that")).length?t:1===(t=t.ifNo("(that|which|whichever|who|whoever|whom|whose|whomever)")).length?t:1===(t=t.ifNo("(despite|during|before|through|throughout)")).length?t:(0===t.length&&(t=e),t.eq(0))},i=function(e){var t=e.clauses(),n=o(t),r=n.match("#Determiner? (#Noun|#Adjective)+").if("#Noun"),i=n.verbs().eq(0);return{subject:r.eq(0),verb:i,object:i.lookAhead(".*")}},s={toNegative:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();n=n.verbs().toNegative(),t.verb.replaceWith(n,!1,!0)})),this},toPositive:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();n=n.verbs().toPositive(),t.verb.replaceWith(n,!1,!0)})),this}},u={isQuestion:function(){return this.filter((function(e){return e.lastTerm().termList(0).hasPost("?")}))},isExclamation:function(){return this.filter((function(e){return e.lastTerm().termList(0).hasPost("!")}))},isStatement:function(){return this.filter((function(e){var t=e.lastTerm().termList(0);return!t.hasPost("?")&&!t.hasPost("!")}))},toExclamation:function(){return this},toQuestion:function(){return this},toStatement:function(){return this}},c={toPastTense:function(){return this.forEach((function(e){if(!e.has("#PastTense")){var t=i(e),n=t.verb.clone();if(n=n.verbs().toPastTense(),t.verb.replaceWith(n,!1,!0),t.object&&t.object.found&&t.object.has("#PresentTense"))t.object.verbs().if("#PresentTense").verbs().toPastTense()}})),this},toPresentTense:function(){return this.forEach((function(e){var t=i(e),n=t.verb.lookBehind("(i|we) (#Adverb|#Verb)?$").found,r=t.verb.clone();(r=n?r.has("(is|was|am|be)")?r.replace("will? (is|was|am|be)","am"):r.verbs().toInfinitive():r.verbs().toPresentTense(),t.verb.replaceWith(r,!1,!0),t.object&&t.object.found&&t.object.has("#PastTense"))&&t.object.verbs().if("#PastTense").verbs().toPresentTense()})),this},toFutureTense:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();(n=n.verbs().toFutureTense(),t.verb.replaceWith(n,!1,!0),t.object&&t.object.found&&t.object.has("(#PastTense|#PresentTense)"))&&t.object.verbs().if("(#PastTense|#PresentTense)").verbs().toInfinitive()})),this}},a=Object.assign({},s,u,c);return function(o){var s=function(o){function s(e,n,o){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),e=e.map((function(e){return e.clone(!0)})),r(this,t(s).call(this,e,n,o))}var u,c,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}(s,o),u=s,(c=[{key:"json",value:function(e){var t=null;"number"==typeof e&&(t=e,e=null),e=e||{text:!0,normal:!0,trim:!0,terms:!0};var n=[];return this.forEach((function(t){var r=t.json(e)[0],o=i(t);r.subject=o.subject.json(e)[0],r.verb=o.verb.json(e)[0],r.object=o.object.json(e)[0],n.push(r)})),null!==t?n[t]:n}},{key:"subjects",value:function(){return this.map((function(e){return i(e).subject}))}},{key:"isPassive",value:function(){return this.if("was #Adverb? #PastTense #Adverb? by")}},{key:"prepend",value:function(e){return this.forEach((function(t){var n=t.match("^.");n.not("#ProperNoun").toLowerCase(),n.prepend(e),n.terms(0).toTitleCase()})),this}},{key:"append",value:function(e){var t=/[.?!]\s*$/.test(e);return this.forEach((function(n){var r=n.match(".$"),o=r.termList(0),i=o.post;!0===t&&(i=""),r.append(e+i),o.post=" "})),this}}])&&e(u.prototype,c),a&&e(u,a),s}(o);return Object.assign(s.prototype,a),o.prototype.sentences=function(e){var t=this.all();return"number"==typeof e&&(t=t.get(e)),new s(t.list,this,this.world)},o}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).compromiseSentences=t()}(this,(function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e){return(t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}var o=function(e){var t=e.clone(!0);return 1===t.length?t:1===(t=t.if("#Verb")).length?t:1===(t=(t=(t=(t=(t=t.ifNo("(after|although|as|because|before|if|since|than|that|though|when|whenever|where|whereas|wherever|whether|while|why|unless|until|once)")).ifNo("^even (if|though)")).ifNo("^so that")).ifNo("^rather than")).ifNo("^provided that")).length?t:1===(t=t.ifNo("(that|which|whichever|who|whoever|whom|whose|whomever)")).length?t:1===(t=t.ifNo("(despite|during|before|through|throughout)")).length?t:(0===t.length&&(t=e),t.eq(0))},i=function(e){var t=e.clauses(),n=o(t),r=n.match("#Determiner? (#Noun|#Adjective)+").if("#Noun"),i=n.verbs().eq(0);return{subject:r.eq(0),verb:i,object:i.lookAhead(".*")}},s={toNegative:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();n=n.verbs().toNegative(),t.verb.replaceWith(n,!1)})),this},toPositive:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();n=n.verbs().toPositive(),t.verb.replaceWith(n,!1)})),this}},u={isQuestion:function(){return this.filter((function(e){return e.lastTerm().termList(0).hasPost("?")}))},isExclamation:function(){return this.filter((function(e){return e.lastTerm().termList(0).hasPost("!")}))},isStatement:function(){return this.filter((function(e){var t=e.lastTerm().termList(0);return!t.hasPost("?")&&!t.hasPost("!")}))},toExclamation:function(){return this},toQuestion:function(){return this},toStatement:function(){return this}},c={toPastTense:function(){return this.forEach((function(e){if(!e.has("#PastTense")){var t=i(e),n=t.verb.clone();if(n=n.verbs().toPastTense(),t.verb.replaceWith(n,!1),t.object&&t.object.found&&t.object.has("#PresentTense"))t.object.verbs().if("#PresentTense").verbs().toPastTense()}})),this},toPresentTense:function(){return this.forEach((function(e){var t=i(e),n=t.verb.lookBehind("(i|we) (#Adverb|#Verb)?$").found,r=t.verb.clone();(r=n?r.has("(is|was|am|be)")?r.replace("will? (is|was|am|be)","am"):r.verbs().toInfinitive():r.verbs().toPresentTense(),t.verb.replaceWith(r,!1),t.object&&t.object.found&&t.object.has("#PastTense"))&&t.object.verbs().if("#PastTense").verbs().toPresentTense()})),this},toFutureTense:function(){return this.forEach((function(e){var t=i(e),n=t.verb.clone();(n=n.verbs().toFutureTense(),t.verb.replaceWith(n,!1),t.object&&t.object.found&&t.object.has("(#PastTense|#PresentTense)"))&&t.object.verbs().if("(#PastTense|#PresentTense)").verbs().toInfinitive()})),this}},a=Object.assign({},s,u,c);return function(o){var s=function(o){function s(e,n,o){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),e=e.map((function(e){return e.clone(!0)})),r(this,t(s).call(this,e,n,o))}var u,c,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}(s,o),u=s,(c=[{key:"json",value:function(e){var t=null;"number"==typeof e&&(t=e,e=null),e=e||{text:!0,normal:!0,trim:!0,terms:!0};var n=[];return this.forEach((function(t){var r=t.json(e)[0],o=i(t);r.subject=o.subject.json(e)[0],r.verb=o.verb.json(e)[0],r.object=o.object.json(e)[0],n.push(r)})),null!==t?n[t]:n}},{key:"subjects",value:function(){return this.map((function(e){return i(e).subject}))}},{key:"isPassive",value:function(){return this.if("was #Adverb? #PastTense #Adverb? by")}},{key:"prepend",value:function(e){return this.forEach((function(t){var n=t.match("^.");n.not("#ProperNoun").toLowerCase(),n.prepend(e),n.terms(0).toTitleCase()})),this}},{key:"append",value:function(e){var t=/[.?!]\s*$/.test(e);return this.forEach((function(n){var r=n.match(".$"),o=r.termList(0),i=o.post;!0===t&&(i=""),r.append(e+i),o.post=" "})),this}}])&&e(u.prototype,c),a&&e(u,a),s}(o);return Object.assign(s.prototype,a),o.prototype.sentences=function(e){var t=this.all();return"number"==typeof e&&(t=t.get(e)),new s(t.list,this,this.world)},o}})); |
{ | ||
"name": "compromise-sentences", | ||
"description": "plugin for nlp-compromise", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)", | ||
@@ -6,0 +6,0 @@ "main": "./builds/compromise-sentences.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47015