@@ -50,6 +50,29 @@ public static void copyEmptyNodes(SemanticGraph source, SemanticGraph target) {
50
50
}
51
51
}
52
52
53
+ public static SemanticGraph enhanceGraph (SemanticGraph basic , SemanticGraph originalEnhanced ,
54
+ boolean keepEmptyNodes ,
55
+ Embedding embeddings ,
56
+ Pattern relativePronounsPattern ) {
57
+
58
+ SemanticGraph enhanced = new SemanticGraph (basic .typedDependencies ());
59
+
60
+ if (keepEmptyNodes ) {
61
+ copyEmptyNodes (originalEnhanced , enhanced );
62
+ }
63
+
64
+ if (embeddings != null ) {
65
+ UniversalGappingEnhancer .addEnhancements (enhanced , embeddings );
66
+ }
67
+ UniversalGrammaticalStructure .addRef (enhanced , relativePronounsPattern );
68
+ UniversalGrammaticalStructure .collapseReferent (enhanced );
69
+ UniversalGrammaticalStructure .propagateConjuncts (enhanced );
70
+ UniversalGrammaticalStructure .addExtraNSubj (enhanced );
71
+ UniversalGrammaticalStructure .addCaseMarkerInformation (enhanced );
72
+ UniversalGrammaticalStructure .addCaseMarkerForConjunctions (enhanced );
73
+ UniversalGrammaticalStructure .addConjInformation (enhanced );
74
+ return enhanced ;
75
+ }
53
76
54
77
public static void main (String [] args ) {
55
78
Properties props = StringUtils .argsToProperties (args );
@@ -62,7 +85,7 @@ public static void main(String[] args) {
62
85
63
86
boolean keepEmptyNodes = PropertiesUtils .getBool (props , "keepEmpty" , false );
64
87
65
- Pattern relativePronounPattern = Pattern .compile (relativePronounsPatternStr );
88
+ Pattern relativePronounsPattern = Pattern .compile (relativePronounsPatternStr );
66
89
67
90
Iterator <Pair <SemanticGraph , SemanticGraph >> sgIterator ; // = null;
68
91
@@ -82,25 +105,9 @@ public static void main(String[] args) {
82
105
while (sgIterator .hasNext ()) {
83
106
Pair <SemanticGraph , SemanticGraph > sgs = sgIterator .next ();
84
107
SemanticGraph basic = sgs .first ();
85
-
86
108
SemanticGraph originalEnhanced = sgs .second ();
87
109
88
- SemanticGraph enhanced = new SemanticGraph (basic .typedDependencies ());
89
-
90
- if (keepEmptyNodes ) {
91
- copyEmptyNodes (originalEnhanced , enhanced );
92
- }
93
-
94
- if (embeddings != null ) {
95
- UniversalGappingEnhancer .addEnhancements (enhanced , embeddings );
96
- }
97
- UniversalGrammaticalStructure .addRef (enhanced , relativePronounPattern );
98
- UniversalGrammaticalStructure .collapseReferent (enhanced );
99
- UniversalGrammaticalStructure .propagateConjuncts (enhanced );
100
- UniversalGrammaticalStructure .addExtraNSubj (enhanced );
101
- UniversalGrammaticalStructure .addCaseMarkerInformation (enhanced );
102
- UniversalGrammaticalStructure .addCaseMarkerForConjunctions (enhanced );
103
- UniversalGrammaticalStructure .addConjInformation (enhanced );
110
+ SemanticGraph enhanced = enhanceGraph (basic , originalEnhanced , keepEmptyNodes , embeddings , relativePronounsPattern );
104
111
System .out .print (writer .printSemanticGraph (basic , enhanced ));
105
112
}
106
113
0 commit comments