-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframes.go
More file actions
36 lines (30 loc) · 882 Bytes
/
frames.go
File metadata and controls
36 lines (30 loc) · 882 Bytes
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
package entitydebs
import (
"iter"
"github.com/ndabAP/entitydebs/tokenize"
)
// Frames contains all analyzed frames and entities of a source. A forest of
// dependency trees can be constructed from the frames.
type Frames struct {
// frames contains data frames for each analyzed text.
frames []frame
// entities contains the tokenized entity.
entities map[string][]tokenize.Token
// deps contains dependency trees of all frames.
deps deps
}
// All returns all tokens of each sentence of all frames and the token offset to
// the first token of a sentence.
//
// An offset of zero indicates a frame advancement.
func (f Frames) All() iter.Seq2[int32, []*tokenize.Token] {
return func(yield func(int32, []*tokenize.Token) bool) {
for _, frame := range f.frames {
for i, sentence := range frame.all() {
if !yield(i, sentence) {
return
}
}
}
}
}