blob: a10f11298680008d4765e569318195a582cb91b4 [file] [log] [blame]
package datok
import (
"bufio"
"io"
)
type TokenWriterI interface {
SentenceEnd()
Token(int, []rune)
Flush() error
}
var _ TokenWriterI = &TokenWriterSimple{}
type TokenWriterSimple struct {
writer *bufio.Writer
}
func NewTokenWriterSimple(w io.Writer) *TokenWriterSimple {
return &TokenWriterSimple{bufio.NewWriter(w)}
}
func (tw *TokenWriterSimple) SentenceEnd() {
tw.writer.WriteRune('\n')
}
func (tw *TokenWriterSimple) Token(_ int, buf []rune) {
tw.writer.WriteString(string(buf))
tw.writer.WriteRune('\n')
}
func (tw *TokenWriterSimple) Flush() error {
return tw.writer.Flush()
}