@@ -42,28 +42,13 @@ public AMRGraph(@JsonProperty("id") String id, @JsonProperty("source") String so
4242
4343 alignNodes ();
4444
45- populateTokens ();
4645
4746
4847
49- }
50-
51- @ Override
52- public ArrayList <Token > extractTokensFromNodes () {
53- ArrayList <Token > tokenlist = new ArrayList <>();
54-
55- int index = 0 ;
5648
57- PTBTokenizer <CoreLabel > ptbt = PTBTokenizer .newPTBTokenizer (new StringReader (this .input ), false , true );
58- while (ptbt .hasNext ()) {
59- CoreLabel label = ptbt .next ();
60- tokenlist .add (new Token (index , label .originalText (), label .word (), label .word ()));
61- index ++;
62- }
49+ }
6350
64- return tokenlist ;
6551
66- }
6752
6853 public void alignUtil (String NodeID , HashMap <String , Node > nodes , HashMap <String , Boolean > visited , int layer , FileWriter writer ) throws IOException {
6954 // Mark the current node as visited and print it
@@ -95,6 +80,7 @@ public void alignNodes() throws IOException, InterruptedException {
9580 for (String i : nodes .keySet ()) {
9681 visited .put (i , false );
9782 }
83+
9884 FileWriter myWriter = new FileWriter ("supportScripts/temp/AMR_TEMP.txt" );
9985 myWriter .write ("#::snt " + this .input + "\n " );
10086 myWriter .write ("(v" + this .top + " / " + nodes .get (this .top ).getLabel () + " " );
@@ -110,6 +96,11 @@ public void alignNodes() throws IOException, InterruptedException {
11096 new BufferedReader (new InputStreamReader (proc .getInputStream ()));
11197
11298 String line = null ;
99+ String [] tokens = null ;
100+ String [] ner_tags = null ;
101+ String [] ner_iob_tags = null ;
102+ String [] pos_tags = null ;
103+ String [] lemmas = null ;
113104 while ((line = input .readLine ()) != null ) {
114105
115106 if (line .startsWith ("v" )) {
@@ -126,8 +117,32 @@ public void alignNodes() throws IOException, InterruptedException {
126117 nodes .get (nodeid ).getAnchors ().add (a );
127118
128119 }
120+ if (line .startsWith ("###tokens" )){
121+ tokens = input .readLine ().split ("<###>" );
122+ }
123+ if (line .startsWith ("###ner_tags" )){
124+ ner_tags = input .readLine ().split ("<###>" );
125+ }
126+ if (line .startsWith ("###ner_iob_tags" )){
127+ ner_iob_tags = input .readLine ().split ("<###>" );
128+ }
129+ if (line .startsWith ("###pos_tags" )){
130+ pos_tags = input .readLine ().split ("<###>" );
131+ }
132+ if (line .startsWith ("###lemmas" )){
133+ lemmas = input .readLine ().split ("<###>" );
134+ }
129135 }
136+ ArrayList <Token > tokenlist = new ArrayList <>();
137+ for (int i = 0 ; i < tokens .length ; i ++) {
130138
139+ tokenlist .add (new Token (i ,tokens [i ],lemmas [i ],null ));
140+ tokenlist .get (i ).getExtraInformation ().put ("NER" ,ner_tags [i ]);
141+ tokenlist .get (i ).getExtraInformation ().put ("NER_IOB" ,ner_iob_tags [i ]);
142+ tokenlist .get (i ).getExtraInformation ().put ("POS" ,pos_tags [i ]);
143+
144+ }
145+ setTokens (tokenlist );
131146
132147 }
133148
0 commit comments