ConvertADJ.java
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
*
*/
package is2.util;
import is2.data.SentenceData09;
import is2.io.CONLLReader09;
import is2.io.CONLLWriter06;
/**
* @author Dr. Bernd Bohnet, 01.03.2010
*
*
*/
public class ConvertADJ {
public static void main(String args[]) throws Exception {
convert(args[0], args[1]);
}
public static void convert(String source, String target) throws Exception {
CONLLReader09 reader = new CONLLReader09(source);
// CONLLWriter09 writer = new CONLLWriter09(target);
int adj = 0, argadj = 0;
int rb = 0, argrb = 0;
while (true) {
SentenceData09 i = reader.getNext();
if (i == null)
break;
for (int k = 0; k < i.length(); k++) {
if (i.gpos[k].startsWith("JJ"))
adj++;
if (i.gpos[k].startsWith("RB"))
rb++;
if (i.argposition != null) {
for (int[] element : i.argposition) {
if (element != null)
for (int a = 0; a < element.length; a++) {
if (element[a] == k && i.gpos[k].startsWith("JJ"))
argadj++;
if (element[a] == k && i.gpos[k].startsWith("RB"))
argrb++;
}
}
}
// (instance.fillp!=null) fillp[j] = instance.fillp[j+1];
}
}
System.out.println("adj " + adj + " " + argadj);
System.out.println("rb " + rb + " " + argrb);
}
public static void convert0906(String source, String target) throws Exception {
CONLLReader09 reader = new CONLLReader09(source);
CONLLWriter06 writer = new CONLLWriter06(target);
while (true) {
SentenceData09 i = reader.getNext();
if (i == null)
break;
String[] formsNoRoot = new String[i.length() - 1];
String[] posNoRoot = new String[formsNoRoot.length];
String[] lemmas = new String[formsNoRoot.length];
String[] org_lemmas = new String[formsNoRoot.length];
String[] of = new String[formsNoRoot.length];
String[] pf = new String[formsNoRoot.length];
String[] pposs = new String[formsNoRoot.length];
String[] labels = new String[formsNoRoot.length];
String[] fillp = new String[formsNoRoot.length];
int[] heads = new int[formsNoRoot.length];
for (int j = 0; j < formsNoRoot.length; j++) {
formsNoRoot[j] = i.forms[j + 1];
posNoRoot[j] = i.gpos[j + 1];
pposs[j] = i.ppos[j + 1];
labels[j] = i.labels[j + 1];
heads[j] = i.heads[j + 1];
lemmas[j] = i.plemmas[j + 1];
org_lemmas[j] = i.lemmas[j + 1];
of[j] = i.ofeats[j + 1];
pf[j] = i.pfeats[j + 1];
// (instance.fillp!=null) fillp[j] = instance.fillp[j+1];
}
SentenceData09 i09 = new SentenceData09(formsNoRoot, lemmas, org_lemmas, posNoRoot, pposs, labels, heads,
fillp, of, pf);
// public SentenceData09(String[] forms, String[] lemmas, String[]
// olemmas,String[] gpos, String[] ppos, String[] labs, int[] heads,
// String[] fillpred) {
// SentenceData09
// SentenceData09 i2 = new SentenceData09(i.forms,
// i.lemmas,i.org_lemmas,);
writer.write(i09);
}
writer.finishWriting();
}
}