forked from advancedlogic/go-freeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.go
39 lines (35 loc) · 978 Bytes
/
output.go
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
package nlp
type Output struct{}
func (this Output) outputSense(a *Analysis) string {
res := ""
ls := a.getSenses()
if ls.Len() > 0 {
for l := ls.Front(); l != nil; l = l.Next() {
res += " " + l.Value.(*Pair).first.(string) + ""
}
}
return res
}
func (this Output) PrintTree(output *string, n *ParseTreeIterator, depth int) {
*output += CreateStringWithChar(depth*2, " ")
if n.pnode.numChildren() == 0 {
if n.pnode.info.(*Node).isHead() {
*output += "+"
}
w := n.pnode.info.(*Node).getWord()
if w == nil {
return
}
*output += "(" + w.getForm() + " " + w.getLemma(0) + " " + w.getTag(0) + ")\n"
//TODO: outputSense
} else {
if n.pnode.info.(*Node).isHead() {
*output += "+"
}
*output += n.pnode.info.(*Node).getLabel() + "_[\n"
for d := n.pnode.siblingBegin(); d.pnode != n.pnode.siblingEnd().pnode; d = d.siblingPlusPlus() {
this.PrintTree(output, d, depth+1)
}
*output += CreateStringWithChar(depth*2, " ") + "]\n"
}
}