-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Feat/natlog and open ie #52
base: master
Are you sure you want to change the base?
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please, use the same order as for the import statements (that's OCD 😆I know). |
||
}, | ||
}, | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same here, let's follow the same order. |
||
}); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: and here |
||
}; | ||
|
||
const LANGUAGE_TO_ISO2 = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
/** | ||
* 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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({ | ||
}); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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. | ||
|
||
/** | ||
* @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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
/** | ||
* 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 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 | ||
? [ | ||
new CorefAnnotator(), | ||
new DependencyParseAnnotator(), | ||
new NaturalLogicAnnotator(), | ||
] | ||
: [new NaturalLogicAnnotator()], | ||
); | ||
} | ||
} | ||
|
||
export default OpenIEAnnotator; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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({ | ||
resolve_coref: false, | ||
triple: { | ||
all_nominals: false, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, make sure this doesn't come as new change, since it was introduced by #51 ... rebasing your branch with the latest master HEAD should do the trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, thats great. I never had a concrete use-case for git rebase and therefore probably never really understood it. Thanks for changing that. 😄