func (t *typewriter) scanMorpheme() (sep string, str string) {
	var buf bytes.Buffer
	tok := t.read()
	if tok == nil {
		return
	}
	str, cat := interpretToken(tok)
	if cat == unknown {
		str = mergeLongVowels(str, 0)
	}
	if t.lastCat == meta || t.lastCat == illegal {
		sep = ""
	} else if cat == personName && t.lastCat == personName {
		sep = " "
	}
	t.lastCat = cat
	coreLen := utf8.RuneCountInString(str)
	buf.WriteString(str)
	for {
		tok := t.read()
		if tok == nil {
			break
		}
		str, cat := interpretToken(tok)
		if cat == auxiliary {
			buf.WriteString(str)
		} else {
			t.unread()
			break
		}
	}
	str = buf.String()
	str = mergeLongVowels(str, coreLen)
	return sep, str
}
scanMorpheme consumes the Kagome tokens one by one.
package furigana
import (
	"bytes"
	"strings"
	"unicode/utf8"
	kagome "github.com/ikawaha/kagome.ipadic/tokenizer"
)
type category int
const (
	illegal category = iota
	meta
	morpheme
	auxiliary
	properNoun
	personName
	unknown
)
type typewriter struct {
	tokens  []kagome.Token
	result  string
	cur     int
	lastCat category
}
func newTypewriter(tokens []kagome.Token) *typewriter {
	return &typewriter{tokens, "", -1, illegal}
}
func (t *typewriter) Typewrite() string {
	if t.cur != -1 {
		return t.result
	}
	var buf bytes.Buffer
	for {
		sep, str := t.scanMorpheme()
		if str == "" {
			break
		}
		buf.WriteString(sep)
		buf.WriteString(str)
	}
	t.result = buf.String()
	return t.result
}