gomamayo

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 12 Imported by: 0

README

go-gomamayo

Go Reference

ゴママヨ検出器のGo言語版です。na2na-p/gomamayo-denoを参考にした再実装です。
形態素解析にはikawaha/kagomeを使っています。
辞書にはIPADIC、NEologd、unidic、unidic3を使えます。

Releases

ダウンロードはこちらから

通常版

[!WARNING] 辞書を含むためファイルサイズが大きいです。(700MB+)

Lite版

[!NOTE] IPADICとunidicのみ含みます。(60MB+)

Library

go get -u github.com/yulog/go-gomamayo@latest

CLI

go install github.com/yulog/go-gomamayo/cmd/gomamayo@latest
Example
gomamayo analyze ごまマヨネーズ
{
  "isGomamayo": true,
  "combo": 1,
  "detail": [
    {
      "surface": "ごま|マヨネーズ",
      "dimension": 1,
      "rawResult1": {
        "id": 28368,
        "start": 0,
        "end": 2,
        "surface": "ごま",
        "class": "KNOWN",
        "pos": [
          "名詞",
          "一般",
          "*",
          "*"
        ],
        "base_form": "ごま",
        "reading": "ゴマ",
        "pronunciation": "ゴマ",
        "features": [
          "名詞",
          "一般",
          "*",
          "*",
          "*",
          "*",
          "ごま",
          "ゴマ",
          "ゴマ"
        ]
      },
      "rawResult2": {
        "id": 99158,
        "start": 2,
        "end": 7,
        "surface": "マヨネーズ",
        "class": "KNOWN",
        "pos": [
          "名詞",
          "一般",
          "*",
          "*"
        ],
        "base_form": "マヨネーズ",
        "reading": "マヨネーズ",
        "pronunciation": "マヨネーズ",
        "features": [
          "名詞",
          "一般",
          "*",
          "*",
          "*",
          "*",
          "マヨネーズ",
          "マ ヨネーズ",
          "マヨネーズ"
        ]
      }
    }
  ]
}
Usage
gomamayo analyze --disable-ignore ごまマヨネーズ
gomamayo ignore add サラダ
gomamayo ignore remove サラダ

License

MIT

Author

yulog

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIgnoreWord

func AddIgnoreWord(word string) error

AddIgnoreWord は除外ワードを追加する

func ExportIgnoreWords

func ExportIgnoreWords(path string) error

ExportIgnoreWords は除外ワードをエクスポートする

func ImportIgnoreWords

func ImportIgnoreWords(path string) error

ImportIgnoreWords は除外ワードをインポートする

func ListIgnoreWords

func ListIgnoreWords(w io.Writer) error

ListIgnoreWords は除外ワードを一覧する

func RemoveAllIgnoreWords

func RemoveAllIgnoreWords() error

RemoveAllIgnoreWords はすべての除外ワードを削除する

func RemoveIgnoreWord

func RemoveIgnoreWord(word string) error

RemoveIgnoreWord は除外ワードを削除する

Types

type Analyzer

type Analyzer struct {
	SysDict *dict.Dict
	// Reading()はuni系だと使えないため、各辞書のconstから持って来て利用する
	// https://github.com/ikawaha/kagome-dict/blob/339b5b8724769ec9506e29fb5e771a9ec012784f/uni/tool/main.go#L39
	ReadingIndex int
	IsIgnored    bool
}

func New

func New(dict *dictlib.Dict, isIgnored bool) *Analyzer

New は Analyzer を作る

func (Analyzer) Analyze

func (a Analyzer) Analyze(input string) (gomamayoResult GomamayoResult)

Analyze は input がゴママヨか判定する

type GomamayoDetail

type GomamayoDetail struct {
	Surface    string              `json:"surface"`
	Dimension  int                 `json:"dimension"`
	RawResult1 tokenizer.TokenData `json:"rawResult1"`
	RawResult2 tokenizer.TokenData `json:"rawResult2"`
}

type GomamayoResult

type GomamayoResult struct {
	IsGomamayo bool             `json:"isGomamayo"`
	Combo      int              `json:"combo"`
	Detail     []GomamayoDetail `json:"detail"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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