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

soxsot

v0.8.2

Published

Library for manipulating Shaleian dictionaries

Downloads

29

Readme

Overview

An official library for manipulating dictionaries written in the new Shaleian dictionary format (.xdn/.xdnw/.xdns). It enables you to perform various operations on Shaleian dictionaries, including parsing, searching and editing.

Classes and functions for manipulating dictionary data are exported from the main entrypoint, and run on both Node.js and browsers. Those concerning file I/O are exported separately from dist/io, which require Node.js modules and run only on Node.js.

This package is currently under development and its API may be significantly changed in the future.

新シャレイア語辞典形式 (.xdn/.xdnw/.xdns) で記述された辞書を操作するための公式ライブラリです。 パース, 検索, 編集などといったシャレイア語辞典に対する様々な操作を行うことができます。

辞書データの操作を行うクラスや関数はメインエントリーポイントからエクスポートされていて、Node.js とブラウザの両方で動きます。 ファイル入出力に関する部分は dist/io からエクスポートされていて、これは Node.js のモジュールを必要とするため Node.js でしか動きません。

このパッケージは現在開発中のため、API は今後大幅に変更される可能性があります。

Installation

Install via npm.

npm i soxsot

Basic usage

Loading

// create a loader
let loader = new DirectoryLoader("directory-path");
// load a dictionary from the specified direcotry
let dictionary = await loader.asPromise();

Saving

// create a saver
let saver = new DirectorySaver(dictionary, "directory-path");
// save a dictionary to the specified directory
await saver.asPromise();

Searching

// create a parameter object for searching
// here we will perform a prefix search of “savac”
// from the word names of the Japanese entries ignoring diacritics and cases
let parameter = new NormalParameter(
  "savac",   // what to search
  "name",    // where to search from
  "prefix",  // how to match (exact, prefix, part or etc…)
  "ja",      // language
  {case: true, diacritic: true}  // what to ignore
);
// perform the search
let result = dictionary.search(parameter);
let words = result.words;
let suggestions = result.suggestions;

Plain objects

Classes related to dictionary data itself, such as Dictionary and Word, have several properties for internal processing. Therefore, when you send objects of these classes using IPC/HTTP communication, if you do not modify them and serialise them as-is, unnecessary data will be included. To prevent this, each such class provides the toPlain method to create plain objects without internal data, and the fromPlain static method to reconvert them to the class objects.

DictionaryWord などの辞書データ本体に関するクラスは、内部処理用のプロパティをいくつかもっています。 そのため、IPC/HTTP 通信を使ってこれらのクラスのオブジェクトを送信するときに、そのオブジェクトに手を加えずにそのままシリアライズすると、不必要なデータが含まれることになります。 これを防ぐため、そのようなクラスには、内部データを含まないプレーンオブジェクトを作る toPlain メソッドと、それらをクラスのオブジェクトに戻す fromPlain 静的メソッドが定義されています。

// create a plain object
let plainDictionary = dictionary.toPlain();
// send a plain object using IPC/HTTP communication
ipcRenderer.send("foo", plainDicitonary);

// receive a plain object
ipcMain.on("foo", (event, plainDictionary) => {
  // convert the plain object to a class object
  let dictionary = Dictionary.fromPlain(plainDictionary);
});