Documentation
¶
Index ¶
- type Tree
- func (tree Tree) Dependencies(fn func(head, dependent *tokenize.Token) bool)
- func (tree Tree) Dependents(head *tokenize.Token, fn func(*tokenize.Token) bool) bool
- func (tree Tree) Edge(uid, vid int64) graph.Edge
- func (tree Tree) From(id int64) graph.Nodes
- func (tree Tree) Head(dependent *tokenize.Token) *tokenize.Token
- func (tree Tree) Root() *tokenize.Token
- func (tree Tree) Search(fn func(token *tokenize.Token) bool) (*tokenize.Token, bool)
- func (tree Tree) String() string
- func (tree Tree) To(id int64) graph.Nodes
- func (tree Tree) Walk(fn func(t *tokenize.Token) bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is a dependency tree.
func Parse ¶
Parse parses the given tokens and returns a head-to-dependent dependency tree. Parse will panic if the tokens contain cyclic dependencies.
The offset can be used if the tokens' head indices cross sentence boundaries.
Tokens and offset can't exceed 2^32.
func (Tree) Dependencies ¶
Dependencies iterates over every relationship and calls fn with the head and dependent token. If fn returns false, Dependencies returns.
func (Tree) Dependents ¶
Dependents iterates over every dependent of head and calls fn with the token. If head has no dependents, it returns false, otherwise true.
func (Tree) Head ¶
Head returns the token dependent is headed from. If dependent is the root token, Head returns nil.
func (Tree) Search ¶
Search iterates over all tokens and returns the found token and true if fn resolves to true. The token order is deterministic.