npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gomamayo

v1.1.6

Published

MeCab不要のゴママヨ検出ライブラリ

Readme

gomamayo

MeCab不要のゴママヨ検出ライブラリ

kuromoji.js とそのdict、 kuromoji-ipadic-neologd のdict を使用して精度を向上させています。
固有名詞のゴママヨも一応検出可能です。

[!WARNING]
使用している辞書のサイズが非常に大きく、判定時の kuromoji.builder({ dicPath }).build((err, tokenizer) => { ... }); でかなり膨大なメモリを消費します(Linux環境での検証時は4GB程度)
メモリに余裕がない環境で使用する際は、判定の制度は下がりますが useNeologdfalse に設定することをおすすめします。

[!NOTE]
使用している辞書のサイズが非常に大きく、導入のためのスクリプトが特殊なため、開発者の環境ではインストールに3分ほど要しました。
自作のゴママヨ判定のインストールに3分も掛かるという動画(YouTube)
~~スクリプトなどを改善し、現在は開発者の環境では1分未満でインストールが可能になりました。 (v1.1.3 より)~~

Install

以下の操作のみで使用できるはずです。

npm install gomamayo

Usage

プログラムから使用

// ESM
import { analyze } from 'gomamayo';
// CJS
const { analyze } = require('gomamayo');

(async () => {
  // 1次ゴママヨの例
  const result1 = await analyze('ごまマヨネーズ');
  console.log(result1.isGomamayo); // true
  console.log(result1.degree); // 1
  console.log(result1.matches[0].words); // ['ごま', 'マヨネーズ']

  // 2次ゴママヨの例
  const result2 = await analyze('博麗霊夢');
  console.log(result2.isGomamayo); // true
  console.log(result2.degree); // 2
  console.log(result2.matches[0].readings); // ['ハクレイ', 'レイム']
})();

オプション

// 高次ゴママヨを検出しない(1次のみ)
await analyze('博麗霊夢', { higher: false });

// 多項ゴママヨを検出しない(最初の1項のみ)
await analyze('太鼓公募募集終了', { multi: false });

// neologd辞書を使用しない(メモリ節約、ただし固有名詞の検出精度が低下)
await analyze('博麗霊夢', { useNeologd: false });

メモリ管理

辞書は一度ロードするとキャッシュされ、以降の呼び出しでは再利用されます。 使用後にメモリを解放したい場合は clearTokenizerCache を使用してください。

import { analyze, clearTokenizerCache } from 'gomamayo';

// 解析を実行
const result = await analyze('ごまマヨネーズ');

// 辞書キャッシュをクリアしてメモリを解放
clearTokenizerCache(); // 全ての辞書を解放
clearTokenizerCache('neologd'); // neologd辞書のみ解放
clearTokenizerCache('ipadic'); // ipadic辞書のみ解放

[!TIP]
メモリ使用量を抑えたい場合:

  • useNeologd: false を指定すると、neologd辞書をロードせずに解析できます(約50%のメモリ削減)
  • 解析後に clearTokenizerCache() を呼び出すと、辞書をメモリから解放できます

CLI

# 1次ゴママヨ
npx gomamayo ごまマヨネーズ

# 2次ゴママヨ
npx gomamayo 博麗霊夢

# オプション
npx gomamayo 博麗霊夢 --higher false  # 高次検出なし
npx gomamayo 太鼓公募募集終了 --multi false  # 多項検出なし
npx gomamayo ごまマヨネーズ --neologd false  # neologd辞書なし(省メモリ)

API

analyze(input, options?)

ゴママヨを解析して詳細な結果を返します。

isGomamayo(input, options?)

ゴママヨかどうかを boolean で返します。

find(input, options?)

ゴママヨの場合は GomamayoMatch[] を、そうでなければ null を返します。

clearTokenizerCache(type?)

トークナイザーのキャッシュをクリアしてメモリを解放します。

  • type: 'ipadic' | 'neologd' | 'all' (デフォルト: 'all')

貢献

コントリビューションを歓迎します!詳細はコントリビューションガイドラインをご覧ください。

貢献者

Contributors

参考

  • https://3qua9la-notebook.hatenablog.com/entry/2021/04/10/220317
  • https://github.com/Hayao0819/Awesome-Gomamayo
  • https://github.com/jugesuke/gomamayo
  • https://github.com/ThinaticSystem/gomamayo.js
    • https://www.npmjs.com/package/gomamayo-js

[!WARNING]
このパッケージは Apache License 2.0 の依存ライブラリ(kuromoji.js および kuromoji-ipadic-neologd)を使用しています。このパッケージ自体は MIT License ですが、これらの依存関係のライセンス条項も適用されます。