// // // THIS IS A GENERATED FILE. DO NOT EDIT. // package main import ( "fmt" "os" "sort" //"github.com/kr/pretty" "github.com/pebbe/util" ) var x = util.CheckErr func main() { for _, filename := range os.Args[1:] { processFile(filename) } } func terminals(node *NodeType, doc *docType) []*NodeType { result := make([]*NodeType, 0) ids := make(map[int]bool) for _, nn := range find(doc /* $node/descendant-or-self::node[@pt or (@index and not(@cat or @pt))] */, &xPath{ arg1: &dSort{ arg1: &dCollect{ ARG: collect__descendant__or__self__node, arg1: &dVariable{ VAR: node, }, arg2: &dPredicate{ arg1: &dOr{ arg1: &dCollect{ ARG: collect__attributes__pt, arg1: &dNode{}, }, arg2: &dSort{ arg1: &dAnd{ arg1: &dCollect{ ARG: collect__attributes__index, arg1: &dNode{}, }, arg2: &dFunction{ ARG: function__not__1__args, arg1: &dArg{ arg1: &dSort{ arg1: &dOr{ arg1: &dCollect{ ARG: collect__attributes__cat, arg1: &dNode{}, }, arg2: &dCollect{ ARG: collect__attributes__pt, arg1: &dNode{}, }, }, }, }, }, }, }, }, }, }, }, }) { n := nn.(*NodeType) if n.Pt != "" { if ids[n.ID] { continue } ids[n.ID] = true result = append(result, n) } else { for _, m := range terminals(doc.Indexed[n.Index], doc) { if ids[m.ID] { continue } ids[m.ID] = true result = append(result, m) } } } return result } func deste(node *NodeType, doc *docType) []interface{} { return find(doc, /* $node//node[@cat="du" and count(.//node[node[@lemma=("hoe","deste") or (node[@lemma="des"] and node[@lemma="te"])] and node[@graad="comp"]])>1] */&xPath{ arg1: &dSort{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dCollect{ ARG: collect__descendant__or__self__type__node, arg1: &dVariable{ VAR: node, }, }, arg2: &dPredicate{ arg1: &dAnd{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__cat, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"du"}, arg1: &dCollect{ ARG: collect__attributes__cat, arg1: &dNode{}, }, }, }, arg2: &dCmp{ ARG: cmp__gt, arg1: &dFunction{ ARG: function__count__1__args, arg1: &dArg{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dCollect{ ARG: collect__descendant__or__self__type__node, arg1: &dNode{}, }, arg2: &dPredicate{ arg1: &dAnd{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dOr{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"hoe", "deste"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, arg2: &dSort{ arg1: &dAnd{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"des"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, }, }, arg2: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"te"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, }, }, }, }, }, }, }, arg2: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__graad, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"comp"}, arg1: &dCollect{ ARG: collect__attributes__graad, arg1: &dNode{}, }, }, }, }, }, }, }, }, }, }, arg2: &dElem{ DATA: []interface{}{1}, arg1: &dFunction{ ARG: function__count__1__args, arg1: &dArg{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dCollect{ ARG: collect__descendant__or__self__type__node, arg1: &dNode{}, }, arg2: &dPredicate{ arg1: &dAnd{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dOr{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"hoe", "deste"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, arg2: &dSort{ arg1: &dAnd{ arg1: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"des"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, }, }, arg2: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"te"}, arg1: &dCollect{ ARG: collect__attributes__lemma, arg1: &dNode{}, }, }, }, }, }, }, }, }, }, }, arg2: &dCollect{ ARG: collect__child__node, arg1: &dNode{}, arg2: &dPredicate{ arg1: &dEqual{ ARG: equal__is, arg1: &dCollect{ ARG: collect__attributes__graad, arg1: &dNode{}, }, arg2: &dElem{ DATA: []interface{}{"comp"}, arg1: &dCollect{ ARG: collect__attributes__graad, arg1: &dNode{}, }, }, }, }, }, }, }, }, }, }, }, }, }, }, }, }, }) } func processFile(filename string) { doc, err := parse(filename) x(err) results := make([]*NodeType, 0) for _, n := range deste(doc.Alpino.Node, doc) { node := n.(*NodeType) if len(deste(node, doc)) == 0 { results = append(results, node) } } for _, r := range results { fmt.Printf("%s\n %d\t", doc.Alpino.Sentence.SentId, r.ID) terms := terminals(r, doc) sort.Slice(terms, func(i, j int) bool { return terms[i].Begin < terms[j].Begin }) for _, t := range terms { fmt.Print(t.Word, " ") } fmt.Println() } }