Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Changed every occurence of enum Mode to int and the enumerator values…
Browse files Browse the repository at this point in the history
… to int values to make it work with pyjnius
  • Loading branch information
mmxgn committed Sep 15, 2018
1 parent 909850b commit a20d877
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/main/java/de/uni_mannheim/minie/MinIE.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,23 @@ public MinIE(ObjectArrayList<AnnotatedProposition> props){
}

/** MinIE mode **/
/** Originally this was a public enum, in order for it to work
with pyjnius however (which has buggy enum reflection) we
replace it with the following integer values:
AGGRESSIVE = 0
DICTIONARY = 1
SAFE = 2
COMPLETE = 3
**/

public enum Mode {
AGGRESSIVE,
DICTIONARY,
SAFE,
COMPLETE
}



/** Default constructor **/
public MinIE(){
Expand All @@ -90,7 +101,7 @@ public MinIE(){
* @param mode - the minimization mode
* @param d - dictionary of multi-word expressions (for MinIE-D)
*/
public MinIE(String sentence, StanfordCoreNLP parser, Mode mode, Dictionary d) {
public MinIE(String sentence, StanfordCoreNLP parser, int mode, Dictionary d) {
// Initializations
this.propositions = new ObjectArrayList<AnnotatedProposition>();
this.sentenceSemGraph = new SemanticGraph();
Expand All @@ -108,7 +119,7 @@ public MinIE(String sentence, StanfordCoreNLP parser, Mode mode, Dictionary d) {
* NOTE: If mode is MinIE-D, then this will proceed as MinIE-D but with empty dictionary
* (i.e. will drop every word that is a candidate)
*/
public MinIE(String sentence, StanfordCoreNLP parser, Mode mode) {
public MinIE(String sentence, StanfordCoreNLP parser, int mode) {
this.propositions = new ObjectArrayList<AnnotatedProposition>();
this.sentenceSemGraph = new SemanticGraph();
this.sentence = new ObjectArrayList<>();
Expand All @@ -125,7 +136,7 @@ public MinIE(String sentence, StanfordCoreNLP parser, Mode mode) {
* NOTE: If mode is MinIE-D, then this will proceed as MinIE-D but with empty dictionary
* (i.e. will drop every word that is a candidate)
*/
public MinIE(String sentence, SemanticGraph sg, Mode mode) {
public MinIE(String sentence, SemanticGraph sg, int mode) {
this.propositions = new ObjectArrayList<AnnotatedProposition>();
this.sentenceSemGraph = new SemanticGraph();
this.sentence = new ObjectArrayList<>();
Expand All @@ -140,7 +151,7 @@ public MinIE(String sentence, SemanticGraph sg, Mode mode) {
* @param mode - the minimization mode
* @param d - dictionary of multi-word expressions (for MinIE-D)
*/
public MinIE(String sentence, SemanticGraph sg, Mode mode, Dictionary dict) {
public MinIE(String sentence, SemanticGraph sg, int mode, Dictionary dict) {
this.propositions = new ObjectArrayList<AnnotatedProposition>();
this.sentenceSemGraph = new SemanticGraph();
this.sentence = new ObjectArrayList<>();
Expand All @@ -158,7 +169,7 @@ public MinIE(String sentence, SemanticGraph sg, Mode mode, Dictionary dict) {
* @param mode - minimization mode
* @param d - dictionary (for MinIE-D)
*/
public void minimize(String sentence, StanfordCoreNLP parser, Mode mode, Dictionary d) {
public void minimize(String sentence, StanfordCoreNLP parser, int mode, Dictionary d) {
// Run ClausIE first
ClausIE clausie = new ClausIE();
clausie.setSemanticGraph(CoreNLPUtils.parse(parser, sentence));
Expand All @@ -172,11 +183,11 @@ public void minimize(String sentence, StanfordCoreNLP parser, Mode mode, Diction
this.setModality();

// Minimize according to the modes (COMPLETE mode doesn't minimize)
if (mode == Mode.SAFE)
if (mode == 2) // previously Mode.SAFE
this.minimizeSafeMode();
else if (mode == Mode.DICTIONARY)
else if (mode == 1) // Mode.DICTIONARY
this.minimizeDictionaryMode(d.words());
else if (mode == Mode.AGGRESSIVE)
else if (mode == 0) // Mode.AGGRESSIVE
this.minimizeAggressiveMode();

this.removeDuplicates();
Expand All @@ -191,7 +202,7 @@ else if (mode == Mode.AGGRESSIVE)
* @param mode - minimization mode
* @param d - dictionary (for MinIE-D)
*/
public void minimize(String sentence, SemanticGraph sg, Mode mode, Dictionary d) {
public void minimize(String sentence, SemanticGraph sg, int mode, Dictionary d) {
// Run ClausIE first
ClausIE clausie = new ClausIE();
clausie.setSemanticGraph(sg);
Expand All @@ -205,11 +216,11 @@ public void minimize(String sentence, SemanticGraph sg, Mode mode, Dictionary d)
this.setModality();

// Minimize according to the modes (COMPLETE mode doesn't minimize)
if (mode == Mode.SAFE)
if (mode == 2) // previously Mode.SAFE
this.minimizeSafeMode();
else if (mode == Mode.DICTIONARY)
else if (mode == 1) // Mode.DICTIONARY
this.minimizeDictionaryMode(d.words());
else if (mode == Mode.AGGRESSIVE)
else if (mode == 0) // Mode.AGGRESSIVE
this.minimizeAggressiveMode();

this.removeDuplicates();
Expand Down

0 comments on commit a20d877

Please sign in to comment.