Documentation
¶
Overview ¶
Package splitter is a utility for preprocessing japanese texts.
Example ¶
sampleText := ` 人魚は、南の方の海にばかり棲んでいるのではあ
りません。北の海にも棲んでいたのであります。
北方の海うみの色は、青うございました。ある
とき、岩の上に、女の人魚があがって、あたりの景
色をながめながら休んでいました。
小川未明作 赤い蝋燭と人魚より`
scanner := bufio.NewScanner(strings.NewReader(sampleText))
scanner.Split(ScanSentences)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
if err := scanner.Err(); err != nil {
panic(err)
}
Output: 人魚は、南の方の海にばかり棲んでいるのではありません。 北の海にも棲んでいたのであります。 北方の海うみの色は、青うございました。 あるとき、岩の上に、女の人魚があがって、あたりの景色をながめながら休んでいました。 小川未明作赤い蝋燭と人魚より
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SentenceSplitter ¶
type SentenceSplitter struct {
Delim []rune // delimiter set. ex. {'。','.'}
Follower []rune // allow following after delimiters. ex. {'」','』'}
SkipWhiteSpace bool // eliminate white space or not
DoubleLineFeedSplit bool // splite at '\n\n' or not
MaxRuneLen int // max sentence length
}
SentenceSplitter is a tiny sentence splitter for japanese texts.
func (SentenceSplitter) ScanSentences ¶
func (s SentenceSplitter) ScanSentences(data []byte, atEOF bool) (advance int, token []byte, err error)
ScanSentences is a split function for a Scanner that returns each sentece of text.
Click to show internal directories.
Click to hide internal directories.