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 🙏

© 2024 – Pkg Stats / Ryan Hefner

shunou

v1.1.1

Published

## How To Use

Downloads

50

Readme

Shunou

How To Use

import {getFurigana} from "shunou"


// let text = ['澱んだ街角で,僕らは出会った', '活版印刷の流れを汲む出版作業では', 'お茶にお煎餅、よく合いますね', '野ブタ。をプロデュース', '本当に', '平気', '平然', '格好いい', '庭には2羽鶏がいる', '頑張り屋', 'アニメを見ています', '踏み込む']
let text = ['アニメを見ています']
for (const tmp of text) {
    getFurigana(tmp, {dicdir: '/opt/homebrew/lib/mecab/dic/unidic'}).then((val) => {
        // console.log(JSON.stringify(val, null, 2));
        console.log(JSON.stringify(val));
    });
}
[
  {
    "origin": "アニメ",
    "hiragana": "あにめ",
    "basicForm": "アニメ-animation",
    "pos": "名詞-普通名詞-一般",
    "separation": [
      {
        "bottom": "ア",
        "top": null
      },
      {
        "bottom": "ニ",
        "top": null
      },
      {
        "bottom": "メ",
        "top": null
      }
    ]
  },
  {
    "origin": "を",
    "hiragana": "お",
    "basicForm": "を",
    "pos": "助詞-格助詞",
    "separation": [
      {
        "bottom": "を",
        "top": null
      }
    ]
  },
  {
    "origin": "見",
    "hiragana": "み",
    "basicForm": "見る",
    "pos": "動詞-非自立可能",
    "separation": [
      {
        "bottom": "見",
        "top": "み"
      }
    ]
  },
  {
    "origin": "て",
    "hiragana": "て",
    "basicForm": "て",
    "pos": "助詞-接続助詞",
    "separation": [
      {
        "bottom": "て",
        "top": null
      }
    ]
  },
  {
    "origin": "い",
    "hiragana": "い",
    "basicForm": "居る",
    "pos": "動詞-非自立可能",
    "separation": [
      {
        "bottom": "い",
        "top": null
      }
    ]
  },
  {
    "origin": "ます",
    "hiragana": "ます",
    "basicForm": "ます",
    "pos": "助動詞",
    "separation": [
      {
        "bottom": "ま",
        "top": null
      },
      {
        "bottom": "す",
        "top": null
      }
    ]
  }
]

Other MeCab Options

export type MecabOptions = {
	rcfile?: string;
	dicdir?: string;
	userdic?: string;
	latticeLevel?: number;
	dictionaryInfo?: boolean;
	outputFormatType?: OutputFormatType;
	allMorphs?: boolean;
	nbest?: number;
	partial?: boolean;
	marginal?: boolean;
	maxGroupingSize?: number;
	nodeFormat?: string;
	unkFormat?: string;
	bosFormat?: string;
	eosFormat?: string;
	eonFormat?: string;
	unkFeature?: string;
	inputBufferSize?: number;
	dumpConfig?: boolean;
	allocateSentence?: boolean;
	theta?: number;
	costFactor?: number;
	output?: string;
};

Shunou uses the MeCab tokenizer, which is a binding for the CLI of MeCab. It should be available for EVERY OS!

This repo is heavily referenced by:

  • https://github.com/MikimotoH/furigana
  • https://github.com/hockyy/nican

MacOS Setup

  • Install mecab via brew

Using UniDic Dictionary

To enable mecab-unidic dictionary, add to$(brew --prefix)/etc/mecabrc the below:

  • dicdir = [$(brew --prefix) //Compute this first]/lib/mecab/dic/unidic

More or less, be like this:

hocky:~/project/shunou$ cat $(brew --prefix)/etc/mecabrc
;
; Configuration file of MeCab
;
; $Id: mecabrc.in,v 1.3 2006/05/29 15:36:08 taku-ku Exp $;
;
; dicdir =  /opt/homebrew/lib/mecab/dic/ipadic
dicdir = /opt/homebrew/lib/mecab/dic/unidic
; userdic = /home/foo/bar/user.dic

; output-format-type = wakati
; input-buffer-size = 8192

; node-format = %m\n
; bos-format = %S\n
; eos-format = EOS\n
  • You can try using IPAdic Neologd or other community based dictionary with the same method with the same method.
    • The important files are char.bin, dicrc, matrix.bin, sys.dic, unk.dic.
  • Put it in a directory, and set the dicdir based on the dictionary directory.

Other Brew Based Dictionary

  • https://formulae.brew.sh/formula/mecab-unidic

  • https://formulae.brew.sh/formula/mecab-jumandic#default

  • https://formulae.brew.sh/formula/mecab-ipadic#default

Linux set up should be similar