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

kakasijs

v1.1.4

Published

A nodejs wrapper for kakasi.It could help to resolve japanese text.

Downloads

12

Readme

kakasijs

Twiiter | Mail | GitHub

🔆 A nodejs wrapper for KaKaSi

⚠️ Bash-Shell-Using & Nodejs-Only

  • you should install kakasi first
  • you could not use it on browser

Usage

  1. Transform japanese sentence between different format(kana,kanji,romajin)
  2. Mark pronunciation to kanji
  3. Word Segmentation ( Need More Test )
const kakasi = require("kakasi");

(async()=>{
	const sentence =  "夢はジュエル 誰もひとつずつ 胸に抱きしめて";
	const senArr   =  ["夢はジュエル","誰もひとつずつ","胸に抱きしめて"]
    
	// -1.Transform->  
	let convertResult = await kakasi.toHira(sentence);
	console.log(convertResult.result)
	//  ゆめはじゅえる だれもひとつずつ むねにだきしめて

	// -2.Mark->
	let markResult = await kakasi.markKana(senArr);
	console.log(markResult.result)
	//  夢(ゆめ)はジュエル 誰も(だれも)ひとつずつ 胸(むね)に抱き(だき)しめて
  
	// -3.Separate-> 
	let sepResult = await kakasi.separate(senArr);
	console.log(sepResult.result)
	//  夢 は ジュエル 誰 もひとつずつ 胸 に 抱 きしめて
  
})()

Installation

0️⃣ Install kakasi

$ curl http://kakasi.namazu.org/stable/kakasi-2.3.6.tar.gz > kakasi-2.3.6.tar.gz
$ gzip -dc kakasi-2.3.6.tar.gz | tar xvf -
$ cd kakasi-2.3.6
$ ./configure
$ make
$ su
# make install

1️⃣ Make sure that kakasi is installed succeed

$ kakasi -h

2️⃣ Install kakasijs to your project

$ npm install kakasijs

API

Struct

// -0. Struct -> //
type Input = string | Array<string>
interface Result {
   result: string;
   from: string;
   to: string;
}

interface To{
   (sentence: Input) : Promise<Result>
}
interface Mark{
   (sentence: Input, leftEdge: string, rightEdge:string, separate:boolean = false) : Promise<Result>
}
interface Separate{
   (sentence :Input, separateChar :string = " "): Promise<Result>;
}

List

//-1. Transform -> //
// convert all to * 
toRoma :To
toHira :To
toKata :To
// convert kanji to * 
kanjitoRoma :To
kanjitoKata :To
kanjitoHira :To
// convert kana to * 
kanaToRoma :To
kanaToHira :To
kanaToKata :To
// convert hira to * 
hiraToRoma :To
hiraToKata :To
// convert kata to * 
kataToroma :To
kataTohira :To

// -2. Mark -> //
markKana :Mark
markKata :Mark

// -3. Separate -> //
separate :Separate

Transform

const kakasi = require("kakasi");

(async() => {
    let result = await kakasi.toHira("夢はジュエル 誰もひとつずつ 胸に抱きしめて")
    console.info(result);
})()

// TransformResult {
//   result: 'ゆめはじゅえる だれもひとつずつ むねにだきしめて',
//   from: 'all',
//   to: 'hira',
//   event: 'transform' }

Mark

const kakasi = require("kakasi");

(async() => {
    let result = await kakasi.markKana("夢はジュエル 誰もひとつずつ 胸に抱きしめて")
    console.info(result);
})()

// MarkResult {
//   result: '夢(ゆめ)はジュエル 誰も(だれも)ひとつずつ 胸(むね)に抱き(だき)しめて',
//   from: 'kanji',
//   to: 'kata',
//   event: 'mark,(,)', }

(async() => {
    let result = await kakasi.markKata("夢はジュエル 誰もひとつずつ 胸に抱きしめて",'[',']',true)
    console.info(result);
})()

// MarkResult {
//   result: '夢[ユメ] は ジュエル 誰も[ダレモ] ひとつずつ 胸[ムネ] に 抱き[ダキ] しめて',
//   from: 'kanji',
//   to: 'kata',
//   event: 'mark,[,], ', }

Separate

const kakasi = require("kakasi");

(async() => {
    let result = await kakasi.separate("夢はジュエル 誰もひとつずつ 胸に抱きしめて")
    console.info(result);
})()

// SeparateResult {
//   result: '夢 は ジュエル 誰 もひとつずつ 胸 に 抱 きしめて',
//   from: 'kanji',
//   to: 'k a n j i',
//   event: 'separate, ', }

(async() => {
    let result = await kakasi.separate(["夢はジュエル","誰もひとつずつ","胸に抱きしめて"],'_')
    console.info(result);
})()

// SeparateResult {
//   result: '夢_は_ジュエル 誰_もひとつずつ 胸_に_抱_きしめて',
//   from: 'kanji',
//   to: 'k_a_n_j_i',
//   event: 'separate,_', }

Knowledge

Just skip this section if you already know abot kanji,kana,hiragana,katakana and romajin.

kanji

Kanji ,or kan'ji, are the adopted logographic Chinese characters that are used in the modern Japanese writing system along with hiragana and katakana.

e.g

夢はジュエル -only the kanji-> 夢

誰もひとつずつ -only the kanji-> 誰

roma(Roman alphabet) <=> Latin alphabet

Mainly as Japanese , Korean pronunciation notes, similar to the English phonetic symbols.

e.g

夢はジュエル -marked with roma -> 夢(yu me)は(wa)ジュエル(ji yu e ru)

kana & hira(hiragana) & kata(katakana)

Kana (仮名) are syllabic Japanese scripts, a part of the Japanese writing system contrasted with the logographic Chinese characters known in Japan as kanji (漢字).

There are three kana scripts: modern cursive hiragana (ひらがな), formerly known as a women's script; modern angular katakana (カタカナ); and the old syllabic use of kanji known as man’yōgana (万葉仮名) that was ancestral to both. Hentaigana (変体仮名, "variant kana") are historical variants of modern standard hiragana.

In modern Japanese, hiragana and katakana have directly corresponding character sets (different sets of characters representing the same sounds).

e.g

#kana#

夢はジュエル -only the kana-> はジュエル

誰もひとつずつ -only the kana-> もひとつずつ

#hiragana#

夢はジュエル -only the hira-> は

誰もひとつずつ -only the hria-> もひとつずつ

#katakana#

夢はジュエル -only the kata-> ジュエル

誰もひとつずつ -only the kata-> NO_KATA_HERE

Coming next

  1. a tips that remind developer to install kakasi first.
  2. remove exec();
  3. connect to the author of kakasi for further impored