郵便番号から住所に変換するツールです。
jsmigemo の成果物の一部から流用し開発しました。
jsmigemoと同様の辞書構造を用いることでデータサイズの削減を図りましたが、実は全然小さくなっていません。 本ツールで用いている、郵便番号から住所に変換するだけの辞書が 1.39MB です。 郵便局のウェブサイトで配布しているCSVファイルがZIP圧縮で 1.94MB です。
よって現段階では全く実用的ではありません。
- 辞書ファイルのサイズの削減
- 読みがなの格納
- CIにより辞書ファイルを自動的に更新
- 住所から郵便番号を検索
- 郵便局のウェブサイトから、最新の郵便番号データをダウンロードして下さい。 「最新データのダウンロード」の「最新データのダウンロード」をクリックすると、「utf_all.zip」を入手できます。
- 「utf_all.zip」中の「UTF_ALL.CSV」ファイルをプロジェクト直下に展開します。
node .\bin\freeyubin-tool.mjs
で、CMigemo形式に変換します。node .\bin\freeyubin-dict.mjs a.txt freeyubin-dict
で、省メモリMigemo形式に変換します。
freeyubin-dict
が、生成した辞書ファイルです。
> node bin/freeyubin-cli.mjs 5650871
大阪府 吹田市 山田丘
const url = 'freeyubin-dict'
fetch(url)
.then(e => e.arraybuffer())
.then(e => {
const dict = new freeyubin.CompactDictionary(e)
const iter = dict.search('5650871')
const address = iter.next().value
console.log(address)
})
三条項BSDライセンス