Skip to content
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

Multi-model support #692

Merged
merged 3 commits into from
Sep 5, 2018
Merged

Multi-model support #692

merged 3 commits into from
Sep 5, 2018

Conversation

cowchipkid
Copy link
Contributor

This version eliminates the reliance on static singletons for configuration parameters, models, brown clusters and gazetteers for NER.

Thomas L. Redman added 2 commits September 1, 2018 19:00
…tatic singleton

rather they are stored in the annotator (which is a singleton per model via the factory for
NER annotators). In this way, we can have multiple NER models for different languages in the
same process space.
@cowchipkid
Copy link
Contributor Author

@mssammon @danyaljj I noticed when I ran the script to increment the version number, there were a slew of .gitignore files that were modified as well. I have not noticed this before, did the script do this? Should I commit these changes as well?

@danyaljj
Copy link
Member

danyaljj commented Sep 5, 2018

@cowchipkid not that I know of. Unless it's necessary, please don't.

Copy link
Contributor

@mssammon mssammon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks really good.
I've marked a couple of catch blocks that simply print an error, but don't otherwise interfere with program execution. I think failure to load a resource should result in an exception: if the client wants to ignore it, then they should do so consciously. It is generally undesirable to run without realizing some resource is not available.

@@ -153,15 +156,13 @@ else if (mode.contains("ALL")){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);
brownClusters = BrownClusters.get(bcs, bcst, bcsl);
WordNetManager.loadConfigAsClasspathResource(true);
wordNet = WordNetManager.getInstance();
}
catch (Exception e){
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please throw an exception here unless there is a recovery option based on a reported failure.

@@ -155,15 +158,14 @@ private void annotateTas(){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);
brownClusters = BrownClusters.get(bcs, bcst, bcsl);
WordNetManager.loadConfigAsClasspathResource(true);
wordNet = WordNetManager.getInstance();
}
catch (Exception e){
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree completely, however, this is not my code, it's nothing that I have changed, it has been this way. I can throw the exceptions up, but the exception apparently end up being thrown in the reader generation code inside the LBJava stuff, and again, I don't even know what this code does. So I can make the change, I can throw the exception up to the reader, but I can't change the getReader method signature of the LBJ generated code, or at least I shouldn't. I propose we throw the exceptions, but in the constructor for this reader, catch the thrown exceptions, convert them to a runtime exception and throw that so we don't have to change the get reader method. And the author should be made aware that this sort of absence of thought about error handling is wrong minded and unacceptable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is not your coding practice, just saw it in the context of your changes. I think your proposal is good. If you think it will take too much time right now, you can skip making the change, but open an issue that describes them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the change, and from just a cursor glance, I think it will work out just fine.

@@ -135,14 +138,11 @@ public String getId(){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);

brownClusters = BrownClusters.get(bcs, bcst, bcsl);
}
catch (Exception e){
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception

@@ -227,13 +230,11 @@ public static void testExtentOnGoldHead(){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);
brownClusters = BrownClusters.get(bcs, bcst, bcsl);
}
catch (Exception e){
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception

@@ -306,13 +309,11 @@ public static void testExtentOnPredictedHead(){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);
brownClusters = BrownClusters.get(bcs, bcst, bcsl);
}
catch (Exception e){
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception

@@ -181,8 +181,7 @@ else if (_mode.contains("ERE")){
bcsl.add(false);
bcsl.add(false);
bcsl.add(false);
BrownClusters.init(bcs, bcst, bcsl, false);
brownClusters = BrownClusters.get();
brownClusters = BrownClusters.get(bcs, bcst, bcsl);
WordNetManager.loadConfigAsClasspathResource(true);
wordNet = WordNetManager.getInstance();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception in following catch block

@@ -25,7 +25,6 @@
HashSet<String> labelsToAnonymizeForEvaluation = new HashSet<>();

private Data(Data other) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's OK to leave (or update) the original comment to make it immediately clear to any other dev why this is specified.


// NOTICE: this only checks tagger1 because tagger2 may legally be null.
if (tagger1 == null) {
if (params.taggerLevel1 == null) {
logger.error("Tagger1 is null. You may need to call NETagPlain.init() first.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it correct to return null here rather than throwing an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but as the above, it has always been this way. I personally don't use this method any more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Fine to leave as is, then.

Copy link
Member

@danyaljj danyaljj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides Mark's comments, looks good to me.

Copy link
Contributor

@mssammon mssammon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding the exception handling.

@mssammon mssammon merged commit 7d9dad3 into CogComp:master Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants