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

sasara

v0.2.0

Published

A lightweight Japanese bunsetsu-level dependency parser for npm.

Readme

sasara(簓)

English | 日本語

A Japanese bunsetsu-level dependency parser for npm. Inference runs on a lightweight linear model (~550KB) with no neural network, so the package stays dependency-light and works in both Node.js and the browser.

Features

  • Small and fast — the trained model is ~550KB. For a typical 10–20 bunsetsu sentence, parsing takes microseconds; morphological analysis dominates the runtime
  • Calibrated confidence scores — each attachment decision can return a probability of being correct
  • Browser-ready — dictionary and model paths are injectable, so it bundles cleanly
  • Written in TypeScript — type definitions included

Installation

npm install sasara

Usage

import { parse } from 'sasara'

const bunsetsu = await parse('太郎は花子に本を渡した。')
for (const b of bunsetsu) {
  console.log(b.surface, '->', b.head)
}
// 太郎は -> 3
// 花子に -> 3
// 本を -> 3
// 渡した。 -> null

parse() automatically loads the bundled trained model on first call.

Confidence scores

import { loadParser } from 'sasara'

const parser = await loadParser({ confidence: true })
const bunsetsu = await parser.parse('太郎は花子に本を渡した。')

for (const b of bunsetsu) {
  console.log(b.surface, '->', b.head, b.confidence)
  // { score: 12.3, probability: 0.91, forced: false }
}

Parsing from a token stream (synchronous)

If you already have morphological analysis results, pass kuromojin tokens directly.

import { tokenize } from 'kuromojin'
import { loadParser } from 'sasara'

const parser = await loadParser()
const tokens = await tokenize('太郎は花子に本を渡した。')
const bunsetsu = parser.parseSync(tokens)

Bunsetsu chunking only

If you don't need dependencies, the chunker is available on its own.

import { tokenize } from 'kuromojin'
import { chunk } from 'sasara'

const bunsetsu = chunk(await tokenize('太郎は花子に本を渡した。'))
// head is left unset (null)

[!NOTE] Input is expected to be a single sentence. Splitting a document into sentences is the caller's responsibility.

Output format

Each bunsetsu (phrase unit) is a Bunsetsu object.

interface Bunsetsu {
  index: number            // position of this bunsetsu in the sentence
  tokens: KuromojiToken[]  // morphemes that make up the bunsetsu
  surface: string          // surface string
  head: number | null      // index of the head bunsetsu; null for the root (sentence-final)
}

With confidence: true, each bunsetsu carries a confidence field (the root gets null).

interface Confidence {
  score: number        // raw attach-decision score (positive = attach, negative = shift)
  probability: number  // P(this attachment is correct), Platt-calibrated from |score|
  forced: boolean      // true if merged by the end-of-sentence fallback, not a classifier decision
}

CLI

npx sasara "太郎は花子に本を渡した。"
# [3] 渡した。
# ├── [0] 太郎は
# ├── [1] 花子に
# └── [2] 本を

-f, --format <tree|list|json> switches output format (default tree, root-down dependency tree in tree-command style); -c, --confidence annotates each bunsetsu with its attach probability, e.g. (0.91) or (0.91*) for a forced merge. Omit the text argument to read sentences from stdin, one per line:

echo "太郎は花子に本を渡した。" | npx sasara -f json -c | jq '.[].surface'

See sasara --help for the full option list (--model, --dic, --chunk).

Accuracy

| Dataset | UAS (head accuracy, root excluded) | Bunsetsu boundary F1 | |---|---|---| | GSD test | 83.31% | 87.15% | | PUD (out-of-domain) | 81.41% | 89.77% |

Full evaluation conventions, confidence calibration details, and the algorithm description live in docs/evaluation.md and docs/algorithm.md.

Browser usage

Browsers have no filesystem, so fetch the model JSON yourself and pass it via the model option. The kuromoji dictionary location must also be specified with dicPath.

import { loadParser } from 'sasara'

const model = await fetch('/assets/model.json').then((r) => r.json())
const parser = await loadParser({
  model,
  dicPath: '/assets/dict/', // where the kuromoji dictionary files (.dat.gz) are served
})

The model JSON ships in the package at sasara/model/model.json; copy it as an asset at build time.

License

  • Code: MIT
  • model/model.json is a derivative of UD_Japanese-GSD (curated by Megagon Labs) and is therefore licensed CC BY-SA 4.0. Commercial use is allowed; redistribution and modification require attribution to the source corpus and the same license
  • UD_Japanese-PUD (CC BY-SA 4.0) is used for evaluation only and is not included in the distribution