From 82d2245b34788ca912d8362b64e42d572e5988a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Sun, 14 Apr 2019 21:22:15 +0200 Subject: [PATCH 1/6] fix: npm run lint and test throw error on windows --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b3be48c..bb754b1 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "build": "gulp build", "build:browser": "gulp build:browser", "prepublish": "npm run lint && npm run test && npm run compile", - "lint": "eslint 'src/**/*.js' 'test/*.js'", + "lint": "eslint \"src/**/*.js\" \"test/*.js\"", "lint:fix": "npm run lint -- --fix", - "test": "nyc --reporter=html --reporter=text mocha test/setup.js --sort 'src/**/*.spec.js' --compilers js:babel-core/register --timeout 30000", + "test": "nyc --reporter=html --reporter=text mocha test/setup.js --sort \"src/**/*.spec.js\" --compilers js:babel-core/register --timeout 30000", "test:watch": "npm run test -- --watch", "doc": "DEBUG=gulp-jsdoc3 gulp doc" }, From 5e5610e6e4dc74ffe2d1192c148e478b7bf792f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Sun, 14 Apr 2019 23:46:37 +0200 Subject: [PATCH 2/6] First work in progress --- examples/browser/corenlp.min.js | 2 +- src/index.js | 4 +++ src/index.spec.js | 4 +++ src/pipeline.js | 4 +++ src/simple/annotator/natlog.js | 39 +++++++++++++++++++++++++ src/simple/annotator/natlog.spec.js | 20 +++++++++++++ src/simple/annotator/openie.js | 45 +++++++++++++++++++++++++++++ src/simple/annotator/openie.spec.js | 20 +++++++++++++ src/simple/sentence.js | 22 ++++++++++++-- 9 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 src/simple/annotator/natlog.js create mode 100644 src/simple/annotator/natlog.spec.js create mode 100644 src/simple/annotator/openie.js create mode 100644 src/simple/annotator/openie.spec.js diff --git a/examples/browser/corenlp.min.js b/examples/browser/corenlp.min.js index 4d26fdf..7d377a1 100644 --- a/examples/browser/corenlp.min.js +++ b/examples/browser/corenlp.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CoreNLP=e()}}(function(){return function(){return function e(t,n,r){function o(s,i){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(a)return a(s,!0);var p=new Error("Cannot find module '"+s+"'");throw p.code="MODULE_NOT_FOUND",p}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return o(n||e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s-1}function f(e,t,n){for(var r=-1,o=e?e.length:0;++r=n&&(i=m,u=!1,t=new R(t));e:for(;++s-1},E.prototype.set=function(e,t){var n=this.__data__,r=J(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},C.prototype.clear=function(){this.__data__={hash:new D,map:new(I||E),string:new D}},C.prototype.delete=function(e){return F(this,e).delete(e)},C.prototype.get=function(e){return F(this,e).get(e)},C.prototype.has=function(e){return F(this,e).has(e)},C.prototype.set=function(e,t){return F(this,e).set(e,t),this},R.prototype.add=R.prototype.push=function(e){return this.__data__.set(e,r),this},R.prototype.has=function(e){return this.__data__.has(e)};var B,W,U=(B=function(e,t){return K(e)?$(e,function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=q),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):h(a,u):o||(a[a.length]=u)}return a}(t,1,K,!0)):[]},W=T(void 0===W?B.length-1:W,0),function(){for(var e=arguments,t=-1,n=T(e.length-W,0),r=Array(n);++t-1&&e%1==0&&e<=o}(e.length)&&!Q(e)}function K(e){return function(e){return!!e&&"object"==typeof e}(e)&&H(e)}function Q(e){var t=X(e)?P.call(e):"";return t==s||t==i}function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=U}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(e){var n=9007199254740991,r="[object Arguments]",o="[object Function]",a="[object GeneratorFunction]",s="object"==typeof e&&e&&e.Object===Object&&e,i="object"==typeof self&&self&&self.Object===Object&&self,u=s||i||Function("return this")();function p(e,t){for(var n=-1,r=t.length,o=e.length;++n-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?d.call(e):"";return t==o||t==a}(e)}(e)}(e)&&c.call(e,"callee")&&(!h.call(e,"callee")||d.call(e)==r)}(e)||!!(g&&e&&e[g])}var _=Array.isArray;t.exports=function(e){return e&&e.length?function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=m),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):p(a,u):o||(a[a.length]=u)}return a}(e,1):[]}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){t.exports=function(e){return e&&e.length?e[0]:void 0}},{}],5:[function(e,t,n){(function(e){var r=200,o="Expected a function",a="__lodash_hash_undefined__",s=1,i=2,u=1/0,p=9007199254740991,l="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Function]",m="[object GeneratorFunction]",_="[object Map]",v="[object Number]",b="[object Object]",x="[object RegExp]",y="[object Set]",j="[object String]",w="[object Symbol]",O="[object ArrayBuffer]",P="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,A=/^\./,N=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,V=/\\(\\)?/g,T=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,M={};M["[object Float32Array]"]=M["[object Float64Array]"]=M["[object Int8Array]"]=M["[object Int16Array]"]=M["[object Int32Array]"]=M["[object Uint8Array]"]=M["[object Uint8ClampedArray]"]=M["[object Uint16Array]"]=M["[object Uint32Array]"]=!0,M[l]=M[c]=M[O]=M[d]=M[P]=M[f]=M[h]=M[g]=M[_]=M[v]=M[b]=M[x]=M[y]=M[j]=M["[object WeakMap]"]=!1;var D="object"==typeof e&&e&&e.Object===Object&&e,E="object"==typeof self&&self&&self.Object===Object&&self,C=D||E||Function("return this")(),R="object"==typeof n&&n&&!n.nodeType&&n,J=R&&"object"==typeof t&&t&&!t.nodeType&&t,$=J&&J.exports===R&&D.process,z=function(){try{return $&&$.binding("util")}catch(e){}}(),F=z&&z.isTypedArray;function L(e,t,n,r){var o=-1,a=e?e.length:0;for(r&&a&&(n=e[++o]);++o-1},ke.prototype.set=function(e,t){var n=this.__data__,r=Te(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new Pe,map:new(de||ke),string:new Pe}},Se.prototype.delete=function(e){return Be(this,e).delete(e)},Se.prototype.get=function(e){return Be(this,e).get(e)},Se.prototype.has=function(e){return Be(this,e).has(e)},Se.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,a),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.clear=function(){this.__data__=new ke},Ne.prototype.delete=function(e){return this.__data__.delete(e)},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ke){var o=n.__data__;if(!de||o.lengthp))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var d=-1,f=!0,h=o&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e-1&&e%1==0&&e<=p}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function pt(e){return"symbol"==typeof e||ut(e)&&oe.call(e)==w}var lt=F?function(e){return function(t){return e(t)}}(F):function(e){return ut(e)&&st(e.length)&&!!M[oe.call(e)]};function ct(e){return ot(e)?Ve(e):Fe(e)}function dt(e){return e}t.exports=function(e,t,n){var r=rt(e)?L:B,o=arguments.length<3;return r(e,ze(t),n,o,De)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,n){(function(e){var n=200,r="__lodash_hash_undefined__",o="[object Function]",a="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,i="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,p=i||u||Function("return this")();function l(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var o=e.length,a=n+(r?1:-1);for(;r?a--:++a-1}function c(e,t,n){for(var r=-1,o=e?e.length:0;++r-1},V.prototype.set=function(e,t){var n=this.__data__,r=M(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new N,map:new(k||V),string:new N}},T.prototype.delete=function(e){return C(this,e).delete(e)},T.prototype.get=function(e){return C(this,e).get(e)},T.prototype.has=function(e){return C(this,e).has(e)},T.prototype.set=function(e,t){return C(this,e).set(e,t),this},I.prototype.add=I.prototype.push=function(e){return this.__data__.set(e,r),this},I.prototype.has=function(e){return this.__data__.has(e)};var E=S&&1/h(new S([,-0]))[1]==1/0?function(e){return new S(e)}:function(){};function C(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function R(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return D(n)?n:void 0}function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return e&&e.length?function(e,t,r){var o=-1,a=l,s=e.length,i=!0,u=[],p=u;if(r)i=!1,a=c;else if(s>=n){var d=t?null:E(e);if(d)return h(d);i=!1,a=f,p=new I}else p=t?[]:u;e:for(;++othis._exec(`java ${n.concat([`-file ${e.path}`]).join(" ")}`).then(e=>{const t=(e.stdout||e.stderr).match(/writing to (.*\.json)/)[1];return this._loadJSONFile(t)}))}}},{"child-process-promise":1,"load-json-file":1,"tmp-file":1}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;t0===e.indexOf(`${a}.`)).map(e=>`${e.replace(`${a}.`,"")}=${encodeURI(n[e])}`).join("&")}`),this._makeRequest(i,u,t)}_makeRequest(e,t,n){const r={method:"POST",uri:`${e}?${t}`,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:n,json:!0};return this._rp(r)}}},{"request-promise-native":11}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectorServer=n.ConnectorCli=n.Service=n.Pipeline=n.Properties=void 0;var r=P(e("./simple/document")),o=P(e("./simple/sentence")),a=P(e("./simple/token")),s=P(e("./simple/expression")),i=P(e("./simple/annotable")),u=P(e("./simple/annotator")),p=P(e("./simple/annotator/tokenize")),l=P(e("./simple/annotator/ssplit")),c=P(e("./simple/annotator/pos")),d=P(e("./simple/annotator/lemma")),f=P(e("./simple/annotator/ner")),h=P(e("./simple/annotator/parse")),g=P(e("./simple/annotator/depparse")),m=P(e("./simple/annotator/relation")),_=P(e("./simple/annotator/regexner")),v=P(e("./simple/annotator/coref")),b=P(e("./util/tree")),x=P(e("./properties")),y=P(e("./pipeline")),j=P(e("./service")),w=P(e("./connector/connector-cli")),O=P(e("./connector/connector-server"));function P(e){return e&&e.__esModule?e:{default:e}}n.Properties=x.default,n.Pipeline=y.default,n.Service=j.default,n.ConnectorCli=w.default,n.ConnectorServer=O.default;n.default={simple:{Annotable:i.default,Annotator:u.default,Document:r.default,Sentence:o.default,Token:a.default,Expression:s.default,annotator:{TokenizerAnnotator:p.default,WordsToSentenceAnnotator:l.default,POSTaggerAnnotator:c.default,MorphaAnnotator:d.default,NERClassifierCombiner:f.default,ParserAnnotator:h.default,DependencyParseAnnotator:g.default,RelationExtractorAnnotator:m.default,RegexNERAnnotator:_.default,CorefAnnotator:v.default}},util:{Tree:b.default}}},{"./connector/connector-cli":7,"./connector/connector-server":8,"./pipeline":10,"./properties":12,"./service":13,"./simple/annotable":14,"./simple/annotator":15,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/ner":20,"./simple/annotator/parse":21,"./simple/annotator/pos":24,"./simple/annotator/regexner":27,"./simple/annotator/relation":28,"./simple/annotator/ssplit":29,"./simple/annotator/tokenize":30,"./simple/document":33,"./simple/expression":36,"./simple/sentence":38,"./simple/token":39,"./util/tree":40}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t(new e).toString()),this._getAnnotatorsKeys()).length>0)throw new Error(`Assert: ${e} requires ${t.join()} within the annotators list.`)}annotateTokensRegex(e,t=!1){var n=this;return x(function*(){return n.assert("TokensRegex",[i.default,u.default]),e.fromJSON(yield n._service.getTokensRegexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatrosOptions())),e.setLanguageISO(j[n._language]),e.addAnnotator(v.TokensRegexAnnotator),t?n._annotateExpression(e):e})()}annotateSemgrex(e,t=!1){var n=this;return x(function*(){return n.assert("Semgrex",[i.default,u.default,f.default]),e.fromJSON(yield n._service.getSemgrexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatrosOptions())),e.setLanguageISO(j[n._language]),e.addAnnotator(v.SemgrexAnnotator),t?n._annotateExpression(e):e})()}annotateTregex(e,t=!1){var n=this;return x(function*(){return n.assert("Tregex",[i.default,u.default,d.default]),e.fromJSON(yield n._service.getTregexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatrosOptions())),e.setLanguageISO(j[n._language]),e.addAnnotator(v.TregexAnnotator),t?n._annotateExpression(e):e})()}_annotateExpression(e){var t=this;return x(function*(){const n=yield t.annotate(new _.default(e.text()));return n.setLanguageISO(j[t._language]),e.mergeTokensFromDocument(n),e})()}_semgrex(e,t){var n=this;return x(function*(){return yield n._service.getSemgrexData(e,t,n._getAnnotatorsKeys(),n._getAnnotatrosOptions())})()}_getAnnotatorsKeys(){return this._properties.getProperty("annotators","").split(",").map(e=>e.trim())}_getAnnotators(){return this._getAnnotatorsKeys().map(e=>y[e])}_getAnnotatrosOptions(){const e=this._properties.getProperties(),t=Object.keys(y);return Object.keys(e).filter(e=>0===t.indexOf(e)).reduce((e,t,n)=>r({},e,{[n]:t}),{})}}},{"./connector/connector-server":8,"./service":13,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/ner":20,"./simple/annotator/parse":21,"./simple/annotator/pos":24,"./simple/annotator/regexner":27,"./simple/annotator/relation":28,"./simple/annotator/ssplit":29,"./simple/annotator/tokenize":30,"./simple/document":33,"./simple/expression":36,"lodash.difference":2}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tfetch(encodeURI(e.uri),r({},e,{withCredentials:!0})).then(e=>e.json()))},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t`${e} = ${this._props[e]}`).join("\n")}}},{}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;tthis.addAnnotator(e))}removeAnnotator(e){delete this._annotators[e.toString()]}hasAnnotator(e){return!!this._annotators[e.toString()]}hasAnyAnnotator(e){return e.some(e=>!!~Object.keys(this._annotators).indexOf(e.toString()))}}},{}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.pipeline())).concat([this.toString()]))}pipelineOptions(){return(0,s.default)(this.dependencies().map(e=>e.pipelineOptions()).concat(Object.keys(this.options()).map(e=>({[`${this}.${e}`]:this.option(e)}))),(e,t)=>r({},e,t),{})}}},{"lodash.flatten":3,"lodash.reduce":5,"lodash.uniq":6}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.isRepresentativeMention())}nonRepresentatives(){return this._mentions.filter(e=>!e.isRepresentativeMention())}document(e=null){return e&&(this._document=e),this._document}fromDocument(e){return this._mentions.forEach(t=>{const n=e.sentence(t.sentNum()-1),r=n.token(t.startIndex()-1);t.sentence(n),t.token(r)}),this}fromJSON(e){return this._mentions=e.map(e=>a.default.fromJSON(e)),this}toJSON(){return[...this._mentions]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./coref-mention":32}],32:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(". ")}sentences(){if(!this.hasAnnotator(o.default))throw new Error("Asked for sentences on Document, but there are unmet annotator dependencies.");return this._sentences}sentence(e){return this.sentences()[e]}corefs(){if(!this.hasAnnotator(i.default))throw new Error("Asked for corefs on Document, but there are unmet annotator dependencies.");return this._corefs}coref(e){return this.corefs()[e]}setLanguageISO(e){super.setLanguageISO(e),this._sentences.forEach(t=>t.setLanguageISO(e))}fromJSON(e){return e.sentences&&(this.addAnnotator(o.default),this._sentences=e.sentences.map(e=>a.default.fromJSON(e,!0))),e.corefs&&(this.addAnnotator(i.default),this._corefs=Object.keys(e.corefs).filter(e=>"length"!==e).map(t=>s.default.fromJSON(e.corefs[t]).fromDocument(this))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator/coref":16,"./annotator/ssplit":29,"./coref-chain":31,"./sentence":38}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tthis.group(e)))}group(e){return this._data[`$${e}`]}labels(){return Object.keys(this._data).filter(e=>/^\$/.test(e)).map(e=>e.substr(1))}fromJSON(e){return this._data=e,this}toJSON(){return r({},this._data)}static fromJSON(e){return(new this).fromJSON(e)}}},{}],35:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("./expression-sentence-match"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e){this._matches=e}matches(){return this._matches}match(e){return this._matches[e]}mergeTokensFromSentence(e){return this.matches().forEach(t=>t.groups().forEach(t=>{t.token=(t=>e.tokens().find(e=>e.index()===t.begin+1&&e.toString()===t.text))(t)||t.token})),this}fromJSON(e){return this._matches=Object.keys(e).filter(e=>"length"!==e).map(t=>a.default.fromJSON(e[t])),this}toJSON(){return[...this._matches]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./expression-sentence-match":34}],36:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TregexAnnotator=n.SemgrexAnnotator=n.TokensRegexAnnotator=void 0;var r=s(e("./annotable")),o=s(e("./annotator")),a=s(e("./expression-sentence"));function s(e){return e&&e.__esModule?e:{default:e}}n.TokensRegexAnnotator=class extends o.default{};n.SemgrexAnnotator=class extends o.default{};n.TregexAnnotator=class extends o.default{};n.default=class extends r.default{constructor(e,t){super(e),this._pattern=t,this._sentences=[]}toString(){return this._text}pattern(){return this._pattern}sentences(){return this._sentences}sentence(e){return this.sentences()[e]}mergeTokensFromDocument(e){return e.sentences().forEach((e,t)=>this.sentence(t).mergeTokensFromSentence(e)),this}fromJSON(e){return e.sentences&&(this._sentences=e.sentences.map(e=>a.default.fromJSON(e))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator":15,"./expression-sentence":35}],37:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e,t,n=null){this._dep=e,this._dependentToken=t,this._governorToken=n}toString(){return this._dep}governor(){return this._governorToken}governorGloss(){return this._governorToken?this._governorToken.word():""}dependent(){return this._dependentToken}dependentGloss(){return this._dependentToken.word()?this._dependentToken.word():""}dep(){return this._dep}depInfo(){return a.default.getGovernorDepInfo(this._dep)}toJSON(){return{dep:this._dep,governor:this._governorToken?this._governorToken.index():0,governorGloss:this._governorToken?this._governorToken.word():"ROOT",dependent:this._dependentToken.index(),dependentGloss:this._dependentToken.word()}}static fromJSON(){throw Error("Not implemented")}}},{"../service":13}],38:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(" ")}index(){return this._index}parse(){return this._parse}words(){if(!this.hasAnnotator(s.default))throw new Error("Asked for words on Sentence, but there are unmet annotator dependencies.");return this._tokens.map(e=>e.word())}word(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a word on Sentence, but there are unmet annotator dependencies.");if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].word()}[Symbol.iterator](){return this._tokens.values()}posTags(){return this._tokens.map(e=>e.pos())}posTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].pos()}lemmas(){return this._tokens.map(e=>e.lemma())}lemma(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].lemma()}nerTags(){return this._tokens.map(e=>e.ner())}nerTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].ner()}governors(){if(!this.hasAnnotator(u.default))throw new Error("Asked for governors on Sentence, but there are unmet annotator dependencies.");return this._governors}governor(e){if(!this.hasAnnotator(u.default))throw new Error("Asked for a governor on Sentence, but there are unmet annotator dependencies.");return this._governors[e]}incommingDependencyLabel(e){}natlogPolarities(){}natlogPolarity(e){}openie(){}openieTriples(e){}tokens(){if(!this.hasAnnotator(s.default))throw new Error("Asked for tokens on Sentence, but there are unmet annotator dependencies.");return this._tokens}token(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a token on Sentence, but there are unmet annotator dependencies.");return this._tokens[e]}algorithms(){}setLanguageISO(e){super.setLanguageISO(e),this._tokens.forEach(t=>t.setLanguageISO(e))}toJSON(){let e={index:this._index,tokens:this._tokens.map(e=>e.toJSON()),basicDependencies:this._governors.map(e=>e.toJSON()),enhancedDependencies:this._enhancedDependencies,enhancedPlusPlusDependencies:this._enhancedPlusPlusDependencies};return this._parse&&(e=r({},e,{parse:this._parse})),e}fromJSON(e,t=!1){const n=t?e:(0,o.default)(e.sentences);return this._index=e.index,n.tokens&&(this.addAnnotator(s.default),this._tokens=n.tokens.map(e=>p.default.fromJSON(e))),n.parse&&(this.addAnnotator(i.default),this._parse=n.parse),n.basicDependencies&&(this.addAnnotator(u.default),this._governors=n.basicDependencies.map(e=>new l.default(e.dep,this._tokens[e.dependent-1],this._tokens[e.governor-1])),this._basicDependencies=n.basicDependencies,this._enhancedDependencies=n.enhancedDependencies,this._enhancedPlusPlusDependencies=n.enhancedPlusPlusDependencies),this}static fromJSON(e,t=!1){return(new this).fromJSON(e,t)}}},{"./annotable":14,"./annotator/depparse":17,"./annotator/parse":21,"./annotator/tokenize":30,"./governor":37,"./token":39,"lodash.head":4}],39:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=a(e("../service")),o=a(e("./annotable"));function a(e){return e&&e.__esModule?e:{default:e}}n.default=class extends o.default{constructor(e){super(e)}toString(){return this._text}index(){return this._index}word(){return this._text}originalText(){return this._originalText}characterOffsetBegin(){return this._characterOffsetBegin}characterOffsetEnd(){return this._characterOffsetEnd}before(){return this._before}after(){return this._after}lemma(){return this._lemma}pos(){return this._pos}posInfo(){return r.default.getTokenPosInfo(this._pos,this.getLanguageISO())}ner(){return this._ner}speaker(){return this._speaker}toJSON(){return{index:this._index,word:this._text,originalText:this._originalText,characterOffsetBegin:this._characterOffsetBegin,characterOffsetEnd:this._characterOffsetEnd,before:this._before,after:this._after,pos:this._pos,lemma:this._lemma,ner:this._ner,speaker:this._speaker}}static fromJSON(e){const t=new this;return t._index=e.index,t._text=e.word,t._originalText=e.originalText,t._characterOffsetBegin=e.characterOffsetBegin,t._characterOffsetEnd=e.characterOffsetEnd,t._before=e.before,t._after=e.after,t._pos=e.pos,t._lemma=e.lemma,t._ner=e.ner,t._speaker=e.speaker,t}}},{"../service":13,"./annotable":14}],40:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Node=void 0;var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};class s{constructor(e="",t="",n=[],r=null){this._pos=e,this._word=t,this._children=n,this._parent=r}pos(){return this._pos}posInfo(){return this._children.length?a.default.getSentenceParseInfo(this._pos,this.getLanguageISO()):a.default.getTokenPosInfo(this._pos,this.getLanguageISO())}token(e=null){return e&&(this._token=e),this._token}word(){return this._word}setLanguageISO(e){this._language=e}getLanguageISO(){return this._language}children(){return this._children}appendChild(e){this._children.push(e)}parent(e=null){return e&&(this._parent=e),this._parent}toJSON(){return{pos:this._pos,posInfo:this.posInfo(),word:this._word,token:this._token,children:this._children}}}n.Node=s;class i{constructor(e){this.rootNode=e}dump(){return JSON.stringify(this.rootNode,(e,t)=>t instanceof s?t.children().length?{pos:t.pos(),info:t.info(),children:t.children()}:{pos:t.pos(),info:t.info(),word:t.word(),token:t.token()}:t,2)}visitDeepFirst(e,t=this.rootNode){t.children().forEach(t=>{this.visitDeepFirst(e,t),e(t)}),e(t)}visitDeepFirstRight(e,t=this.rootNode){t.children().reverse().forEach(t=>{this.visitDeepFirstRight(e,t),e(t)}),e(t)}visitLeaves(e,t=this.rootNode){t.children().forEach(t=>{t.children().length?this.visitLeaves(e,t):e(t)}),t.children().length||e(t)}static fromSentence(e,t=!1){const n=e.parse();if(!n)throw new Error("Unable to create Tree from Sentence, did you run ParserAnnotator first?");const r=i.fromString(n,t);let o=0;r.visitLeaves(t=>t.token(e.token(o++)));const a=e.getLanguageISO();return a&&r.visitDeepFirst(e=>e.setLanguageISO(a)),r}static fromString(e,t=!1){return new i(this._transformTree(this._buildTree(e),t))}static _buildTree(e){let t={children:[]};const n=[t],r=e.length;for(let o=0;o-1?(e.pos=t.substr(0,n),e.word=t.substr(n+1)):e.pos=t}static _transformTree(e,t){if(t){const t=new s(e.pos,e.word);return e.children.forEach(e=>{const n=this._transformTree(e);n.parent(t),t.appendChild(n)}),t}return new s(e.pos,e.word,e.children.map(e=>this._transformTree(e)))}}n.default=i},{"../service":13}]},{},[9])(9)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CoreNLP=e()}}(function(){return function(){return function e(t,n,r){function o(s,i){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){return o(t[s][1][e]||e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s-1}function f(e,t,n){for(var r=-1,o=e?e.length:0;++r=n&&(i=m,u=!1,t=new R(t));e:for(;++s-1},D.prototype.set=function(e,t){var n=this.__data__,r=J(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},C.prototype.clear=function(){this.__data__={hash:new E,map:new(M||D),string:new E}},C.prototype.delete=function(e){return z(this,e).delete(e)},C.prototype.get=function(e){return z(this,e).get(e)},C.prototype.has=function(e){return z(this,e).has(e)},C.prototype.set=function(e,t){return z(this,e).set(e,t),this},R.prototype.add=R.prototype.push=function(e){return this.__data__.set(e,r),this},R.prototype.has=function(e){return this.__data__.has(e)};var B,W,U=(B=function(e,t){return K(e)?$(e,function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=q),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):h(a,u):o||(a[a.length]=u)}return a}(t,1,K,!0)):[]},W=T(void 0===W?B.length-1:W,0),function(){for(var e=arguments,t=-1,n=T(e.length-W,0),r=Array(n);++t-1&&e%1==0&&e<=o}(e.length)&&!Q(e)}function K(e){return function(e){return!!e&&"object"==typeof e}(e)&&H(e)}function Q(e){var t=X(e)?P.call(e):"";return t==s||t==i}function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=U}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(e){var n=9007199254740991,r="[object Arguments]",o="[object Function]",a="[object GeneratorFunction]",s="object"==typeof e&&e&&e.Object===Object&&e,i="object"==typeof self&&self&&self.Object===Object&&self,u=s||i||Function("return this")();function l(e,t){for(var n=-1,r=t.length,o=e.length;++n-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?d.call(e):"";return t==o||t==a}(e)}(e)}(e)&&c.call(e,"callee")&&(!h.call(e,"callee")||d.call(e)==r)}(e)||!!(g&&e&&e[g])}var _=Array.isArray;t.exports=function(e){return e&&e.length?function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=m),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):l(a,u):o||(a[a.length]=u)}return a}(e,1):[]}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){t.exports=function(e){return e&&e.length?e[0]:void 0}},{}],5:[function(e,t,n){(function(e){var r=200,o="Expected a function",a="__lodash_hash_undefined__",s=1,i=2,u=1/0,l=9007199254740991,p="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Function]",m="[object GeneratorFunction]",_="[object Map]",v="[object Number]",b="[object Object]",y="[object RegExp]",x="[object Set]",j="[object String]",w="[object Symbol]",O="[object ArrayBuffer]",P="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,A=/^\./,N=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,V=/\\(\\)?/g,T=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,I={};I["[object Float32Array]"]=I["[object Float64Array]"]=I["[object Int8Array]"]=I["[object Int16Array]"]=I["[object Int32Array]"]=I["[object Uint8Array]"]=I["[object Uint8ClampedArray]"]=I["[object Uint16Array]"]=I["[object Uint32Array]"]=!0,I[p]=I[c]=I[O]=I[d]=I[P]=I[f]=I[h]=I[g]=I[_]=I[v]=I[b]=I[y]=I[x]=I[j]=I["[object WeakMap]"]=!1;var E="object"==typeof e&&e&&e.Object===Object&&e,D="object"==typeof self&&self&&self.Object===Object&&self,C=E||D||Function("return this")(),R="object"==typeof n&&n&&!n.nodeType&&n,J=R&&"object"==typeof t&&t&&!t.nodeType&&t,$=J&&J.exports===R&&E.process,L=function(){try{return $&&$.binding("util")}catch(e){}}(),z=L&&L.isTypedArray;function F(e,t,n,r){var o=-1,a=e?e.length:0;for(r&&a&&(n=e[++o]);++o-1},ke.prototype.set=function(e,t){var n=this.__data__,r=Te(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new Pe,map:new(de||ke),string:new Pe}},Se.prototype.delete=function(e){return Be(this,e).delete(e)},Se.prototype.get=function(e){return Be(this,e).get(e)},Se.prototype.has=function(e){return Be(this,e).has(e)},Se.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,a),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.clear=function(){this.__data__=new ke},Ne.prototype.delete=function(e){return this.__data__.delete(e)},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ke){var o=n.__data__;if(!de||o.lengthl))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var d=-1,f=!0,h=o&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e-1&&e%1==0&&e<=l}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function lt(e){return"symbol"==typeof e||ut(e)&&oe.call(e)==w}var pt=z?function(e){return function(t){return e(t)}}(z):function(e){return ut(e)&&st(e.length)&&!!I[oe.call(e)]};function ct(e){return ot(e)?Ve(e):ze(e)}function dt(e){return e}t.exports=function(e,t,n){var r=rt(e)?F:B,o=arguments.length<3;return r(e,Le(t),n,o,Ee)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,n){(function(e){var n=200,r="__lodash_hash_undefined__",o="[object Function]",a="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,i="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,l=i||u||Function("return this")();function p(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var o=e.length,a=n+(r?1:-1);for(;r?a--:++a-1}function c(e,t,n){for(var r=-1,o=e?e.length:0;++r-1},V.prototype.set=function(e,t){var n=this.__data__,r=I(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new N,map:new(k||V),string:new N}},T.prototype.delete=function(e){return C(this,e).delete(e)},T.prototype.get=function(e){return C(this,e).get(e)},T.prototype.has=function(e){return C(this,e).has(e)},T.prototype.set=function(e,t){return C(this,e).set(e,t),this},M.prototype.add=M.prototype.push=function(e){return this.__data__.set(e,r),this},M.prototype.has=function(e){return this.__data__.has(e)};var D=S&&1/h(new S([,-0]))[1]==1/0?function(e){return new S(e)}:function(){};function C(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function R(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return E(n)?n:void 0}function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return e&&e.length?function(e,t,r){var o=-1,a=p,s=e.length,i=!0,u=[],l=u;if(r)i=!1,a=c;else if(s>=n){var d=t?null:D(e);if(d)return h(d);i=!1,a=f,l=new M}else l=t?[]:u;e:for(;++othis._exec(`java ${n.concat([`-file ${e.path}`]).join(" ")}`).then(e=>{const t=(e.stdout||e.stderr).match(/writing to (.*\.json)/)[1];return this._loadJSONFile(t)}))}}},{"child-process-promise":1,"load-json-file":1,"tmp-file":1}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;t0===e.indexOf(`${a}.`)).map(e=>`${e.replace(`${a}.`,"")}=${encodeURI(n[e])}`).join("&")}`),this._makeRequest(i,u,t)}_makeRequest(e,t,n){const r={method:"POST",uri:`${e}?${t}`,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:n,json:!0};return this._username&&Object.assign(r,{auth:{user:this._username,pass:this._password}}),this._rp(r)}}},{"request-promise-native":11}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectorServer=n.ConnectorCli=n.Service=n.Pipeline=n.Properties=void 0;var r=S(e("./simple/document")),o=S(e("./simple/sentence")),a=S(e("./simple/token")),s=S(e("./simple/expression")),i=S(e("./simple/annotable")),u=S(e("./simple/annotator")),l=S(e("./simple/annotator/tokenize")),p=S(e("./simple/annotator/natlog")),c=S(e("./simple/annotator/openie")),d=S(e("./simple/annotator/ssplit")),f=S(e("./simple/annotator/pos")),h=S(e("./simple/annotator/lemma")),g=S(e("./simple/annotator/ner")),m=S(e("./simple/annotator/parse")),_=S(e("./simple/annotator/depparse")),v=S(e("./simple/annotator/relation")),b=S(e("./simple/annotator/regexner")),y=S(e("./simple/annotator/coref")),x=S(e("./util/tree")),j=S(e("./properties")),w=S(e("./pipeline")),O=S(e("./service")),P=S(e("./connector/connector-cli")),k=S(e("./connector/connector-server"));function S(e){return e&&e.__esModule?e:{default:e}}n.Properties=j.default,n.Pipeline=w.default,n.Service=O.default,n.ConnectorCli=P.default,n.ConnectorServer=k.default;n.default={simple:{Annotable:i.default,Annotator:u.default,Document:r.default,Sentence:o.default,Token:a.default,Expression:s.default,annotator:{TokenizerAnnotator:l.default,WordsToSentenceAnnotator:d.default,POSTaggerAnnotator:f.default,MorphaAnnotator:h.default,NERClassifierCombiner:g.default,ParserAnnotator:m.default,DependencyParseAnnotator:_.default,RelationExtractorAnnotator:v.default,RegexNERAnnotator:b.default,CorefAnnotator:y.default,NaturalLogicAnnotator:p.default,OpenIEAnnotator:c.default}},util:{Tree:x.default}}},{"./connector/connector-cli":7,"./connector/connector-server":8,"./pipeline":10,"./properties":12,"./service":13,"./simple/annotable":14,"./simple/annotator":15,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"./simple/sentence":40,"./simple/token":41,"./util/tree":42}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t(new e).toString()),this._getAnnotatorsKeys()).length>0)throw new Error(`Assert: ${e} requires ${t.join()} within the annotators list.`)}annotateTokensRegex(e,t=!1){var n=this;return j(function*(){return n.assert("TokensRegex",[i.default,p.default]),e.fromJSON(yield n._service.getTokensRegexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TokensRegexAnnotator),t?n._annotateExpression(e):e})()}annotateSemgrex(e,t=!1){var n=this;return j(function*(){return n.assert("Semgrex",[i.default,p.default,g.default]),e.fromJSON(yield n._service.getSemgrexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.SemgrexAnnotator),t?n._annotateExpression(e):e})()}annotateTregex(e,t=!1){var n=this;return j(function*(){return n.assert("Tregex",[i.default,p.default,h.default]),e.fromJSON(yield n._service.getTregexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TregexAnnotator),t?n._annotateExpression(e):e})()}_annotateExpression(e){var t=this;return j(function*(){const n=yield t.annotate(new b.default(e.text()));return n.setLanguageISO(O[t._language]),e.mergeTokensFromDocument(n),e})()}_semgrex(e,t){var n=this;return j(function*(){return yield n._service.getSemgrexData(e,t,n._getAnnotatorsKeys(),n._getAnnotatorsOptions())})()}_getAnnotatorsKeys(){return this._properties.getProperty("annotators","").split(",").map(e=>e.trim())}_getAnnotators(){return this._getAnnotatorsKeys().map(e=>w[e])}_getAnnotatorsOptions(){const e=this._properties.getProperties(),t=Object.keys(w);return Object.keys(e).filter(e=>t.includes(e.split(".")[0])).reduce((t,n)=>r({},t,{[n]:e[n]}),{})}}},{"./connector/connector-server":8,"./service":13,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"lodash.difference":2}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tfetch(encodeURI(e.uri),r({},e,{withCredentials:!0})).then(e=>e.json()))},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t`${e} = ${this._props[e]}`).join("\n")}}},{}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;tthis.addAnnotator(e))}removeAnnotator(e){delete this._annotators[e.toString()]}hasAnnotator(e){return!!this._annotators[e.toString()]}hasAnyAnnotator(e){return e.some(e=>!!~Object.keys(this._annotators).indexOf(e.toString()))}}},{}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.pipeline())).concat([this.toString()]))}pipelineOptions(){return(0,s.default)(this.dependencies().map(e=>e.pipelineOptions()).concat(Object.keys(this.options()).map(e=>({[`${this}.${e}`]:this.option(e)}))),(e,t)=>r({},e,t),{})}}},{"lodash.flatten":3,"lodash.reduce":5,"lodash.uniq":6}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.isRepresentativeMention())}nonRepresentatives(){return this._mentions.filter(e=>!e.isRepresentativeMention())}document(e=null){return e&&(this._document=e),this._document}fromDocument(e){return this._mentions.forEach(t=>{const n=e.sentence(t.sentNum()-1),r=n.token(t.startIndex()-1);t.sentence(n),t.token(r)}),this}fromJSON(e){return this._mentions=e.map(e=>a.default.fromJSON(e)),this}toJSON(){return[...this._mentions]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./coref-mention":34}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(". ")}sentences(){if(!this.hasAnnotator(o.default))throw new Error("Asked for sentences on Document, but there are unmet annotator dependencies.");return this._sentences}sentence(e){return this.sentences()[e]}corefs(){if(!this.hasAnnotator(i.default))throw new Error("Asked for corefs on Document, but there are unmet annotator dependencies.");return this._corefs}coref(e){return this.corefs()[e]}setLanguageISO(e){super.setLanguageISO(e),this._sentences.forEach(t=>t.setLanguageISO(e))}fromJSON(e){return e.sentences&&(this.addAnnotator(o.default),this._sentences=e.sentences.map(e=>a.default.fromJSON(e,!0))),e.corefs&&(this.addAnnotator(i.default),this._corefs=Object.keys(e.corefs).filter(e=>"length"!==e).map(t=>s.default.fromJSON(e.corefs[t]).fromDocument(this))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator/coref":16,"./annotator/ssplit":31,"./coref-chain":33,"./sentence":40}],36:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tthis.group(e)))}group(e){return this._data[`$${e}`]}labels(){return Object.keys(this._data).filter(e=>/^\$/.test(e)).map(e=>e.substr(1))}fromJSON(e){return this._data=e,this}toJSON(){return r({},this._data)}static fromJSON(e){return(new this).fromJSON(e)}}},{}],37:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("./expression-sentence-match"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e){this._matches=e}matches(){return this._matches}match(e){return this._matches[e]}mergeTokensFromSentence(e){return this.matches().forEach(t=>t.groups().forEach(t=>{t.token=(t=>e.tokens().find(e=>e.index()===t.begin+1&&e.toString()===t.text))(t)||t.token})),this}fromJSON(e){return this._matches=Object.keys(e).filter(e=>"length"!==e).map(t=>a.default.fromJSON(e[t])),this}toJSON(){return[...this._matches]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./expression-sentence-match":36}],38:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TregexAnnotator=n.SemgrexAnnotator=n.TokensRegexAnnotator=void 0;var r=s(e("./annotable")),o=s(e("./annotator")),a=s(e("./expression-sentence"));function s(e){return e&&e.__esModule?e:{default:e}}n.TokensRegexAnnotator=class extends o.default{};n.SemgrexAnnotator=class extends o.default{};n.TregexAnnotator=class extends o.default{};n.default=class extends r.default{constructor(e,t){super(e),this._pattern=t,this._sentences=[]}toString(){return this._text}pattern(){return this._pattern}sentences(){return this._sentences}sentence(e){return this.sentences()[e]}mergeTokensFromDocument(e){return e.sentences().forEach((e,t)=>this.sentence(t).mergeTokensFromSentence(e)),this}fromJSON(e){return e.sentences&&(this._sentences=e.sentences.map(e=>a.default.fromJSON(e))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator":15,"./expression-sentence":37}],39:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e,t,n=null){this._dep=e,this._dependentToken=t,this._governorToken=n}toString(){return this._dep}governor(){return this._governorToken}governorGloss(){return this._governorToken?this._governorToken.word():""}dependent(){return this._dependentToken}dependentGloss(){return this._dependentToken.word()?this._dependentToken.word():""}dep(){return this._dep}depInfo(){return a.default.getGovernorDepInfo(this._dep)}toJSON(){return{dep:this._dep,governor:this._governorToken?this._governorToken.index():0,governorGloss:this._governorToken?this._governorToken.word():"ROOT",dependent:this._dependentToken.index(),dependentGloss:this._dependentToken.word()}}static fromJSON(){throw Error("Not implemented")}}},{"../service":13}],40:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(" ")}index(){return this._index}parse(){return this._parse}words(){if(!this.hasAnnotator(s.default))throw new Error("Asked for words on Sentence, but there are unmet annotator dependencies.");return this._tokens.map(e=>e.word())}word(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a word on Sentence, but there are unmet annotator dependencies.");if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].word()}[Symbol.iterator](){return this._tokens.values()}posTags(){return this._tokens.map(e=>e.pos())}posTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].pos()}lemmas(){return this._tokens.map(e=>e.lemma())}lemma(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].lemma()}nerTags(){return this._tokens.map(e=>e.ner())}nerTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].ner()}governors(){if(!this.hasAnnotator(p.default))throw new Error("Asked for governors on Sentence, but there are unmet annotator dependencies.");return this._governors}governor(e){if(!this.hasAnnotator(p.default))throw new Error("Asked for a governor on Sentence, but there are unmet annotator dependencies.");return this._governors[e]}incommingDependencyLabel(e){}natlogPolarities(){if(!this.hasAnnotator(u.default))throw new Error("Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.");return this._natLogPolarities}natlogPolarity(e){if(!this.hasAnnotator(u.default))throw new Error("Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.");return this._natLogPolarities[e]}openie(){if(!this.hasAnnotator(l.default))throw new Error("Asked for a OpenIE-Annotation on Sentence, but there are unmet annotator dependencies.");return this._openie}openieTriples(e){}tokens(){if(!this.hasAnnotator(s.default))throw new Error("Asked for tokens on Sentence, but there are unmet annotator dependencies.");return this._tokens}token(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a token on Sentence, but there are unmet annotator dependencies.");return this._tokens[e]}algorithms(){}setLanguageISO(e){super.setLanguageISO(e),this._tokens.forEach(t=>t.setLanguageISO(e))}toJSON(){let e={index:this._index,tokens:this._tokens.map(e=>e.toJSON()),basicDependencies:this._governors.map(e=>e.toJSON()),enhancedDependencies:this._enhancedDependencies,enhancedPlusPlusDependencies:this._enhancedPlusPlusDependencies};return this._parse&&(e=r({},e,{parse:this._parse})),e}fromJSON(e,t=!1){const n=t?e:(0,o.default)(e.sentences);return this._index=e.index,n.tokens&&(this.addAnnotator(s.default),this._tokens=n.tokens.map(e=>c.default.fromJSON(e))),n.parse&&(this.addAnnotator(i.default),this._parse=n.parse),n.openie&&(this.addAnnotator(l.default),this._openie=n.openie),n.basicDependencies&&(this.addAnnotator(p.default),this._governors=n.basicDependencies.map(e=>new d.default(e.dep,this._tokens[e.dependent-1],this._tokens[e.governor-1])),this._basicDependencies=n.basicDependencies,this._enhancedDependencies=n.enhancedDependencies,this._enhancedPlusPlusDependencies=n.enhancedPlusPlusDependencies),this}static fromJSON(e,t=!1){return(new this).fromJSON(e,t)}}},{"./annotable":14,"./annotator/depparse":17,"./annotator/natlog":20,"./annotator/openie":22,"./annotator/parse":23,"./annotator/tokenize":32,"./governor":39,"./token":41,"lodash.head":4}],41:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=a(e("../service")),o=a(e("./annotable"));function a(e){return e&&e.__esModule?e:{default:e}}n.default=class extends o.default{constructor(e){super(e)}toString(){return this._text}index(){return this._index}word(){return this._text}originalText(){return this._originalText}characterOffsetBegin(){return this._characterOffsetBegin}characterOffsetEnd(){return this._characterOffsetEnd}before(){return this._before}after(){return this._after}lemma(){return this._lemma}pos(){return this._pos}posInfo(){return r.default.getTokenPosInfo(this._pos,this.getLanguageISO())}ner(){return this._ner}speaker(){return this._speaker}toJSON(){return{index:this._index,word:this._text,originalText:this._originalText,characterOffsetBegin:this._characterOffsetBegin,characterOffsetEnd:this._characterOffsetEnd,before:this._before,after:this._after,pos:this._pos,lemma:this._lemma,ner:this._ner,speaker:this._speaker}}static fromJSON(e){const t=new this;return t._index=e.index,t._text=e.word,t._originalText=e.originalText,t._characterOffsetBegin=e.characterOffsetBegin,t._characterOffsetEnd=e.characterOffsetEnd,t._before=e.before,t._after=e.after,t._pos=e.pos,t._lemma=e.lemma,t._ner=e.ner,t._speaker=e.speaker,t}}},{"../service":13,"./annotable":14}],42:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Node=void 0;var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};class s{constructor(e="",t="",n=[],r=null){this._pos=e,this._word=t,this._children=n,this._parent=r}pos(){return this._pos}posInfo(){return this._children.length?a.default.getSentenceParseInfo(this._pos,this.getLanguageISO()):a.default.getTokenPosInfo(this._pos,this.getLanguageISO())}token(e=null){return e&&(this._token=e),this._token}word(){return this._word}setLanguageISO(e){this._language=e}getLanguageISO(){return this._language}children(){return this._children}appendChild(e){this._children.push(e)}parent(e=null){return e&&(this._parent=e),this._parent}toJSON(){return{pos:this._pos,posInfo:this.posInfo(),word:this._word,token:this._token,children:this._children}}}n.Node=s;class i{constructor(e){this.rootNode=e}dump(){return JSON.stringify(this.rootNode,(e,t)=>t instanceof s?t.children().length?{pos:t.pos(),info:t.info(),children:t.children()}:{pos:t.pos(),info:t.info(),word:t.word(),token:t.token()}:t,2)}visitDeepFirst(e,t=this.rootNode){t.children().forEach(t=>{this.visitDeepFirst(e,t),e(t)}),e(t)}visitDeepFirstRight(e,t=this.rootNode){t.children().reverse().forEach(t=>{this.visitDeepFirstRight(e,t),e(t)}),e(t)}visitLeaves(e,t=this.rootNode){t.children().forEach(t=>{t.children().length?this.visitLeaves(e,t):e(t)}),t.children().length||e(t)}static fromSentence(e,t=!1){const n=e.parse();if(!n)throw new Error("Unable to create Tree from Sentence, did you run ParserAnnotator first?");const r=i.fromString(n,t);let o=0;r.visitLeaves(t=>t.token(e.token(o++)));const a=e.getLanguageISO();return a&&r.visitDeepFirst(e=>e.setLanguageISO(a)),r}static fromString(e,t=!1){return new i(this._transformTree(this._buildTree(e),t))}static _buildTree(e){let t={children:[]};const n=[t],r=e.length;for(let o=0;o-1?(e.pos=t.substr(0,n),e.word=t.substr(n+1)):e.pos=t}static _transformTree(e,t){if(t){const n=new s(e.pos,e.word);return e.children.forEach(e=>{const r=this._transformTree(e,t);r.parent(n),n.appendChild(r)}),n}return new s(e.pos,e.word,e.children.map(e=>this._transformTree(e)))}}n.default=i},{"../service":13}]},{},[9])(9)}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 0f0d0b8..cb7c10c 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,8 @@ import Expression from './simple/expression'; import Annotable from './simple/annotable'; import Annotator from './simple/annotator'; import TokenizerAnnotator from './simple/annotator/tokenize'; +import NaturalLogicAnnotator from './simple/annotator/natlog'; +import OpenIEAnnotator from './simple/annotator/openie'; import WordsToSentenceAnnotator from './simple/annotator/ssplit'; import POSTaggerAnnotator from './simple/annotator/pos'; import MorphaAnnotator from './simple/annotator/lemma'; @@ -58,6 +60,8 @@ export default { RelationExtractorAnnotator, RegexNERAnnotator, CorefAnnotator, + NaturalLogicAnnotator, + OpenIEAnnotator, }, }, /** diff --git a/src/index.spec.js b/src/index.spec.js index 7a4f6fc..75421df 100644 --- a/src/index.spec.js +++ b/src/index.spec.js @@ -10,6 +10,8 @@ import Token from './simple/token'; import Annotable from './simple/annotable'; import Annotator from './simple/annotator'; import TokenizerAnnotator from './simple/annotator/tokenize'; +import OpenIEAnnotator from './simple/annotator/openie'; +import NaturalLogicAnnotator from './simple/annotator/natlog'; import WordsToSentenceAnnotator from './simple/annotator/ssplit'; import POSTaggerAnnotator from './simple/annotator/pos'; import MorphaAnnotator from './simple/annotator/lemma'; @@ -73,6 +75,8 @@ describe('CoreNLP Library entry point', () => { RelationExtractorAnnotator, RegexNERAnnotator, CorefAnnotator, + NaturalLogicAnnotator, + OpenIEAnnotator, }); }); }); diff --git a/src/pipeline.js b/src/pipeline.js index 1d31123..82f606f 100644 --- a/src/pipeline.js +++ b/src/pipeline.js @@ -2,6 +2,8 @@ import difference from 'lodash.difference'; import Service from './service'; import ConnectorServer from './connector/connector-server'; import tokenize from './simple/annotator/tokenize'; +import natlog from './simple/annotator/natlog'; +import openie from './simple/annotator/openie'; import ssplit from './simple/annotator/ssplit'; import pos from './simple/annotator/pos'; import lemma from './simple/annotator/lemma'; @@ -30,6 +32,8 @@ const ANNOTATORS_BY_KEY = { relation, regexner, coref, + natlog, + openie, }; const LANGUAGE_TO_ISO2 = { diff --git a/src/simple/annotator/natlog.js b/src/simple/annotator/natlog.js new file mode 100644 index 0000000..9f19360 --- /dev/null +++ b/src/simple/annotator/natlog.js @@ -0,0 +1,39 @@ +import Annotator from '../annotator'; +import TokenizerAnnotator from './tokenize'; +import WordsToSentenceAnnotator from './ssplit'; +import POSTaggerAnnotator from './pos'; +import MorphaAnnotator from './lemma'; +import DependencyParseAnnotator from './depparse'; + +/** + * @class + * @classdesc Class representing an Natural Logic Annotator. + * @extends Annotator + * @memberof CoreNLP/simple/annotator + * @requires tokenize, ssplit, pos, lemma, depparse (Can also use parse) + * @see {@link https://stanfordnlp.github.io/CoreNLP/natlog.html|NaturalLogicAnnotator} + */ +class NaturalLogicAnnotator extends Annotator { + /** + * Create an Annotator + * @param {Object} [options] a key-value map of options, without the annotator prefix + */ + constructor(options = {}) { + super( + 'natlog', + { + // dopolarity: True by default. If set to false, the annotator will only annotate quantifiers and quantifier scopes, and not annotate the polarity of each token + ...options, + }, + [ + new TokenizerAnnotator(), + new WordsToSentenceAnnotator(), + new POSTaggerAnnotator(), + new MorphaAnnotator(), + new DependencyParseAnnotator(), + ], + ); + } +} + +export default NaturalLogicAnnotator; \ No newline at end of file diff --git a/src/simple/annotator/natlog.spec.js b/src/simple/annotator/natlog.spec.js new file mode 100644 index 0000000..9aea214 --- /dev/null +++ b/src/simple/annotator/natlog.spec.js @@ -0,0 +1,20 @@ +import NaturalLogicAnnotator from './natlog'; + +describe('Annotator', () => { + let annotator; + + describe('NaturalLogicAnnotator', () => { + beforeEach(() => { + annotator = new NaturalLogicAnnotator(); + }); + + it('should have a proper pipeline', () => { + expect(annotator.pipeline()).to.deep.equal(['tokenize', 'ssplit', 'pos', 'lemma', 'depparse', 'natlog']); + }); + + it('should have the proper default options', () => { + expect(annotator.options()).to.deep.equal({ + }); + }); + }); +}); \ No newline at end of file diff --git a/src/simple/annotator/openie.js b/src/simple/annotator/openie.js new file mode 100644 index 0000000..47cb9dd --- /dev/null +++ b/src/simple/annotator/openie.js @@ -0,0 +1,45 @@ +import Annotator from '../annotator'; +import NaturalLogicAnnotator from './natlog'; + +//TODO: Requirements are missing here https://stanfordnlp.github.io/CoreNLP/annotators.html, verify. + +/** + * @class + * @classdesc Class representing an OpenIE Annotator. + * @extends Annotator + * @memberof CoreNLP/simple/annotator + * @requires natlog + * @see {@link https://stanfordnlp.github.io/CoreNLP/openie.html|OpenIEAnnotator} + */ +class OpenIEAnnotator extends Annotator { + /** + * Create an Annotator + * @param {Object} [options] a key-value map of options, without the annotator prefix + */ + constructor(options = {}) { + super( + 'openie', + { + // format (Enum) default One of {reverb, ollie, default, qa_srl}. Changes the output format of the program. Default will produce tab-separated columns for confidence, the subject, relation, and the object of a relation. ReVerb will output a TSV in the ReVerb format. Ollie will output relations in the default format returned by Ollie. + // filelist (filepath) null A path to a file, which contains files to annotate. Each file should be on its own line. If this option is set, only these files are annotated and the files passed via bare arguments are ignored. + // threads (integer) number of cores The number of threads to run on. By default, this is the number of cores in the system. + // max_entailments_per_clause (integer) 1000 The maximum number of entailments to produce for each clause extracted in the sentence. The larger this value is, the slower the system will run, but the more relations it can potentially extract. Setting this below 100 is not recommended; setting it above 1000 is likewise not recommended. + // resolve_coref (boolean) false If true, run coreference (and consequently NER as a dependency of coreference) and replace pronominal mentions with their canonical mention in the text. + // ignore_affinity (boolean) false Whether to ignore the affinity model for prepositional attachments. + // affinity_probability_cap (double) 1 /3 The affinity value above which confidence of the extraction is taken as 1.0. + // triple.strict (boolean) true If true, extract triples only if they consume the entire fragment. This is useful for ensuring that only logically warranted triples are extracted, but puts more burden on the entailment system to find minimal phrases (see -max_entailments_per_clause). + // triple.all_nominals (boolean) false If true, extract nominal relations always and not only when a named entity tag warrants it. This greatly overproduces such triples, but can be useful in certain situations. + // splitter.model (filepath) You can override the default location of the clause splitting model with this option. + // splitter.nomodel (boolean) false Run without a clause splitting model – that is, split on every clause. + // splitter.disable (boolean) false Don’t split clauses at all, and only extract relations centered around the root verb. + // affinity_models (filepath) + ...options, + }, + [ + new NaturalLogicAnnotator(), + ], + ); + } +} + +export default OpenIEAnnotator; \ No newline at end of file diff --git a/src/simple/annotator/openie.spec.js b/src/simple/annotator/openie.spec.js new file mode 100644 index 0000000..1cb09d1 --- /dev/null +++ b/src/simple/annotator/openie.spec.js @@ -0,0 +1,20 @@ +import OpenIEAnnotator from './openie'; + +describe('Annotator', () => { + let annotator; + + describe('OpenIEAnnotator', () => { + beforeEach(() => { + annotator = new OpenIEAnnotator(); + }); + + it('should have a proper pipeline', () => { + expect(annotator.pipeline()).to.deep.equal(["tokenize", "ssplit", "pos", "lemma", "depparse", 'natlog', 'openie']); + }); + + it('should have the proper default options', () => { + expect(annotator.options()).to.deep.equal({ + }); + }); + }); +}); \ No newline at end of file diff --git a/src/simple/sentence.js b/src/simple/sentence.js index a1115e1..a6c3c23 100644 --- a/src/simple/sentence.js +++ b/src/simple/sentence.js @@ -2,6 +2,8 @@ import head from 'lodash.head'; import Annotable from './annotable'; import TokenizerAnnotator from './annotator/tokenize'; import ParserAnnotator from './annotator/parse'; +import NaturalLogicAnnotator from './annotator/natlog'; +import OpenIEAnnotator from './annotator/openie'; import DependencyParseAnnotator from './annotator/depparse'; import Token from './token'; import Governor from './governor'; @@ -30,6 +32,8 @@ class Sentence extends Annotable { super(text); this._tokens = []; this._governors = []; + this._openie = []; + this._natLogPolarities = []; } /** @@ -185,19 +189,29 @@ class Sentence extends Annotable { incommingDependencyLabel(index) { } - // TODO - // eslint-disable-next-line class-methods-use-this natlogPolarities() { + if (!this.hasAnnotator(NaturalLogicAnnotator)) { + throw new Error('Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + } + return this._natLogPolarities; } // TODO // eslint-disable-next-line class-methods-use-this, no-unused-vars natlogPolarity(index) { + if (!this.hasAnnotator(NaturalLogicAnnotator)) { + throw new Error('Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + } + return this._natLogPolarities[index]; } // TODO // eslint-disable-next-line class-methods-use-this openie() { + if (!this.hasAnnotator(OpenIEAnnotator)) { + throw new Error('Asked for a OpenIE-Annotation on Sentence, but there are unmet annotator dependencies.'); + } + return this._openie; } // TODO @@ -287,6 +301,10 @@ class Sentence extends Annotable { this.addAnnotator(ParserAnnotator); this._parse = sentence.parse; } + if (sentence.openie) { + this.addAnnotator(OpenIEAnnotator); + this._openie = sentence.openie; + } if (sentence.basicDependencies) { this.addAnnotator(DependencyParseAnnotator); this._governors = sentence.basicDependencies.map(gov => From 6be60d6c32c6746b137c7312d8cfb1b37ecd85ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Mon, 15 Apr 2019 10:02:05 +0200 Subject: [PATCH 3/6] add coref-option --- examples/browser/corenlp.min.js | 2 +- src/simple/annotator/openie.js | 28 +++++++++++++++++----------- src/simple/sentence.js | 18 ++++++++++-------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/examples/browser/corenlp.min.js b/examples/browser/corenlp.min.js index 7d377a1..f9f3baa 100644 --- a/examples/browser/corenlp.min.js +++ b/examples/browser/corenlp.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CoreNLP=e()}}(function(){return function(){return function e(t,n,r){function o(s,i){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){return o(t[s][1][e]||e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s-1}function f(e,t,n){for(var r=-1,o=e?e.length:0;++r=n&&(i=m,u=!1,t=new R(t));e:for(;++s-1},D.prototype.set=function(e,t){var n=this.__data__,r=J(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},C.prototype.clear=function(){this.__data__={hash:new E,map:new(M||D),string:new E}},C.prototype.delete=function(e){return z(this,e).delete(e)},C.prototype.get=function(e){return z(this,e).get(e)},C.prototype.has=function(e){return z(this,e).has(e)},C.prototype.set=function(e,t){return z(this,e).set(e,t),this},R.prototype.add=R.prototype.push=function(e){return this.__data__.set(e,r),this},R.prototype.has=function(e){return this.__data__.has(e)};var B,W,U=(B=function(e,t){return K(e)?$(e,function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=q),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):h(a,u):o||(a[a.length]=u)}return a}(t,1,K,!0)):[]},W=T(void 0===W?B.length-1:W,0),function(){for(var e=arguments,t=-1,n=T(e.length-W,0),r=Array(n);++t-1&&e%1==0&&e<=o}(e.length)&&!Q(e)}function K(e){return function(e){return!!e&&"object"==typeof e}(e)&&H(e)}function Q(e){var t=X(e)?P.call(e):"";return t==s||t==i}function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=U}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(e){var n=9007199254740991,r="[object Arguments]",o="[object Function]",a="[object GeneratorFunction]",s="object"==typeof e&&e&&e.Object===Object&&e,i="object"==typeof self&&self&&self.Object===Object&&self,u=s||i||Function("return this")();function l(e,t){for(var n=-1,r=t.length,o=e.length;++n-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?d.call(e):"";return t==o||t==a}(e)}(e)}(e)&&c.call(e,"callee")&&(!h.call(e,"callee")||d.call(e)==r)}(e)||!!(g&&e&&e[g])}var _=Array.isArray;t.exports=function(e){return e&&e.length?function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=m),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):l(a,u):o||(a[a.length]=u)}return a}(e,1):[]}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){t.exports=function(e){return e&&e.length?e[0]:void 0}},{}],5:[function(e,t,n){(function(e){var r=200,o="Expected a function",a="__lodash_hash_undefined__",s=1,i=2,u=1/0,l=9007199254740991,p="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Function]",m="[object GeneratorFunction]",_="[object Map]",v="[object Number]",b="[object Object]",y="[object RegExp]",x="[object Set]",j="[object String]",w="[object Symbol]",O="[object ArrayBuffer]",P="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,A=/^\./,N=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,V=/\\(\\)?/g,T=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,I={};I["[object Float32Array]"]=I["[object Float64Array]"]=I["[object Int8Array]"]=I["[object Int16Array]"]=I["[object Int32Array]"]=I["[object Uint8Array]"]=I["[object Uint8ClampedArray]"]=I["[object Uint16Array]"]=I["[object Uint32Array]"]=!0,I[p]=I[c]=I[O]=I[d]=I[P]=I[f]=I[h]=I[g]=I[_]=I[v]=I[b]=I[y]=I[x]=I[j]=I["[object WeakMap]"]=!1;var E="object"==typeof e&&e&&e.Object===Object&&e,D="object"==typeof self&&self&&self.Object===Object&&self,C=E||D||Function("return this")(),R="object"==typeof n&&n&&!n.nodeType&&n,J=R&&"object"==typeof t&&t&&!t.nodeType&&t,$=J&&J.exports===R&&E.process,L=function(){try{return $&&$.binding("util")}catch(e){}}(),z=L&&L.isTypedArray;function F(e,t,n,r){var o=-1,a=e?e.length:0;for(r&&a&&(n=e[++o]);++o-1},ke.prototype.set=function(e,t){var n=this.__data__,r=Te(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new Pe,map:new(de||ke),string:new Pe}},Se.prototype.delete=function(e){return Be(this,e).delete(e)},Se.prototype.get=function(e){return Be(this,e).get(e)},Se.prototype.has=function(e){return Be(this,e).has(e)},Se.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,a),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.clear=function(){this.__data__=new ke},Ne.prototype.delete=function(e){return this.__data__.delete(e)},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ke){var o=n.__data__;if(!de||o.lengthl))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var d=-1,f=!0,h=o&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e-1&&e%1==0&&e<=l}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function lt(e){return"symbol"==typeof e||ut(e)&&oe.call(e)==w}var pt=z?function(e){return function(t){return e(t)}}(z):function(e){return ut(e)&&st(e.length)&&!!I[oe.call(e)]};function ct(e){return ot(e)?Ve(e):ze(e)}function dt(e){return e}t.exports=function(e,t,n){var r=rt(e)?F:B,o=arguments.length<3;return r(e,Le(t),n,o,Ee)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,n){(function(e){var n=200,r="__lodash_hash_undefined__",o="[object Function]",a="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,i="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,l=i||u||Function("return this")();function p(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var o=e.length,a=n+(r?1:-1);for(;r?a--:++a-1}function c(e,t,n){for(var r=-1,o=e?e.length:0;++r-1},V.prototype.set=function(e,t){var n=this.__data__,r=I(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new N,map:new(k||V),string:new N}},T.prototype.delete=function(e){return C(this,e).delete(e)},T.prototype.get=function(e){return C(this,e).get(e)},T.prototype.has=function(e){return C(this,e).has(e)},T.prototype.set=function(e,t){return C(this,e).set(e,t),this},M.prototype.add=M.prototype.push=function(e){return this.__data__.set(e,r),this},M.prototype.has=function(e){return this.__data__.has(e)};var D=S&&1/h(new S([,-0]))[1]==1/0?function(e){return new S(e)}:function(){};function C(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function R(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return E(n)?n:void 0}function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return e&&e.length?function(e,t,r){var o=-1,a=p,s=e.length,i=!0,u=[],l=u;if(r)i=!1,a=c;else if(s>=n){var d=t?null:D(e);if(d)return h(d);i=!1,a=f,l=new M}else l=t?[]:u;e:for(;++othis._exec(`java ${n.concat([`-file ${e.path}`]).join(" ")}`).then(e=>{const t=(e.stdout||e.stderr).match(/writing to (.*\.json)/)[1];return this._loadJSONFile(t)}))}}},{"child-process-promise":1,"load-json-file":1,"tmp-file":1}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;t0===e.indexOf(`${a}.`)).map(e=>`${e.replace(`${a}.`,"")}=${encodeURI(n[e])}`).join("&")}`),this._makeRequest(i,u,t)}_makeRequest(e,t,n){const r={method:"POST",uri:`${e}?${t}`,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:n,json:!0};return this._username&&Object.assign(r,{auth:{user:this._username,pass:this._password}}),this._rp(r)}}},{"request-promise-native":11}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectorServer=n.ConnectorCli=n.Service=n.Pipeline=n.Properties=void 0;var r=S(e("./simple/document")),o=S(e("./simple/sentence")),a=S(e("./simple/token")),s=S(e("./simple/expression")),i=S(e("./simple/annotable")),u=S(e("./simple/annotator")),l=S(e("./simple/annotator/tokenize")),p=S(e("./simple/annotator/natlog")),c=S(e("./simple/annotator/openie")),d=S(e("./simple/annotator/ssplit")),f=S(e("./simple/annotator/pos")),h=S(e("./simple/annotator/lemma")),g=S(e("./simple/annotator/ner")),m=S(e("./simple/annotator/parse")),_=S(e("./simple/annotator/depparse")),v=S(e("./simple/annotator/relation")),b=S(e("./simple/annotator/regexner")),y=S(e("./simple/annotator/coref")),x=S(e("./util/tree")),j=S(e("./properties")),w=S(e("./pipeline")),O=S(e("./service")),P=S(e("./connector/connector-cli")),k=S(e("./connector/connector-server"));function S(e){return e&&e.__esModule?e:{default:e}}n.Properties=j.default,n.Pipeline=w.default,n.Service=O.default,n.ConnectorCli=P.default,n.ConnectorServer=k.default;n.default={simple:{Annotable:i.default,Annotator:u.default,Document:r.default,Sentence:o.default,Token:a.default,Expression:s.default,annotator:{TokenizerAnnotator:l.default,WordsToSentenceAnnotator:d.default,POSTaggerAnnotator:f.default,MorphaAnnotator:h.default,NERClassifierCombiner:g.default,ParserAnnotator:m.default,DependencyParseAnnotator:_.default,RelationExtractorAnnotator:v.default,RegexNERAnnotator:b.default,CorefAnnotator:y.default,NaturalLogicAnnotator:p.default,OpenIEAnnotator:c.default}},util:{Tree:x.default}}},{"./connector/connector-cli":7,"./connector/connector-server":8,"./pipeline":10,"./properties":12,"./service":13,"./simple/annotable":14,"./simple/annotator":15,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"./simple/sentence":40,"./simple/token":41,"./util/tree":42}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t(new e).toString()),this._getAnnotatorsKeys()).length>0)throw new Error(`Assert: ${e} requires ${t.join()} within the annotators list.`)}annotateTokensRegex(e,t=!1){var n=this;return j(function*(){return n.assert("TokensRegex",[i.default,p.default]),e.fromJSON(yield n._service.getTokensRegexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TokensRegexAnnotator),t?n._annotateExpression(e):e})()}annotateSemgrex(e,t=!1){var n=this;return j(function*(){return n.assert("Semgrex",[i.default,p.default,g.default]),e.fromJSON(yield n._service.getSemgrexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.SemgrexAnnotator),t?n._annotateExpression(e):e})()}annotateTregex(e,t=!1){var n=this;return j(function*(){return n.assert("Tregex",[i.default,p.default,h.default]),e.fromJSON(yield n._service.getTregexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TregexAnnotator),t?n._annotateExpression(e):e})()}_annotateExpression(e){var t=this;return j(function*(){const n=yield t.annotate(new b.default(e.text()));return n.setLanguageISO(O[t._language]),e.mergeTokensFromDocument(n),e})()}_semgrex(e,t){var n=this;return j(function*(){return yield n._service.getSemgrexData(e,t,n._getAnnotatorsKeys(),n._getAnnotatorsOptions())})()}_getAnnotatorsKeys(){return this._properties.getProperty("annotators","").split(",").map(e=>e.trim())}_getAnnotators(){return this._getAnnotatorsKeys().map(e=>w[e])}_getAnnotatorsOptions(){const e=this._properties.getProperties(),t=Object.keys(w);return Object.keys(e).filter(e=>t.includes(e.split(".")[0])).reduce((t,n)=>r({},t,{[n]:e[n]}),{})}}},{"./connector/connector-server":8,"./service":13,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"lodash.difference":2}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tfetch(encodeURI(e.uri),r({},e,{withCredentials:!0})).then(e=>e.json()))},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t`${e} = ${this._props[e]}`).join("\n")}}},{}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;tthis.addAnnotator(e))}removeAnnotator(e){delete this._annotators[e.toString()]}hasAnnotator(e){return!!this._annotators[e.toString()]}hasAnyAnnotator(e){return e.some(e=>!!~Object.keys(this._annotators).indexOf(e.toString()))}}},{}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.pipeline())).concat([this.toString()]))}pipelineOptions(){return(0,s.default)(this.dependencies().map(e=>e.pipelineOptions()).concat(Object.keys(this.options()).map(e=>({[`${this}.${e}`]:this.option(e)}))),(e,t)=>r({},e,t),{})}}},{"lodash.flatten":3,"lodash.reduce":5,"lodash.uniq":6}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.isRepresentativeMention())}nonRepresentatives(){return this._mentions.filter(e=>!e.isRepresentativeMention())}document(e=null){return e&&(this._document=e),this._document}fromDocument(e){return this._mentions.forEach(t=>{const n=e.sentence(t.sentNum()-1),r=n.token(t.startIndex()-1);t.sentence(n),t.token(r)}),this}fromJSON(e){return this._mentions=e.map(e=>a.default.fromJSON(e)),this}toJSON(){return[...this._mentions]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./coref-mention":34}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(". ")}sentences(){if(!this.hasAnnotator(o.default))throw new Error("Asked for sentences on Document, but there are unmet annotator dependencies.");return this._sentences}sentence(e){return this.sentences()[e]}corefs(){if(!this.hasAnnotator(i.default))throw new Error("Asked for corefs on Document, but there are unmet annotator dependencies.");return this._corefs}coref(e){return this.corefs()[e]}setLanguageISO(e){super.setLanguageISO(e),this._sentences.forEach(t=>t.setLanguageISO(e))}fromJSON(e){return e.sentences&&(this.addAnnotator(o.default),this._sentences=e.sentences.map(e=>a.default.fromJSON(e,!0))),e.corefs&&(this.addAnnotator(i.default),this._corefs=Object.keys(e.corefs).filter(e=>"length"!==e).map(t=>s.default.fromJSON(e.corefs[t]).fromDocument(this))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator/coref":16,"./annotator/ssplit":31,"./coref-chain":33,"./sentence":40}],36:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tthis.group(e)))}group(e){return this._data[`$${e}`]}labels(){return Object.keys(this._data).filter(e=>/^\$/.test(e)).map(e=>e.substr(1))}fromJSON(e){return this._data=e,this}toJSON(){return r({},this._data)}static fromJSON(e){return(new this).fromJSON(e)}}},{}],37:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("./expression-sentence-match"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e){this._matches=e}matches(){return this._matches}match(e){return this._matches[e]}mergeTokensFromSentence(e){return this.matches().forEach(t=>t.groups().forEach(t=>{t.token=(t=>e.tokens().find(e=>e.index()===t.begin+1&&e.toString()===t.text))(t)||t.token})),this}fromJSON(e){return this._matches=Object.keys(e).filter(e=>"length"!==e).map(t=>a.default.fromJSON(e[t])),this}toJSON(){return[...this._matches]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./expression-sentence-match":36}],38:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TregexAnnotator=n.SemgrexAnnotator=n.TokensRegexAnnotator=void 0;var r=s(e("./annotable")),o=s(e("./annotator")),a=s(e("./expression-sentence"));function s(e){return e&&e.__esModule?e:{default:e}}n.TokensRegexAnnotator=class extends o.default{};n.SemgrexAnnotator=class extends o.default{};n.TregexAnnotator=class extends o.default{};n.default=class extends r.default{constructor(e,t){super(e),this._pattern=t,this._sentences=[]}toString(){return this._text}pattern(){return this._pattern}sentences(){return this._sentences}sentence(e){return this.sentences()[e]}mergeTokensFromDocument(e){return e.sentences().forEach((e,t)=>this.sentence(t).mergeTokensFromSentence(e)),this}fromJSON(e){return e.sentences&&(this._sentences=e.sentences.map(e=>a.default.fromJSON(e))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator":15,"./expression-sentence":37}],39:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e,t,n=null){this._dep=e,this._dependentToken=t,this._governorToken=n}toString(){return this._dep}governor(){return this._governorToken}governorGloss(){return this._governorToken?this._governorToken.word():""}dependent(){return this._dependentToken}dependentGloss(){return this._dependentToken.word()?this._dependentToken.word():""}dep(){return this._dep}depInfo(){return a.default.getGovernorDepInfo(this._dep)}toJSON(){return{dep:this._dep,governor:this._governorToken?this._governorToken.index():0,governorGloss:this._governorToken?this._governorToken.word():"ROOT",dependent:this._dependentToken.index(),dependentGloss:this._dependentToken.word()}}static fromJSON(){throw Error("Not implemented")}}},{"../service":13}],40:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(" ")}index(){return this._index}parse(){return this._parse}words(){if(!this.hasAnnotator(s.default))throw new Error("Asked for words on Sentence, but there are unmet annotator dependencies.");return this._tokens.map(e=>e.word())}word(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a word on Sentence, but there are unmet annotator dependencies.");if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].word()}[Symbol.iterator](){return this._tokens.values()}posTags(){return this._tokens.map(e=>e.pos())}posTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].pos()}lemmas(){return this._tokens.map(e=>e.lemma())}lemma(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].lemma()}nerTags(){return this._tokens.map(e=>e.ner())}nerTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].ner()}governors(){if(!this.hasAnnotator(p.default))throw new Error("Asked for governors on Sentence, but there are unmet annotator dependencies.");return this._governors}governor(e){if(!this.hasAnnotator(p.default))throw new Error("Asked for a governor on Sentence, but there are unmet annotator dependencies.");return this._governors[e]}incommingDependencyLabel(e){}natlogPolarities(){if(!this.hasAnnotator(u.default))throw new Error("Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.");return this._natLogPolarities}natlogPolarity(e){if(!this.hasAnnotator(u.default))throw new Error("Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.");return this._natLogPolarities[e]}openie(){if(!this.hasAnnotator(l.default))throw new Error("Asked for a OpenIE-Annotation on Sentence, but there are unmet annotator dependencies.");return this._openie}openieTriples(e){}tokens(){if(!this.hasAnnotator(s.default))throw new Error("Asked for tokens on Sentence, but there are unmet annotator dependencies.");return this._tokens}token(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a token on Sentence, but there are unmet annotator dependencies.");return this._tokens[e]}algorithms(){}setLanguageISO(e){super.setLanguageISO(e),this._tokens.forEach(t=>t.setLanguageISO(e))}toJSON(){let e={index:this._index,tokens:this._tokens.map(e=>e.toJSON()),basicDependencies:this._governors.map(e=>e.toJSON()),enhancedDependencies:this._enhancedDependencies,enhancedPlusPlusDependencies:this._enhancedPlusPlusDependencies};return this._parse&&(e=r({},e,{parse:this._parse})),e}fromJSON(e,t=!1){const n=t?e:(0,o.default)(e.sentences);return this._index=e.index,n.tokens&&(this.addAnnotator(s.default),this._tokens=n.tokens.map(e=>c.default.fromJSON(e))),n.parse&&(this.addAnnotator(i.default),this._parse=n.parse),n.openie&&(this.addAnnotator(l.default),this._openie=n.openie),n.basicDependencies&&(this.addAnnotator(p.default),this._governors=n.basicDependencies.map(e=>new d.default(e.dep,this._tokens[e.dependent-1],this._tokens[e.governor-1])),this._basicDependencies=n.basicDependencies,this._enhancedDependencies=n.enhancedDependencies,this._enhancedPlusPlusDependencies=n.enhancedPlusPlusDependencies),this}static fromJSON(e,t=!1){return(new this).fromJSON(e,t)}}},{"./annotable":14,"./annotator/depparse":17,"./annotator/natlog":20,"./annotator/openie":22,"./annotator/parse":23,"./annotator/tokenize":32,"./governor":39,"./token":41,"lodash.head":4}],41:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=a(e("../service")),o=a(e("./annotable"));function a(e){return e&&e.__esModule?e:{default:e}}n.default=class extends o.default{constructor(e){super(e)}toString(){return this._text}index(){return this._index}word(){return this._text}originalText(){return this._originalText}characterOffsetBegin(){return this._characterOffsetBegin}characterOffsetEnd(){return this._characterOffsetEnd}before(){return this._before}after(){return this._after}lemma(){return this._lemma}pos(){return this._pos}posInfo(){return r.default.getTokenPosInfo(this._pos,this.getLanguageISO())}ner(){return this._ner}speaker(){return this._speaker}toJSON(){return{index:this._index,word:this._text,originalText:this._originalText,characterOffsetBegin:this._characterOffsetBegin,characterOffsetEnd:this._characterOffsetEnd,before:this._before,after:this._after,pos:this._pos,lemma:this._lemma,ner:this._ner,speaker:this._speaker}}static fromJSON(e){const t=new this;return t._index=e.index,t._text=e.word,t._originalText=e.originalText,t._characterOffsetBegin=e.characterOffsetBegin,t._characterOffsetEnd=e.characterOffsetEnd,t._before=e.before,t._after=e.after,t._pos=e.pos,t._lemma=e.lemma,t._ner=e.ner,t._speaker=e.speaker,t}}},{"../service":13,"./annotable":14}],42:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Node=void 0;var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};class s{constructor(e="",t="",n=[],r=null){this._pos=e,this._word=t,this._children=n,this._parent=r}pos(){return this._pos}posInfo(){return this._children.length?a.default.getSentenceParseInfo(this._pos,this.getLanguageISO()):a.default.getTokenPosInfo(this._pos,this.getLanguageISO())}token(e=null){return e&&(this._token=e),this._token}word(){return this._word}setLanguageISO(e){this._language=e}getLanguageISO(){return this._language}children(){return this._children}appendChild(e){this._children.push(e)}parent(e=null){return e&&(this._parent=e),this._parent}toJSON(){return{pos:this._pos,posInfo:this.posInfo(),word:this._word,token:this._token,children:this._children}}}n.Node=s;class i{constructor(e){this.rootNode=e}dump(){return JSON.stringify(this.rootNode,(e,t)=>t instanceof s?t.children().length?{pos:t.pos(),info:t.info(),children:t.children()}:{pos:t.pos(),info:t.info(),word:t.word(),token:t.token()}:t,2)}visitDeepFirst(e,t=this.rootNode){t.children().forEach(t=>{this.visitDeepFirst(e,t),e(t)}),e(t)}visitDeepFirstRight(e,t=this.rootNode){t.children().reverse().forEach(t=>{this.visitDeepFirstRight(e,t),e(t)}),e(t)}visitLeaves(e,t=this.rootNode){t.children().forEach(t=>{t.children().length?this.visitLeaves(e,t):e(t)}),t.children().length||e(t)}static fromSentence(e,t=!1){const n=e.parse();if(!n)throw new Error("Unable to create Tree from Sentence, did you run ParserAnnotator first?");const r=i.fromString(n,t);let o=0;r.visitLeaves(t=>t.token(e.token(o++)));const a=e.getLanguageISO();return a&&r.visitDeepFirst(e=>e.setLanguageISO(a)),r}static fromString(e,t=!1){return new i(this._transformTree(this._buildTree(e),t))}static _buildTree(e){let t={children:[]};const n=[t],r=e.length;for(let o=0;o-1?(e.pos=t.substr(0,n),e.word=t.substr(n+1)):e.pos=t}static _transformTree(e,t){if(t){const n=new s(e.pos,e.word);return e.children.forEach(e=>{const r=this._transformTree(e,t);r.parent(n),n.appendChild(r)}),n}return new s(e.pos,e.word,e.children.map(e=>this._transformTree(e)))}}n.default=i},{"../service":13}]},{},[9])(9)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CoreNLP=e()}}(function(){return function(){return function e(t,n,r){function o(s,i){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){return o(t[s][1][e]||e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s-1}function f(e,t,n){for(var r=-1,o=e?e.length:0;++r=n&&(i=m,u=!1,t=new R(t));e:for(;++s-1},D.prototype.set=function(e,t){var n=this.__data__,r=J(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},C.prototype.clear=function(){this.__data__={hash:new E,map:new(M||D),string:new E}},C.prototype.delete=function(e){return L(this,e).delete(e)},C.prototype.get=function(e){return L(this,e).get(e)},C.prototype.has=function(e){return L(this,e).has(e)},C.prototype.set=function(e,t){return L(this,e).set(e,t),this},R.prototype.add=R.prototype.push=function(e){return this.__data__.set(e,r),this},R.prototype.has=function(e){return this.__data__.has(e)};var B,W,U=(B=function(e,t){return K(e)?$(e,function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=q),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):h(a,u):o||(a[a.length]=u)}return a}(t,1,K,!0)):[]},W=T(void 0===W?B.length-1:W,0),function(){for(var e=arguments,t=-1,n=T(e.length-W,0),r=Array(n);++t-1&&e%1==0&&e<=o}(e.length)&&!Q(e)}function K(e){return function(e){return!!e&&"object"==typeof e}(e)&&H(e)}function Q(e){var t=X(e)?P.call(e):"";return t==s||t==i}function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=U}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(e){var n=9007199254740991,r="[object Arguments]",o="[object Function]",a="[object GeneratorFunction]",s="object"==typeof e&&e&&e.Object===Object&&e,i="object"==typeof self&&self&&self.Object===Object&&self,u=s||i||Function("return this")();function l(e,t){for(var n=-1,r=t.length,o=e.length;++n-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?d.call(e):"";return t==o||t==a}(e)}(e)}(e)&&c.call(e,"callee")&&(!h.call(e,"callee")||d.call(e)==r)}(e)||!!(g&&e&&e[g])}var _=Array.isArray;t.exports=function(e){return e&&e.length?function e(t,n,r,o,a){var s=-1,i=t.length;for(r||(r=m),a||(a=[]);++s0&&r(u)?n>1?e(u,n-1,r,o,a):l(a,u):o||(a[a.length]=u)}return a}(e,1):[]}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){t.exports=function(e){return e&&e.length?e[0]:void 0}},{}],5:[function(e,t,n){(function(e){var r=200,o="Expected a function",a="__lodash_hash_undefined__",s=1,i=2,u=1/0,l=9007199254740991,p="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Function]",m="[object GeneratorFunction]",_="[object Map]",v="[object Number]",b="[object Object]",y="[object RegExp]",x="[object Set]",j="[object String]",w="[object Symbol]",O="[object ArrayBuffer]",P="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,A=/^\./,N=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,V=/\\(\\)?/g,T=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,I={};I["[object Float32Array]"]=I["[object Float64Array]"]=I["[object Int8Array]"]=I["[object Int16Array]"]=I["[object Int32Array]"]=I["[object Uint8Array]"]=I["[object Uint8ClampedArray]"]=I["[object Uint16Array]"]=I["[object Uint32Array]"]=!0,I[p]=I[c]=I[O]=I[d]=I[P]=I[f]=I[h]=I[g]=I[_]=I[v]=I[b]=I[y]=I[x]=I[j]=I["[object WeakMap]"]=!1;var E="object"==typeof e&&e&&e.Object===Object&&e,D="object"==typeof self&&self&&self.Object===Object&&self,C=E||D||Function("return this")(),R="object"==typeof n&&n&&!n.nodeType&&n,J=R&&"object"==typeof t&&t&&!t.nodeType&&t,$=J&&J.exports===R&&E.process,z=function(){try{return $&&$.binding("util")}catch(e){}}(),L=z&&z.isTypedArray;function F(e,t,n,r){var o=-1,a=e?e.length:0;for(r&&a&&(n=e[++o]);++o-1},ke.prototype.set=function(e,t){var n=this.__data__,r=Te(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new Pe,map:new(de||ke),string:new Pe}},Se.prototype.delete=function(e){return Be(this,e).delete(e)},Se.prototype.get=function(e){return Be(this,e).get(e)},Se.prototype.has=function(e){return Be(this,e).has(e)},Se.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,a),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.clear=function(){this.__data__=new ke},Ne.prototype.delete=function(e){return this.__data__.delete(e)},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ke){var o=n.__data__;if(!de||o.lengthl))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var d=-1,f=!0,h=o&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e-1&&e%1==0&&e<=l}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function lt(e){return"symbol"==typeof e||ut(e)&&oe.call(e)==w}var pt=L?function(e){return function(t){return e(t)}}(L):function(e){return ut(e)&&st(e.length)&&!!I[oe.call(e)]};function ct(e){return ot(e)?Ve(e):Le(e)}function dt(e){return e}t.exports=function(e,t,n){var r=rt(e)?F:B,o=arguments.length<3;return r(e,ze(t),n,o,Ee)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,n){(function(e){var n=200,r="__lodash_hash_undefined__",o="[object Function]",a="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,i="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,l=i||u||Function("return this")();function p(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var o=e.length,a=n+(r?1:-1);for(;r?a--:++a-1}function c(e,t,n){for(var r=-1,o=e?e.length:0;++r-1},V.prototype.set=function(e,t){var n=this.__data__,r=I(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},T.prototype.clear=function(){this.__data__={hash:new N,map:new(k||V),string:new N}},T.prototype.delete=function(e){return C(this,e).delete(e)},T.prototype.get=function(e){return C(this,e).get(e)},T.prototype.has=function(e){return C(this,e).has(e)},T.prototype.set=function(e,t){return C(this,e).set(e,t),this},M.prototype.add=M.prototype.push=function(e){return this.__data__.set(e,r),this},M.prototype.has=function(e){return this.__data__.has(e)};var D=S&&1/h(new S([,-0]))[1]==1/0?function(e){return new S(e)}:function(){};function C(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function R(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return E(n)?n:void 0}function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return e&&e.length?function(e,t,r){var o=-1,a=p,s=e.length,i=!0,u=[],l=u;if(r)i=!1,a=c;else if(s>=n){var d=t?null:D(e);if(d)return h(d);i=!1,a=f,l=new M}else l=t?[]:u;e:for(;++othis._exec(`java ${n.concat([`-file ${e.path}`]).join(" ")}`).then(e=>{const t=(e.stdout||e.stderr).match(/writing to (.*\.json)/)[1];return this._loadJSONFile(t)}))}}},{"child-process-promise":1,"load-json-file":1,"tmp-file":1}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;t0===e.indexOf(`${a}.`)).map(e=>`${e.replace(`${a}.`,"")}=${encodeURI(n[e])}`).join("&")}`),this._makeRequest(i,u,t)}_makeRequest(e,t,n){const r={method:"POST",uri:`${e}?${t}`,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:n,json:!0};return this._username&&Object.assign(r,{auth:{user:this._username,pass:this._password}}),this._rp(r)}}},{"request-promise-native":11}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectorServer=n.ConnectorCli=n.Service=n.Pipeline=n.Properties=void 0;var r=S(e("./simple/document")),o=S(e("./simple/sentence")),a=S(e("./simple/token")),s=S(e("./simple/expression")),i=S(e("./simple/annotable")),u=S(e("./simple/annotator")),l=S(e("./simple/annotator/tokenize")),p=S(e("./simple/annotator/natlog")),c=S(e("./simple/annotator/openie")),d=S(e("./simple/annotator/ssplit")),f=S(e("./simple/annotator/pos")),h=S(e("./simple/annotator/lemma")),g=S(e("./simple/annotator/ner")),m=S(e("./simple/annotator/parse")),_=S(e("./simple/annotator/depparse")),v=S(e("./simple/annotator/relation")),b=S(e("./simple/annotator/regexner")),y=S(e("./simple/annotator/coref")),x=S(e("./util/tree")),j=S(e("./properties")),w=S(e("./pipeline")),O=S(e("./service")),P=S(e("./connector/connector-cli")),k=S(e("./connector/connector-server"));function S(e){return e&&e.__esModule?e:{default:e}}n.Properties=j.default,n.Pipeline=w.default,n.Service=O.default,n.ConnectorCli=P.default,n.ConnectorServer=k.default;n.default={simple:{Annotable:i.default,Annotator:u.default,Document:r.default,Sentence:o.default,Token:a.default,Expression:s.default,annotator:{TokenizerAnnotator:l.default,WordsToSentenceAnnotator:d.default,POSTaggerAnnotator:f.default,MorphaAnnotator:h.default,NERClassifierCombiner:g.default,ParserAnnotator:m.default,DependencyParseAnnotator:_.default,RelationExtractorAnnotator:v.default,RegexNERAnnotator:b.default,CorefAnnotator:y.default,NaturalLogicAnnotator:p.default,OpenIEAnnotator:c.default}},util:{Tree:x.default}}},{"./connector/connector-cli":7,"./connector/connector-server":8,"./pipeline":10,"./properties":12,"./service":13,"./simple/annotable":14,"./simple/annotator":15,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"./simple/sentence":40,"./simple/token":41,"./util/tree":42}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t(new e).toString()),this._getAnnotatorsKeys()).length>0)throw new Error(`Assert: ${e} requires ${t.join()} within the annotators list.`)}annotateTokensRegex(e,t=!1){var n=this;return j(function*(){return n.assert("TokensRegex",[i.default,p.default]),e.fromJSON(yield n._service.getTokensRegexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TokensRegexAnnotator),t?n._annotateExpression(e):e})()}annotateSemgrex(e,t=!1){var n=this;return j(function*(){return n.assert("Semgrex",[i.default,p.default,g.default]),e.fromJSON(yield n._service.getSemgrexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.SemgrexAnnotator),t?n._annotateExpression(e):e})()}annotateTregex(e,t=!1){var n=this;return j(function*(){return n.assert("Tregex",[i.default,p.default,h.default]),e.fromJSON(yield n._service.getTregexData(e.text(),e.pattern(),n._getAnnotatorsKeys(),n._getAnnotatorsOptions())),e.setLanguageISO(O[n._language]),e.addAnnotator(y.TregexAnnotator),t?n._annotateExpression(e):e})()}_annotateExpression(e){var t=this;return j(function*(){const n=yield t.annotate(new b.default(e.text()));return n.setLanguageISO(O[t._language]),e.mergeTokensFromDocument(n),e})()}_semgrex(e,t){var n=this;return j(function*(){return yield n._service.getSemgrexData(e,t,n._getAnnotatorsKeys(),n._getAnnotatorsOptions())})()}_getAnnotatorsKeys(){return this._properties.getProperty("annotators","").split(",").map(e=>e.trim())}_getAnnotators(){return this._getAnnotatorsKeys().map(e=>w[e])}_getAnnotatorsOptions(){const e=this._properties.getProperties(),t=Object.keys(w);return Object.keys(e).filter(e=>t.includes(e.split(".")[0])).reduce((t,n)=>r({},t,{[n]:e[n]}),{})}}},{"./connector/connector-server":8,"./service":13,"./simple/annotator/coref":16,"./simple/annotator/depparse":17,"./simple/annotator/lemma":19,"./simple/annotator/natlog":20,"./simple/annotator/ner":21,"./simple/annotator/openie":22,"./simple/annotator/parse":23,"./simple/annotator/pos":26,"./simple/annotator/regexner":29,"./simple/annotator/relation":30,"./simple/annotator/ssplit":31,"./simple/annotator/tokenize":32,"./simple/document":35,"./simple/expression":38,"lodash.difference":2}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tfetch(encodeURI(e.uri),r({},e,{withCredentials:!0})).then(e=>e.json()))},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t`${e} = ${this._props[e]}`).join("\n")}}},{}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=Object.assign||function(e){for(var t=1;tthis.addAnnotator(e))}removeAnnotator(e){delete this._annotators[e.toString()]}hasAnnotator(e){return!!this._annotators[e.toString()]}hasAnyAnnotator(e){return e.some(e=>!!~Object.keys(this._annotators).indexOf(e.toString()))}}},{}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.pipeline())).concat([this.toString()]))}pipelineOptions(){return(0,s.default)(this.dependencies().map(e=>e.pipelineOptions()).concat(Object.keys(this.options()).map(e=>({[`${this}.${e}`]:this.option(e)}))),(e,t)=>r({},e,t),{})}}},{"lodash.flatten":3,"lodash.reduce":5,"lodash.uniq":6}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.isRepresentativeMention())}nonRepresentatives(){return this._mentions.filter(e=>!e.isRepresentativeMention())}document(e=null){return e&&(this._document=e),this._document}fromDocument(e){return this._mentions.forEach(t=>{const n=e.sentence(t.sentNum()-1),r=n.token(t.startIndex()-1);t.sentence(n),t.token(r)}),this}fromJSON(e){return this._mentions=e.map(e=>a.default.fromJSON(e)),this}toJSON(){return[...this._mentions]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./coref-mention":34}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(". ")}sentences(){if(!this.hasAnnotator(o.default))throw new Error("Asked for sentences on Document, but there are unmet annotator dependencies.");return this._sentences}sentence(e){return this.sentences()[e]}corefs(){if(!this.hasAnnotator(i.default))throw new Error("Asked for corefs on Document, but there are unmet annotator dependencies.");return this._corefs}coref(e){return this.corefs()[e]}setLanguageISO(e){super.setLanguageISO(e),this._sentences.forEach(t=>t.setLanguageISO(e))}fromJSON(e){return e.sentences&&(this.addAnnotator(o.default),this._sentences=e.sentences.map(e=>a.default.fromJSON(e,!0))),e.corefs&&(this.addAnnotator(i.default),this._corefs=Object.keys(e.corefs).filter(e=>"length"!==e).map(t=>s.default.fromJSON(e.corefs[t]).fromDocument(this))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator/coref":16,"./annotator/ssplit":31,"./coref-chain":33,"./sentence":40}],36:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;tthis.group(e)))}group(e){return this._data[`$${e}`]}labels(){return Object.keys(this._data).filter(e=>/^\$/.test(e)).map(e=>e.substr(1))}fromJSON(e){return this._data=e,this}toJSON(){return r({},this._data)}static fromJSON(e){return(new this).fromJSON(e)}}},{}],37:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("./expression-sentence-match"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e){this._matches=e}matches(){return this._matches}match(e){return this._matches[e]}mergeTokensFromSentence(e){return this.matches().forEach(t=>t.groups().forEach(t=>{t.token=(t=>e.tokens().find(e=>e.index()===t.begin+1&&e.toString()===t.text))(t)||t.token})),this}fromJSON(e){return this._matches=Object.keys(e).filter(e=>"length"!==e).map(t=>a.default.fromJSON(e[t])),this}toJSON(){return[...this._matches]}static fromJSON(e){return(new this).fromJSON(e)}}},{"./expression-sentence-match":36}],38:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TregexAnnotator=n.SemgrexAnnotator=n.TokensRegexAnnotator=void 0;var r=s(e("./annotable")),o=s(e("./annotator")),a=s(e("./expression-sentence"));function s(e){return e&&e.__esModule?e:{default:e}}n.TokensRegexAnnotator=class extends o.default{};n.SemgrexAnnotator=class extends o.default{};n.TregexAnnotator=class extends o.default{};n.default=class extends r.default{constructor(e,t){super(e),this._pattern=t,this._sentences=[]}toString(){return this._text}pattern(){return this._pattern}sentences(){return this._sentences}sentence(e){return this.sentences()[e]}mergeTokensFromDocument(e){return e.sentences().forEach((e,t)=>this.sentence(t).mergeTokensFromSentence(e)),this}fromJSON(e){return e.sentences&&(this._sentences=e.sentences.map(e=>a.default.fromJSON(e))),this}toJSON(){return{text:this._text,sentences:this._sentences}}static fromJSON(e){return(new this).fromJSON(e)}}},{"./annotable":14,"./annotator":15,"./expression-sentence":37}],39:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};n.default=class{constructor(e,t,n=null){this._dep=e,this._dependentToken=t,this._governorToken=n}toString(){return this._dep}governor(){return this._governorToken}governorGloss(){return this._governorToken?this._governorToken.word():""}dependent(){return this._dependentToken}dependentGloss(){return this._dependentToken.word()?this._dependentToken.word():""}dep(){return this._dep}depInfo(){return a.default.getGovernorDepInfo(this._dep)}toJSON(){return{dep:this._dep,governor:this._governorToken?this._governorToken.index():0,governorGloss:this._governorToken?this._governorToken.word():"ROOT",dependent:this._dependentToken.index(),dependentGloss:this._dependentToken.word()}}static fromJSON(){throw Error("Not implemented")}}},{"../service":13}],40:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;te.toString()).join(" ")}index(){return this._index}parse(){return this._parse}words(){if(!this.hasAnnotator(s.default))throw new Error("Asked for words on Sentence, but there are unmet annotator dependencies.");return this._tokens.map(e=>e.word())}word(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a word on Sentence, but there are unmet annotator dependencies.");if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].word()}[Symbol.iterator](){return this._tokens.values()}posTags(){return this._tokens.map(e=>e.pos())}posTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].pos()}lemmas(){return this._tokens.map(e=>e.lemma())}lemma(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].lemma()}nerTags(){return this._tokens.map(e=>e.ner())}nerTag(e){if(!this._tokens[e])throw new Error(`Sentence instance does not contain a token with index ${e}`);return this._tokens[e].ner()}governors(){if(!this.hasAnnotator(l.default))throw new Error("Asked for governors on Sentence, but there are unmet annotator dependencies.");return this._governors}governor(e){if(!this.hasAnnotator(l.default))throw new Error("Asked for a governor on Sentence, but there are unmet annotator dependencies.");return this._governors[e]}incommingDependencyLabel(e){}natlogPolarities(){}natlogPolarity(e){}openie(){if(!this.hasAnnotator(u.default))throw new Error("Asked for a OpenIE-Annotation on Sentence, but there are unmet annotator dependencies.");return this._openie}openieTriples(e){}tokens(){if(!this.hasAnnotator(s.default))throw new Error("Asked for tokens on Sentence, but there are unmet annotator dependencies.");return this._tokens}token(e){if(!this.hasAnnotator(s.default))throw new Error("Asked for a token on Sentence, but there are unmet annotator dependencies.");return this._tokens[e]}algorithms(){}setLanguageISO(e){super.setLanguageISO(e),this._tokens.forEach(t=>t.setLanguageISO(e))}toJSON(){let e={index:this._index,tokens:this._tokens.map(e=>e.toJSON()),basicDependencies:this._governors.map(e=>e.toJSON()),enhancedDependencies:this._enhancedDependencies,enhancedPlusPlusDependencies:this._enhancedPlusPlusDependencies};return this._parse&&(e=r({},e,{parse:this._parse})),e}fromJSON(e,t=!1){const n=t?e:(0,o.default)(e.sentences);return this._index=e.index,n.tokens&&(this.addAnnotator(s.default),this._tokens=n.tokens.map(e=>p.default.fromJSON(e))),n.parse&&(this.addAnnotator(i.default),this._parse=n.parse),n.openie&&(this.addAnnotator(u.default),this._openie=n.openie),n.basicDependencies&&(this.addAnnotator(l.default),this._governors=n.basicDependencies.map(e=>new c.default(e.dep,this._tokens[e.dependent-1],this._tokens[e.governor-1])),this._basicDependencies=n.basicDependencies,this._enhancedDependencies=n.enhancedDependencies,this._enhancedPlusPlusDependencies=n.enhancedPlusPlusDependencies),this}static fromJSON(e,t=!1){return(new this).fromJSON(e,t)}}},{"./annotable":14,"./annotator/depparse":17,"./annotator/natlog":20,"./annotator/openie":22,"./annotator/parse":23,"./annotator/tokenize":32,"./governor":39,"./token":41,"lodash.head":4}],41:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=a(e("../service")),o=a(e("./annotable"));function a(e){return e&&e.__esModule?e:{default:e}}n.default=class extends o.default{constructor(e){super(e)}toString(){return this._text}index(){return this._index}word(){return this._text}originalText(){return this._originalText}characterOffsetBegin(){return this._characterOffsetBegin}characterOffsetEnd(){return this._characterOffsetEnd}before(){return this._before}after(){return this._after}lemma(){return this._lemma}pos(){return this._pos}posInfo(){return r.default.getTokenPosInfo(this._pos,this.getLanguageISO())}ner(){return this._ner}speaker(){return this._speaker}toJSON(){return{index:this._index,word:this._text,originalText:this._originalText,characterOffsetBegin:this._characterOffsetBegin,characterOffsetEnd:this._characterOffsetEnd,before:this._before,after:this._after,pos:this._pos,lemma:this._lemma,ner:this._ner,speaker:this._speaker}}static fromJSON(e){const t=new this;return t._index=e.index,t._text=e.word,t._originalText=e.originalText,t._characterOffsetBegin=e.characterOffsetBegin,t._characterOffsetEnd=e.characterOffsetEnd,t._before=e.before,t._after=e.after,t._pos=e.pos,t._lemma=e.lemma,t._ner=e.ner,t._speaker=e.speaker,t}}},{"../service":13,"./annotable":14}],42:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Node=void 0;var r,o=e("../service"),a=(r=o)&&r.__esModule?r:{default:r};class s{constructor(e="",t="",n=[],r=null){this._pos=e,this._word=t,this._children=n,this._parent=r}pos(){return this._pos}posInfo(){return this._children.length?a.default.getSentenceParseInfo(this._pos,this.getLanguageISO()):a.default.getTokenPosInfo(this._pos,this.getLanguageISO())}token(e=null){return e&&(this._token=e),this._token}word(){return this._word}setLanguageISO(e){this._language=e}getLanguageISO(){return this._language}children(){return this._children}appendChild(e){this._children.push(e)}parent(e=null){return e&&(this._parent=e),this._parent}toJSON(){return{pos:this._pos,posInfo:this.posInfo(),word:this._word,token:this._token,children:this._children}}}n.Node=s;class i{constructor(e){this.rootNode=e}dump(){return JSON.stringify(this.rootNode,(e,t)=>t instanceof s?t.children().length?{pos:t.pos(),info:t.info(),children:t.children()}:{pos:t.pos(),info:t.info(),word:t.word(),token:t.token()}:t,2)}visitDeepFirst(e,t=this.rootNode){t.children().forEach(t=>{this.visitDeepFirst(e,t),e(t)}),e(t)}visitDeepFirstRight(e,t=this.rootNode){t.children().reverse().forEach(t=>{this.visitDeepFirstRight(e,t),e(t)}),e(t)}visitLeaves(e,t=this.rootNode){t.children().forEach(t=>{t.children().length?this.visitLeaves(e,t):e(t)}),t.children().length||e(t)}static fromSentence(e,t=!1){const n=e.parse();if(!n)throw new Error("Unable to create Tree from Sentence, did you run ParserAnnotator first?");const r=i.fromString(n,t);let o=0;r.visitLeaves(t=>t.token(e.token(o++)));const a=e.getLanguageISO();return a&&r.visitDeepFirst(e=>e.setLanguageISO(a)),r}static fromString(e,t=!1){return new i(this._transformTree(this._buildTree(e),t))}static _buildTree(e){let t={children:[]};const n=[t],r=e.length;for(let o=0;o-1?(e.pos=t.substr(0,n),e.word=t.substr(n+1)):e.pos=t}static _transformTree(e,t){if(t){const n=new s(e.pos,e.word);return e.children.forEach(e=>{const r=this._transformTree(e,t);r.parent(n),n.appendChild(r)}),n}return new s(e.pos,e.word,e.children.map(e=>this._transformTree(e)))}}n.default=i},{"../service":13}]},{},[9])(9)}); \ No newline at end of file diff --git a/src/simple/annotator/openie.js b/src/simple/annotator/openie.js index 47cb9dd..41f4581 100644 --- a/src/simple/annotator/openie.js +++ b/src/simple/annotator/openie.js @@ -1,5 +1,7 @@ -import Annotator from '../annotator'; -import NaturalLogicAnnotator from './natlog'; +import Annotator from "../annotator"; +import NaturalLogicAnnotator from "./natlog"; +import DependencyParseAnnotator from "./depparse"; +import CorefAnnotator from "./coref"; //TODO: Requirements are missing here https://stanfordnlp.github.io/CoreNLP/annotators.html, verify. @@ -18,28 +20,32 @@ class OpenIEAnnotator extends Annotator { */ constructor(options = {}) { super( - 'openie', + "openie", { // format (Enum) default One of {reverb, ollie, default, qa_srl}. Changes the output format of the program. Default will produce tab-separated columns for confidence, the subject, relation, and the object of a relation. ReVerb will output a TSV in the ReVerb format. Ollie will output relations in the default format returned by Ollie. // filelist (filepath) null A path to a file, which contains files to annotate. Each file should be on its own line. If this option is set, only these files are annotated and the files passed via bare arguments are ignored. // threads (integer) number of cores The number of threads to run on. By default, this is the number of cores in the system. // max_entailments_per_clause (integer) 1000 The maximum number of entailments to produce for each clause extracted in the sentence. The larger this value is, the slower the system will run, but the more relations it can potentially extract. Setting this below 100 is not recommended; setting it above 1000 is likewise not recommended. - // resolve_coref (boolean) false If true, run coreference (and consequently NER as a dependency of coreference) and replace pronominal mentions with their canonical mention in the text. + resolve_coref: false, // (boolean) false If true, run coreference (and consequently NER as a dependency of coreference) and replace pronominal mentions with their canonical mention in the text. // ignore_affinity (boolean) false Whether to ignore the affinity model for prepositional attachments. // affinity_probability_cap (double) 1 /3 The affinity value above which confidence of the extraction is taken as 1.0. // triple.strict (boolean) true If true, extract triples only if they consume the entire fragment. This is useful for ensuring that only logically warranted triples are extracted, but puts more burden on the entailment system to find minimal phrases (see -max_entailments_per_clause). - // triple.all_nominals (boolean) false If true, extract nominal relations always and not only when a named entity tag warrants it. This greatly overproduces such triples, but can be useful in certain situations. + triple: { all_nominals: false }, // If true, extract nominal relations always and not only when a named entity tag warrants it. This greatly overproduces such triples, but can be useful in certain situations. // splitter.model (filepath) You can override the default location of the clause splitting model with this option. // splitter.nomodel (boolean) false Run without a clause splitting model – that is, split on every clause. // splitter.disable (boolean) false Don’t split clauses at all, and only extract relations centered around the root verb. - // affinity_models (filepath) - ...options, + // affinity_models (filepath) + ...options }, - [ - new NaturalLogicAnnotator(), - ], + options.resolve_coref + ? [ + new CorefAnnotator(), + new DependencyParseAnnotator(), + new NaturalLogicAnnotator() + ] + : [new DependencyParseAnnotator(), new NaturalLogicAnnotator()] ); } } -export default OpenIEAnnotator; \ No newline at end of file +export default OpenIEAnnotator; diff --git a/src/simple/sentence.js b/src/simple/sentence.js index a6c3c23..32efc99 100644 --- a/src/simple/sentence.js +++ b/src/simple/sentence.js @@ -189,20 +189,22 @@ class Sentence extends Annotable { incommingDependencyLabel(index) { } + // TODO + // eslint-disable-next-line class-methods-use-this, no-unused-vars natlogPolarities() { - if (!this.hasAnnotator(NaturalLogicAnnotator)) { - throw new Error('Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); - } - return this._natLogPolarities; + // if (!this.hasAnnotator(NaturalLogicAnnotator)) { + // throw new Error('Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + // } + // return this._natLogPolarities; } // TODO // eslint-disable-next-line class-methods-use-this, no-unused-vars natlogPolarity(index) { - if (!this.hasAnnotator(NaturalLogicAnnotator)) { - throw new Error('Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); - } - return this._natLogPolarities[index]; + // if (!this.hasAnnotator(NaturalLogicAnnotator)) { + // throw new Error('Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + // } + // return this._natLogPolarities[index]; } // TODO From 86af2b623e3cac51e2dff014be3d6d19d59caa10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Mon, 15 Apr 2019 10:05:15 +0200 Subject: [PATCH 4/6] lint changes --- src/simple/annotator/natlog.js | 2 +- src/simple/annotator/natlog.spec.js | 2 +- src/simple/annotator/openie.js | 24 ++++++++++++------------ src/simple/annotator/openie.spec.js | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/simple/annotator/natlog.js b/src/simple/annotator/natlog.js index 9f19360..9f4b5ae 100644 --- a/src/simple/annotator/natlog.js +++ b/src/simple/annotator/natlog.js @@ -36,4 +36,4 @@ class NaturalLogicAnnotator extends Annotator { } } -export default NaturalLogicAnnotator; \ No newline at end of file +export default NaturalLogicAnnotator; diff --git a/src/simple/annotator/natlog.spec.js b/src/simple/annotator/natlog.spec.js index 9aea214..bd100d9 100644 --- a/src/simple/annotator/natlog.spec.js +++ b/src/simple/annotator/natlog.spec.js @@ -17,4 +17,4 @@ describe('Annotator', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/src/simple/annotator/openie.js b/src/simple/annotator/openie.js index 41f4581..9f7d6cd 100644 --- a/src/simple/annotator/openie.js +++ b/src/simple/annotator/openie.js @@ -1,9 +1,9 @@ -import Annotator from "../annotator"; -import NaturalLogicAnnotator from "./natlog"; -import DependencyParseAnnotator from "./depparse"; -import CorefAnnotator from "./coref"; +import Annotator from '../annotator'; +import NaturalLogicAnnotator from './natlog'; +import DependencyParseAnnotator from './depparse'; +import CorefAnnotator from './coref'; -//TODO: Requirements are missing here https://stanfordnlp.github.io/CoreNLP/annotators.html, verify. +// TODO: Requirements are missing here https://stanfordnlp.github.io/CoreNLP/annotators.html, verify. /** * @class @@ -20,7 +20,7 @@ class OpenIEAnnotator extends Annotator { */ constructor(options = {}) { super( - "openie", + 'openie', { // format (Enum) default One of {reverb, ollie, default, qa_srl}. Changes the output format of the program. Default will produce tab-separated columns for confidence, the subject, relation, and the object of a relation. ReVerb will output a TSV in the ReVerb format. Ollie will output relations in the default format returned by Ollie. // filelist (filepath) null A path to a file, which contains files to annotate. Each file should be on its own line. If this option is set, only these files are annotated and the files passed via bare arguments are ignored. @@ -35,15 +35,15 @@ class OpenIEAnnotator extends Annotator { // splitter.nomodel (boolean) false Run without a clause splitting model – that is, split on every clause. // splitter.disable (boolean) false Don’t split clauses at all, and only extract relations centered around the root verb. // affinity_models (filepath) - ...options + ...options, }, options.resolve_coref ? [ - new CorefAnnotator(), - new DependencyParseAnnotator(), - new NaturalLogicAnnotator() - ] - : [new DependencyParseAnnotator(), new NaturalLogicAnnotator()] + new CorefAnnotator(), + new DependencyParseAnnotator(), + new NaturalLogicAnnotator(), + ] + : [new DependencyParseAnnotator(), new NaturalLogicAnnotator()], ); } } diff --git a/src/simple/annotator/openie.spec.js b/src/simple/annotator/openie.spec.js index 1cb09d1..7cb678f 100644 --- a/src/simple/annotator/openie.spec.js +++ b/src/simple/annotator/openie.spec.js @@ -9,7 +9,7 @@ describe('Annotator', () => { }); it('should have a proper pipeline', () => { - expect(annotator.pipeline()).to.deep.equal(["tokenize", "ssplit", "pos", "lemma", "depparse", 'natlog', 'openie']); + expect(annotator.pipeline()).to.deep.equal(['tokenize', 'ssplit', 'pos', 'lemma', 'depparse', 'natlog', 'openie']); }); it('should have the proper default options', () => { @@ -17,4 +17,4 @@ describe('Annotator', () => { }); }); }); -}); \ No newline at end of file +}); From 06a428cc428b3b7b1cb4a0e0f193b92ceddce0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Mon, 15 Apr 2019 10:32:16 +0200 Subject: [PATCH 5/6] lint and pass tests --- src/simple/annotator/natlog.js | 3 ++- src/simple/annotator/openie.js | 28 ++++++++++++++-------------- src/simple/annotator/openie.spec.js | 14 +++++++++++++- src/simple/sentence.js | 24 +++++++++++++++++++----- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/simple/annotator/natlog.js b/src/simple/annotator/natlog.js index 9f4b5ae..e08df17 100644 --- a/src/simple/annotator/natlog.js +++ b/src/simple/annotator/natlog.js @@ -22,7 +22,8 @@ class NaturalLogicAnnotator extends Annotator { super( 'natlog', { - // dopolarity: True by default. If set to false, the annotator will only annotate quantifiers and quantifier scopes, and not annotate the polarity of each token + // dopolarity: True by default. If set to false, the annotator will only annotate + // quantifiers and quantifier scopes, and not annotate the polarity of each token ...options, }, [ diff --git a/src/simple/annotator/openie.js b/src/simple/annotator/openie.js index 9f7d6cd..16d21d4 100644 --- a/src/simple/annotator/openie.js +++ b/src/simple/annotator/openie.js @@ -22,19 +22,19 @@ class OpenIEAnnotator extends Annotator { super( 'openie', { - // format (Enum) default One of {reverb, ollie, default, qa_srl}. Changes the output format of the program. Default will produce tab-separated columns for confidence, the subject, relation, and the object of a relation. ReVerb will output a TSV in the ReVerb format. Ollie will output relations in the default format returned by Ollie. - // filelist (filepath) null A path to a file, which contains files to annotate. Each file should be on its own line. If this option is set, only these files are annotated and the files passed via bare arguments are ignored. - // threads (integer) number of cores The number of threads to run on. By default, this is the number of cores in the system. - // max_entailments_per_clause (integer) 1000 The maximum number of entailments to produce for each clause extracted in the sentence. The larger this value is, the slower the system will run, but the more relations it can potentially extract. Setting this below 100 is not recommended; setting it above 1000 is likewise not recommended. - resolve_coref: false, // (boolean) false If true, run coreference (and consequently NER as a dependency of coreference) and replace pronominal mentions with their canonical mention in the text. - // ignore_affinity (boolean) false Whether to ignore the affinity model for prepositional attachments. - // affinity_probability_cap (double) 1 /3 The affinity value above which confidence of the extraction is taken as 1.0. - // triple.strict (boolean) true If true, extract triples only if they consume the entire fragment. This is useful for ensuring that only logically warranted triples are extracted, but puts more burden on the entailment system to find minimal phrases (see -max_entailments_per_clause). - triple: { all_nominals: false }, // If true, extract nominal relations always and not only when a named entity tag warrants it. This greatly overproduces such triples, but can be useful in certain situations. - // splitter.model (filepath) You can override the default location of the clause splitting model with this option. - // splitter.nomodel (boolean) false Run without a clause splitting model – that is, split on every clause. - // splitter.disable (boolean) false Don’t split clauses at all, and only extract relations centered around the root verb. - // affinity_models (filepath) + // format (Enum) default One of {reverb, ollie, default, qa_srl}. Changes the output form + // filelist (filepath) null A path to a file, which contains files to annotate. + // threads (integer) number of cores The number of threads to run on. + // max_entailments_per_clause (integer) 1000 The maximum number of entailments to prod + resolve_coref: false, // (boolean) false If true, run coreference (and consequently + // ignore_affinity (boolean) false Whether to ignore the affinity model for preposi + // affinity_probability_cap (double) 1 /3 The affinity value above which confidence + // triple.strict (boolean) true If true, extract triples only if they consume the e + triple: { all_nominals: false }, // If true, extract nominal relations always and not o + // splitter.model (filepath) You can override the default location of the clause + // splitter.nomodel (boolean) false Run without a clause splitting model – that is, + // splitter.disable (boolean) false Don’t split clauses at all, and only extract re + // affinity_models (filepath) ...options, }, options.resolve_coref @@ -43,7 +43,7 @@ class OpenIEAnnotator extends Annotator { new DependencyParseAnnotator(), new NaturalLogicAnnotator(), ] - : [new DependencyParseAnnotator(), new NaturalLogicAnnotator()], + : [new NaturalLogicAnnotator()], ); } } diff --git a/src/simple/annotator/openie.spec.js b/src/simple/annotator/openie.spec.js index 7cb678f..aedf67d 100644 --- a/src/simple/annotator/openie.spec.js +++ b/src/simple/annotator/openie.spec.js @@ -9,11 +9,23 @@ describe('Annotator', () => { }); it('should have a proper pipeline', () => { - expect(annotator.pipeline()).to.deep.equal(['tokenize', 'ssplit', 'pos', 'lemma', 'depparse', 'natlog', 'openie']); + expect(annotator.pipeline()).to.deep.equal([ + 'tokenize', + 'ssplit', + 'pos', + 'lemma', + 'depparse', + 'natlog', + 'openie', + ]); }); it('should have the proper default options', () => { expect(annotator.options()).to.deep.equal({ + resolve_coref: false, + triple: { + all_nominals: false, + }, }); }); }); diff --git a/src/simple/sentence.js b/src/simple/sentence.js index 32efc99..ccf9062 100644 --- a/src/simple/sentence.js +++ b/src/simple/sentence.js @@ -2,7 +2,6 @@ import head from 'lodash.head'; import Annotable from './annotable'; import TokenizerAnnotator from './annotator/tokenize'; import ParserAnnotator from './annotator/parse'; -import NaturalLogicAnnotator from './annotator/natlog'; import OpenIEAnnotator from './annotator/openie'; import DependencyParseAnnotator from './annotator/depparse'; import Token from './token'; @@ -193,7 +192,9 @@ class Sentence extends Annotable { // eslint-disable-next-line class-methods-use-this, no-unused-vars natlogPolarities() { // if (!this.hasAnnotator(NaturalLogicAnnotator)) { - // throw new Error('Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + // throw new Error( + // 'Asked for PolarityAnnotation on Sentence, but there are unmet annotator dependencies.' + // ); // } // return this._natLogPolarities; } @@ -202,14 +203,27 @@ class Sentence extends Annotable { // eslint-disable-next-line class-methods-use-this, no-unused-vars natlogPolarity(index) { // if (!this.hasAnnotator(NaturalLogicAnnotator)) { - // throw new Error('Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.'); + // throw new Error( + // 'Asked for a PolarityAnnotation on Sentence, but there are unmet annotator dependencies.' + // ); // } // return this._natLogPolarities[index]; } - // TODO - // eslint-disable-next-line class-methods-use-this + /** + * Extract open-domain relation triples. + * @requires {@link OpenIEAnnotator} + * @throws {Error} in case the require annotator was not applied to the sentence + * @returns {Array.} OpenIE-Triples + */ openie() { + // TODO: Create OpenIE-Triples: + // object:"Constantin Hütterer" + // objectSpan:Array(2) [3, 5] + // relation:"is" + // relationSpan:Array(2) [2, 3] + // subject:"My name" + // subjectSpan:Array(2) [0, 2] if (!this.hasAnnotator(OpenIEAnnotator)) { throw new Error('Asked for a OpenIE-Annotation on Sentence, but there are unmet annotator dependencies.'); } From 4dbfca95254435aed258d4dcce564fbe13db55ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20H=C3=BCtterer?= Date: Wed, 17 Apr 2019 11:01:07 +0200 Subject: [PATCH 6/6] chore(imports) improve order of imports --- src/index.js | 4 ++-- src/index.spec.js | 4 ++-- src/pipeline.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index cb7c10c..9cbef47 100644 --- a/src/index.js +++ b/src/index.js @@ -5,8 +5,6 @@ import Expression from './simple/expression'; import Annotable from './simple/annotable'; import Annotator from './simple/annotator'; import TokenizerAnnotator from './simple/annotator/tokenize'; -import NaturalLogicAnnotator from './simple/annotator/natlog'; -import OpenIEAnnotator from './simple/annotator/openie'; import WordsToSentenceAnnotator from './simple/annotator/ssplit'; import POSTaggerAnnotator from './simple/annotator/pos'; import MorphaAnnotator from './simple/annotator/lemma'; @@ -16,6 +14,8 @@ import DependencyParseAnnotator from './simple/annotator/depparse'; import RelationExtractorAnnotator from './simple/annotator/relation'; import RegexNERAnnotator from './simple/annotator/regexner'; import CorefAnnotator from './simple/annotator/coref'; +import NaturalLogicAnnotator from './simple/annotator/natlog'; +import OpenIEAnnotator from './simple/annotator/openie'; import Tree from './util/tree'; import _Properties from './properties'; import _Pipeline from './pipeline'; diff --git a/src/index.spec.js b/src/index.spec.js index 75421df..5855bfa 100644 --- a/src/index.spec.js +++ b/src/index.spec.js @@ -11,8 +11,6 @@ import Annotable from './simple/annotable'; import Annotator from './simple/annotator'; import TokenizerAnnotator from './simple/annotator/tokenize'; import OpenIEAnnotator from './simple/annotator/openie'; -import NaturalLogicAnnotator from './simple/annotator/natlog'; -import WordsToSentenceAnnotator from './simple/annotator/ssplit'; import POSTaggerAnnotator from './simple/annotator/pos'; import MorphaAnnotator from './simple/annotator/lemma'; import NERClassifierCombiner from './simple/annotator/ner'; @@ -21,6 +19,8 @@ import DependencyParseAnnotator from './simple/annotator/depparse'; import RelationExtractorAnnotator from './simple/annotator/relation'; import RegexNERAnnotator from './simple/annotator/regexner'; import CorefAnnotator from './simple/annotator/coref'; +import NaturalLogicAnnotator from './simple/annotator/natlog'; +import WordsToSentenceAnnotator from './simple/annotator/ssplit'; import Tree from './util/tree'; describe('CoreNLP Library entry point', () => { diff --git a/src/pipeline.js b/src/pipeline.js index 82f606f..ec41b36 100644 --- a/src/pipeline.js +++ b/src/pipeline.js @@ -2,8 +2,6 @@ import difference from 'lodash.difference'; import Service from './service'; import ConnectorServer from './connector/connector-server'; import tokenize from './simple/annotator/tokenize'; -import natlog from './simple/annotator/natlog'; -import openie from './simple/annotator/openie'; import ssplit from './simple/annotator/ssplit'; import pos from './simple/annotator/pos'; import lemma from './simple/annotator/lemma'; @@ -13,6 +11,8 @@ import depparse from './simple/annotator/depparse'; import relation from './simple/annotator/relation'; import regexner from './simple/annotator/regexner'; import coref from './simple/annotator/coref'; +import natlog from './simple/annotator/natlog'; +import openie from './simple/annotator/openie'; import Document from './simple/document'; import {