dajareGo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: MIT Imports: 6 Imported by: 0

README

DajareGo Logo

DajareGo

DajareGo provides checking a sentence if it is Dajare (Japanese pun).

MIT LICENSE GitHub go.mod Go version GoDev

[日本語版Readmeはこちら]

Getting Started

Usage

First, import DajareGo to your project.

go get github.com/jugesuke/dajareGo
import "github.com/jugesuke/dajareGo"

Next, load dictionary of tokenizer.

if err := dajareGo.Init(); err != nil {
  panic(err)
}

Next, use IsDajare function.

result := dajareGo.IsDajare("アルミ缶の上にあるミカン")

To get the result if the sentence is Dajare, use result.IsDajare.

result := dajareGo.IsDajare("アルミ缶の上にあるミカン")
if result.IsDajare {
  fmt.Println("This is Dajare")
} else {
  fmt.Println("This is not Dajare")
}

More information, please read Document.

Definition of Dajare

In this Package, Dajare is defined the sentence contains pair(s) of words which has a similar reading but a different meaning.

The Gopher character is based on the Go mascot designed by Renée French.

Documentation

Overview

Package dajareGo provides checking a sentence if it is Dajare (Japanese pun).

Definition of Dajare

In this Package, Dajare is defined the sentence contains pair(s) of words which has a similar reading but a different meaning.

How to Use

You can check if a sentence is Dajare with IsDajare function, like below.

if err := dajareGo.Init(); err != nil {
	panic(err)
}
result := dajareGo.IsDajare("アルミ缶の上にあるミカン")
if result.IsDajare {
	fmt.Println("This is Dajare")
} else {
	fmt.Println("This is not Dajare")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Set dictionary. You must do this first.

func SetCustomDictionary

func SetCustomDictionary(dict *dict.Dict) error

Set dictionary you like. You can use a Kagome Dictionary. https://github.com/ikawaha/kagome#dictionaries

Types

type Result

type Result struct {
	// If it is Dajare, this field is True, else False.
	IsDajare bool

	// This field shows an index of all word which has a similar reading but a different meaning
	DajareWordIndex []int

	// a pair of sentence and its Syllables
	Sentence Token

	// Tokens of given sentence
	Tokens []Token
}

Result has a result of IsDajare function.

func IsDajare

func IsDajare(s string) Result

IsDajare checks if a sentence is Dajare.

type Syllable

type Syllable string

type Syllables

type Syllables []Syllable

func NewSyllables

func NewSyllables(new string) Syllables

type Token

type Token struct {
	Surface   string
	Syllables Syllables
}

Token is a pair of Surface and its Syllables

Directories

Path Synopsis
cmd
dajareGo command

Jump to

Keyboard shortcuts

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