gomamayo

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 13 Imported by: 0

README

go-gomamayo

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

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

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
	IsIgnored bool
}

func New deprecated

func New(sysdict string, isIgnored bool) (*Analyzer, error)

Deprecated: 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
analyzer
cmd

Jump to

Keyboard shortcuts

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