# edict-index

> Build and search an index from EDICT or other EDICT format databases.

Latest version **0.0.2** (published 2019-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install edict-index
pnpm add edict-index
yarn add edict-index
bun add edict-index
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-08-18 |
| First published | 2019-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 965.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mistval |
| Maintainers | rschmidt |
| Keywords | edict, japanese, dictionary, search, index, edict2 |

## Links

- npm: https://www.npmjs.com/package/edict-index
- Repository: https://github.com/mistval/edict-index
- Homepage: https://github.com/mistval/edict-index#readme
- Issues: https://github.com/mistval/edict-index/issues
- npm.io page: https://npm.io/package/edict-index

## Dependencies (1)

- [flexsearch](https://npm.io/package/flexsearch.md) ^0.6.23

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2019-08-18
- 0.0.1 — 2019-07-21

## README

# edict-index

Build and search an index from EDICT/EDICT2 or other EDICT-like dictionary files.

## Usage

If you have a dictionary file as a string, you can build an index and search it like this:

```js
const EdictIndex = require('edict-index');

const index = EdictIndex.buildIndex(EDICT2_AS_STRING); // This takes a long time so you should only do it once.
const results = index.search('十六夜');
console.log(JSON.stringify(results, null, 2));
```

This prints the following:

```json
[
  {
    "kanji": [
      "十六夜"
    ],
    "readings": [
      "いざよい"
    ],
    "glosses": [
      {
        "tags": [
          "n"
        ],
        "seeAlso": [],
        "definition": "sixteen-day-old moon"
      }
    ],
    "matchType": 100,
    "frequencyRank": 36431
  }
]
```

For examples that show how to obtain, decompress, and convert a dictionary file, see:

* [example_edict2.js](https://github.com/mistval/edict-index/blob/master/example_edict2.js)
* [example_hispadic.js](https://github.com/mistval/edict-index/blob/master/example_hispadic.js)

`matchType` is an enum. The values can be accessed via `const { MatchType } = require('edict-index');`. The values are:

```js
module.exports = {
  KANJI_OR_KANA_EXACT: 100,
  KANJI_OR_KANA_SUBSTRING: 75,
  DEFINITION_EXACT: 50,
  DEFINITION_SUBSTRING: 25,
  FUZZY: 1,
};
```

The `frequencyRank` is determined using a word frequency list in the module. This is used for sorting results. If the word is not in the frequency list, its rank will be `Number.MAX_SAFE_INTEGER`.

This module uses FlexSearch to index and search the dictionary. You can access the FlexSearch index directly if you need to `const { flexSearchIndex } = EdictIndex.buildIndex(EDICT2_AS_STRING);`.

---
_Source: https://npm.io/package/edict-index · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
