Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKK辞書を追加 #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ https://github.com/kotofurumiya/genshin-dict/releases/latest
| macOS追加辞書 | 原神辞書_macOS.txt | |
| iPhoneユーザ辞書 | | mac経由で追加可能(後述) |
| Google IME | 原神辞書_Windows.txt | macでもWindows用ファイルで追加可能 |
| SKK | SKK-JISYO.genshin | SKK辞書 |

## 利用方法(Windows)

Expand Down
13 changes: 12 additions & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import fs from 'fs';
import url from 'url';
import path from 'path';
import { loadDictList } from '../worddata/index.js';
import { toKotoeriDict, toMacUserDict, toWindowsImeDict, expandVuHiragana, toUtf16BOM } from './lib/platform.js';
import {
toKotoeriDict,
toMacUserDict,
toWindowsImeDict,
expandVuHiragana,
toUtf16BOM,
toSkkDict,
} from './lib/platform.js';
import { generateDocs } from './lib/docgen.js';
import { DictItem } from '../worddata/dict.js';

Expand All @@ -14,6 +21,7 @@ const distDir = path.join(dirname, '..', 'genshin-dictionary');
const winDictFile = path.join(distDir, '原神辞書_Windows.txt');
const macDictFile = path.join(distDir, '原神辞書_macOS.txt');
const macUserDictFile = path.join(distDir, '原神辞書_macOS_ユーザ辞書.plist');
const skkDictFile = path.join(distDir, 'SKK-JISYO.genshin');

console.log('辞書データを構築しています...');

Expand All @@ -28,6 +36,7 @@ console.log('辞書データを構築しています...');
const winIme = toWindowsImeDict(words);
const kotoeri = toKotoeriDict(words);
const plist = toMacUserDict(words);
const skk = toSkkDict(words);

console.log('ドキュメントを生成しています...');

Expand All @@ -44,9 +53,11 @@ console.log('辞書データを構築しています...');
fs.writeFileSync(winDictFile, toUtf16BOM(winIme));
fs.writeFileSync(macDictFile, kotoeri, 'utf8');
fs.writeFileSync(macUserDictFile, plist, 'utf8');
fs.writeFileSync(skkDictFile, skk, 'utf8');

console.log('完了しました');
console.log(winDictFile);
console.log(macDictFile);
console.log(macUserDictFile);
console.log(skkDictFile);
})();
12 changes: 12 additions & 0 deletions scripts/lib/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ export const toUtf16BOM = (str: string): Buffer => {
const u16leBuf = Buffer.from(`\ufeff${str}`, 'utf16le');
return u16leBuf;
};

export const toSkkDict = (items: DictItem[]) => {
const head = `;; -*- fundamental -*- ; coding: utf-8 -*-
;; okuri-ari entries.
;; okuri-nasi entries.`;
const dicts = items
.map(({ hiragana, word }) => {
return `${hiragana} /${word}/`;
})
.join('\n');
return [head, dicts].join('\n');
};