ikku

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 5 Imported by: 0

README

ikku-go (一句)

ikku-go is Ikku("一句") detector, Ikku is something like Japanese Haiku("俳句").

Inspired by r7kamura/ikku.

logo image

Install

$ go get github.com/kurochan/ikku-go

Example

import (
	"fmt"
	"github.com/ikawaha/kagome-dict/ipa"
	ikku "github.com/kurochan/ikku-go"
)

r, err := ikku.NewReviewer(ipa.Dict())
if err != nil {
	panic(err)
}

// This is Haiku.
fmt.Println(r.Find("古池や蛙飛び込む水の音"))
// This contains Haiku.
fmt.Println(r.Find("まさに古池や蛙飛び込む水の音ですね。"))
// This is NOT Haiku.
fmt.Println(r.Find("今日もいい天気だ。"))

song := r.Find("まさに古池や蛙飛び込む水の音ですね。")
fmt.Println(song.String())
// Output: 古池や蛙飛び込む水の音

Documentation

Overview

ikku is Ikku("一句") detector, Ikku is something like Japanese Haiku("俳句").

Inspired by r7kamura/ikku.

Example
package main

import (
	"fmt"

	"github.com/ikawaha/kagome-dict/ipa"
	ikku "github.com/kurochan/ikku-go"
)

func main() {
	r, err := ikku.NewReviewer(ipa.Dict())
	if err != nil {
		panic(err)
	}
	// This is Haiku.
	fmt.Println(r.Find("古池や蛙飛び込む水の音"))
	// This contains Haiku.
	fmt.Println(r.Find("まさに古池や蛙飛び込む水の音ですね。"))
	// This is NOT Haiku.
	fmt.Println(r.Find("今日もいい天気だ。"))
}
Output:

Example (Print)
package main

import (
	"fmt"

	"github.com/ikawaha/kagome-dict/ipa"
	ikku "github.com/kurochan/ikku-go"
)

func main() {
	r, err := ikku.NewReviewer(ipa.Dict())
	if err != nil {
		panic(err)
	}
	song := r.Find("まさに古池や蛙飛び込む水の音ですね。")
	fmt.Println(song.String())
}
Output:

古池や蛙飛び込む水の音

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReviewerOptionExactly

func ReviewerOptionExactly(exactly bool) reviewerOptionExactly

Requires exact match.

Example
package main

import (
	"github.com/ikawaha/kagome-dict/ipa"
	ikku "github.com/kurochan/ikku-go"
)

func main() {
	ikku.NewReviewer(
		ipa.Dict(),
		ikku.ReviewerOptionExactly(true),
	)
}
Output:

func ReviewerOptionRule

func ReviewerOptionRule(rule []int) reviewerOptionRule

Customize count rule.

Example
package main

import (
	"github.com/ikawaha/kagome-dict/ipa"
	ikku "github.com/kurochan/ikku-go"
)

func main() {
	//nolint
	ikku.NewReviewer(
		ipa.Dict(),
		ikku.ReviewerOptionRule([]int{5, 7, 5, 7, 7}),
	)
}
Output:

Types

type Node

type Node struct {
	Token tokenizer.Token
}

func (*Node) String

func (n *Node) String() string

type Reviewer

type Reviewer struct {
	// contains filtered or unexported fields
}

func NewReviewer

func NewReviewer(dict *dict.Dict, opts ...ReviewerOption) (*Reviewer, error)

func (*Reviewer) Find

func (r *Reviewer) Find(text string) *Song

func (*Reviewer) Judge

func (r *Reviewer) Judge(text string) bool

func (*Reviewer) Search

func (r *Reviewer) Search(text string) []Song

type ReviewerOption

type ReviewerOption interface {
	Apply(*reviewerOption)
}

type Song

type Song struct {
	Phrases [][]Node
	Exactly bool
	Rule    []int
}

func (*Song) String

func (s *Song) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL