yukichant 6.0.1 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +2 -2
- package/src/node.js +16 -5
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
yukichantは、テキストデータを詠唱呪文(魔法の言葉)に変換するコマンドです。
|
|
7
7
|
また変換した詠唱呪文は、元のテキストデータにデコードすることができます。
|
|
8
8
|
|
|
9
|
+
## Demo
|
|
10
|
+
|
|
11
|
+
- ブラウザで試せるデモページ: [https://amanoese.github.io/yukichant/](https://amanoese.github.io/yukichant/)
|
|
12
|
+
|
|
9
13
|
## 特徴
|
|
10
14
|
|
|
11
15
|
- **エンコード/デコード**: 任意のテキストを日本語の呪文風文章に変換し、復号できます。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yukichant",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@semantic-release/github": "^12.0.6",
|
|
47
47
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
48
48
|
"husky": "^9.1.7",
|
|
49
|
-
"jest": "^
|
|
49
|
+
"jest": "^30.3.0",
|
|
50
50
|
"jest-extended": "^1.2.0",
|
|
51
51
|
"semantic-release": "^25.0.3"
|
|
52
52
|
},
|
package/src/node.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
3
4
|
import kuromoji from 'kuromoji'
|
|
4
5
|
import natural from 'natural'
|
|
5
6
|
import typoCorrection from './typo-correction.js'
|
|
@@ -7,16 +8,26 @@ import { initTypoCorrection } from './typo-correction.js'
|
|
|
7
8
|
import fkm, { initFuzzyKanjiMatch } from './fuzzy-kanji-match.js'
|
|
8
9
|
import { createChant } from './index.js'
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
|
|
13
|
+
const meisi = JSON.parse(fs.readFileSync(new URL('../data/meisi.json', import.meta.url), 'utf8'));
|
|
14
|
+
const dousi = JSON.parse(fs.readFileSync(new URL('../data/dousi.json', import.meta.url), 'utf8'));
|
|
15
|
+
|
|
16
|
+
const kanji2radicalPath = require.resolve('kanjivg-radical/data/kanji2radical.json')
|
|
17
|
+
const kanjiVgRadicalDir = path.dirname(path.dirname(kanji2radicalPath))
|
|
18
|
+
const kanji2element = JSON.parse(
|
|
19
|
+
fs.readFileSync(path.join(kanjiVgRadicalDir, 'data', 'kanji2radical.json'), 'utf8')
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const yukidicBasePath = require.resolve('yukidic/dic/base.dat.gz')
|
|
23
|
+
const yukidicDir = path.dirname(path.dirname(yukidicBasePath))
|
|
24
|
+
const dicPath = path.join(yukidicDir, 'dic') + path.sep
|
|
14
25
|
|
|
15
26
|
initFuzzyKanjiMatch({ meisi, dousi, kanji2element, TfIdf: natural.TfIdf });
|
|
16
27
|
|
|
17
28
|
const tokenizer = await new Promise((resolve, reject) => {
|
|
18
29
|
kuromoji
|
|
19
|
-
.builder({ dicPath
|
|
30
|
+
.builder({ dicPath })
|
|
20
31
|
.build(function (err, tokenizer) {
|
|
21
32
|
if (err != null) {
|
|
22
33
|
reject(err);
|