Convert0409.java
4.73 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/**
*
*/
package is2.util;
import is2.data.SentenceData09;
import is2.io.CONLLReader04;
import is2.io.CONLLReader06;
import is2.io.CONLLReader09;
import is2.io.CONLLWriter06;
import is2.io.CONLLWriter09;
/**
* @author Dr. Bernd Bohnet, 01.03.2010
*
*
*/
public class Convert0409 {
public static void main(String args[]) throws Exception {
convert(args[0],args[1]);
}
public static void convert(String source, String target) throws Exception {
CONLLReader04 reader = new CONLLReader04(source);
CONLLWriter09 writer = new CONLLWriter09(target);
int str =0;
while (true) {
SentenceData09 i = reader.getNext();
str++;
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];
if (formsNoRoot[j].length()==0 ||formsNoRoot[j].equals("")) {
System.out.println("error forms "+str);
// System.exit(0);
formsNoRoot[j]=" ";
}
posNoRoot[j] = i.gpos[j+1];
if (posNoRoot[j].length()==0 ||posNoRoot[j].equals(" ")) {
System.out.println("error pos "+str);
// System.exit(0);
}
pposs[j] = i.ppos[j+1];
if (pposs[j].length()==0 ||pposs[j].equals(" ")) {
System.out.println("error pos "+str);
//System.exit(0);
}
labels[j] = i.labels[j+1];
if (labels[j].length()==0 ||labels[j].equals(" ")) {
System.out.println("error lab "+str);
// System.exit(0);
}
heads[j] = i.heads[j+1];
if(heads[j]> posNoRoot.length) {
System.out.println("head out of range "+heads[j]+" "+heads.length+" "+str);
heads[j]=posNoRoot.length;
}
lemmas[j] = i.plemmas[j+1];
if (lemmas[j].length()==0 ||lemmas[j].equals(" ")) {
System.out.println("error lab "+str);
// System.exit(0);
}
org_lemmas[j] = i.lemmas[j+1];
if (org_lemmas[j].length()==0 ||org_lemmas[j].equals(" ")) {
System.out.println("error lab "+str);
// System.exit(0);
}
of[j] = i.ofeats[j+1];
pf[j] = i.pfeats[j+1];
if (str==6099) {
// System.out.println(formsNoRoot[j]+"\t"+posNoRoot[j]+"\t"+pposs[j]+"\t"+labels[j]+"\t"+heads[j]);
}
// (instance.fillp!=null) fillp[j] = instance.fillp[j+1];
}
SentenceData09 i09 = new SentenceData09(formsNoRoot, lemmas, org_lemmas,pposs, 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();
}
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();
}
}