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

closewords

v2.1.1

Published

A library for finding the most similar word from a list of words, supporting Japanese (including kanji). / 最も似た単語を単語群から検索する日本語(漢字含む)対応のライブラリ

Downloads

1,094

Readme

closewords

A library for finding the most similar word from a list of words, supporting Japanese (including kanji). 最も似た単語を単語群から検索する日本語(漢字含む)対応のライブラリ

Note: it may be a little slow because it uses morphological analysis. By adopting worker_threads, the processing speed is slightly improved compared to the standard. 注意: 形態素解析を利用しているため多少遅い可能性があります。worker_threads を採用しているため、標準より少しは処理速度は改善されています。

Teams

Usage

closeWords(word: string | { word: string, pronounce?: string }, candidates: Array<string | { word: string, pronounce?: string }>, raw?:boolean(default: false)): Promise<string[] | Array<{ word: string, score: number }>>

The highest score is 1 (the lowest is 0). A score of 1 means a perfect character-by-character match. スコアの最高値は1です(最低値は0です)。 スコアが1の場合、文字列が完全に一致していることを示します。

Example

const { closeWords } = require('closewords');

(async () => {
  const word = '東京';
  const candidates = ['東京', 'とっこう', '東きょう', 'とう京', 'とうきょう', 'とーきょー'];

  try {
    const result = await closeWords(word, candidates);
    console.log('結果:', result);

    // raw: true
    const resultWithScores = await closeWords(word, candidates, true);
    console.log('スコアを含む結果:', resultWithScores);
  } catch (error) {
    console.error('Error:', error);
  }
})();

Result

結果: [ '東京' ]
スコアを含む結果: [
  { word: '東京', score: 1 },
  { word: 'とう京', score: 0.6466666666666666 },
  { word: '東きょう', score: 0.4409090909090909 },
  { word: 'とうきょう', score: 0.42 },
  { word: 'とっこう', score: 0.36933333333333324 },
  { word: 'とーきょー', score: 0.356 }
]

Change Log

2.1.0 --> 2.1.1

Fixed README. Fixed the issue that only a string could be specified in word. Fixed the issue that word.pronounce was ignored. Fixed the issue that non-alphabet could be specified for word.pronounce and pronounce in candidates[]. word.pronounce and pronounce in candidates[] are now optional. Fixed a few pther bugs. README を修正しました。 word に文字列以外指定できない問題を修正しました。 word.pronounce が無視される問題を修正しました。 word.pronouncecandidates[] 内の pronounce にアルファベット以外を指定できる問題を修正しました。 word.pronouncecandidates[] 内の pronounce を任意にしました。 その他数件のバグを修正しました。

2.0.0 --> 2.1.0

Added a way to specify the pronunciation of words. 単語の発音を指定する方法を追加しました。

1.0.2 --> 2.0.0

Introduced fast-levenshtein and fixed score calculation. The similarity of the original strings is also evaluated. fast-levenshtein を導入し、スコア計算方法を修正しました。元の文字列の一致度も評価されるようになりました。

1.0.1 --> 1.0.2

Introduced jaro-winkler and optimized. jaro-winkler を導入し、最適化しました。

1.0.0 --> 1.0.1

Fixed score calculation. スコア計算方法を修正しました。

0.x --> 1.0.0

Package released! Introducing morphological analysis. パッケージをリリース! 形態素解析を導入しました。

Get Support