Skip to content

Commit 1456d10

Browse files
committed
增加了DependencyTree中得到依赖型数组的函数getTags()
1 parent 577e23a commit 1456d10

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

fnlp-core/src/main/java/org/fnlp/nlp/parser/dep/DependencyTree.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ private void toList(ArrayList<List<String>> lists) {
246246
}
247247

248248
}
249-
249+
//错误
250250
public String[] getWords() {
251251
String[] words = new String[size];
252252
getWords(words);
253253
return words;
254254
}
255-
255+
//错误
256256
private void getWords(String[] words) {
257257
words[id] = word;
258258
for (int i = 0; i < leftChilds.size(); i++) {
@@ -262,6 +262,48 @@ private void getWords(String[] words) {
262262
rightChilds.get(i).getWords(words);
263263
}
264264

265-
}
265+
}
266+
/**
267+
* 得到依赖类型数组
268+
* @return
269+
*/
270+
271+
public String getTags() {
272+
StringBuffer sb = new StringBuffer();
273+
for (int i = 0; i < leftChilds.size(); i++) {
274+
sb.append(leftChilds.get(i).getTags());
275+
}
276+
if(relation!=null)
277+
sb.append(relation);
278+
else
279+
sb.append("核心词");
280+
sb.append(" ");
281+
for (int i = 0; i < rightChilds.size(); i++) {
282+
sb.append(rightChilds.get(i).getTags());
283+
}
284+
return sb.toString();
285+
}
286+
287+
288+
289+
290+
291+
292+
293+
294+
295+
296+
297+
298+
299+
300+
301+
302+
303+
304+
305+
306+
307+
266308

267309
}

0 commit comments

Comments
 (0)