4
4
import edu .stanford .nlp .ling .*;
5
5
import edu .stanford .nlp .semgraph .*;
6
6
import edu .stanford .nlp .trees .*;
7
+ import edu .stanford .nlp .trees .ud .CoNLLUFeatures ;
7
8
import edu .stanford .nlp .util .*;
8
9
9
10
import java .io .*;
@@ -29,6 +30,7 @@ public class CoNLLUReader {
29
30
public static final int CoNLLU_LemmaField = 2 ;
30
31
public static final int CoNLLU_UPOSField = 3 ;
31
32
public static final int CoNLLU_XPOSField = 4 ;
33
+ public static final int CoNLLU_FeaturesField = 5 ;
32
34
public static final int CoNLLU_GovField = 6 ;
33
35
public static final int CoNLLU_RelnField = 7 ;
34
36
public static final int CoNLLU_MiscField = 9 ;
@@ -304,10 +306,21 @@ public CoreMap convertCoNLLUSentenceToCoreMap(CoNLLUDocument doc, CoNLLUSentence
304
306
cl .setValue (fields .get (CoNLLU_WordField ));
305
307
cl .setOriginalText (fields .get (CoNLLU_WordField ));
306
308
cl .setIsNewline (false );
309
+
307
310
if (!fields .get (CoNLLU_LemmaField ).equals ("_" ))
308
311
cl .setLemma (fields .get (CoNLLU_LemmaField ));
312
+
309
313
if (!fields .get (CoNLLU_UPOSField ).equals ("_" ))
310
314
cl .setTag (fields .get (CoNLLU_UPOSField ));
315
+
316
+ //final String xpos = fields.get(CoNLLU_XPOSField);
317
+ //if (!xpos.equals("_"))
318
+ // cl.setTag(xpos);
319
+
320
+ if (!fields .get (CoNLLU_FeaturesField ).equals ("_" )) {
321
+ CoNLLUFeatures features = new CoNLLUFeatures (fields .get (CoNLLU_FeaturesField ));
322
+ cl .set (CoreAnnotations .CoNLLUFeats .class , features );
323
+ }
311
324
for (int extraColumnIdx = 10 ; extraColumnIdx < columnCount && extraColumnIdx < fields .size ();
312
325
extraColumnIdx ++) {
313
326
cl .set (extraColumns .get (extraColumnIdx ), fields .get (extraColumnIdx ));
0 commit comments