Skip to content

Instantly share code, notes, and snippets.

@mandel59
mandel59 / unihan_radicals.erq
Created March 24, 2024 11:25
部首別漢字総数の集計
-- Unihanのデータを使って、部首ごとの文字数をカウントする。
-- 複数の部首が登録されている漢字については、それぞれの部首で重複してカウントされる。
-- 実行コマンド: erq --init mojidata.erq < unihan_radicals.erq
table temp.radicals_chart =
unihan_kRSUnicode
join regexp_all(value, '(?<r>\d+)''*\.(?<s>\d+)')
{ UCS, unpack groups {r, s} }
join radicals on r=radical
{radical: 部首漢字 => count: count(distinct UCS)}
@mandel59
mandel59 / mj-toiawase-20240306.txt
Last active March 6, 2024 12:40
MJ文字情報一覧 部首・内画数の誤りについて
MJ文字情報一覧の部首・内画数のうち、下記リストのものは誤りが含まれると思われますが、こちらは修正可能でしょうか? ご確認いただきたく存じます。
リストは空行区切りのレコードになっていて、各レコード各行にMJ文字図形名、漢字、MJ文字情報一覧表に記載されている部首・内画数(複数ある場合は複数行にわたって記載。正しい部首・内画数も含む。)を順に記載しています。
以下、リスト
MJ000026
亠部6画
广部8画
-- erq <matsudo-population-density.erq > matsudo-population-density.svg
topojson_feature(readfile('r2ka12207.topojson'), 'town')
{*, unpack properties {KEY_CODE, AREA, JINKO}}
{*, population_density: JINKO / AREA * 1000000}
output vega lite svg with
projection mercator,
mark geoshape,
encoding {
color: population_density q {title: "人口密度[人/km²]"}
},
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width": 500,
"height": 300,
"data": {
"url": "https://geoshape.ex.nii.ac.jp/ka/topojson/2020/12/r2ka12207.topojson",
"format": {
"type": "topojson",
"feature": "town"
}
-- erq <jazh-consonants.erq >jazh-consonants.svg
attach '/Users/mandel59/ws/mojidata/packages/mojidata/dist/moji.db' as mojidata;;
with ja as (k: unihan_kJapaneseOn join o: string_split(k.value, ' ') {UCS, ja_c: ifnull(regexp_substr(lower(o.value), '^(ch|ts|sh|[hfbmtdnrszjkgwy])'), '∅') })
with zh as (k: unihan_kMandarin join p: string_split(k.value, ' ') {UCS, zh_c: ifnull(regexp_substr(p.value, '^(zh|ch|sh|[bpmfdtnlzcsrjqxgkhwy])'), '∅') })
joyo { UCS: 漢字 } join ja using (UCS) join zh using (UCS) { ja_c, zh_c => count: count(distinct UCS) }
output vega lite svg with
encoding {
x: ja_c n sort['h','f','b','m','t','ch','ts','d','n','r','s','sh','z','j','k','g','w','y','∅'],
y: zh_c n sort['b','p','m','f','d','t','n','l','zh','ch','sh','z','c','s','j','q','x','r','g','k','h','w','y','∅']
},
No. 文字情報基盤漢字 変更前UCS 変更前漢字 変更先UCS 変更先漢字
1 MJ006392 U+4E54 U+215E4 𡗤
2 MJ011878 U+617A U+2284C 𢡌
3 MJ016697 U+720B U+24455 𤑕
4 MJ026224 U+9094 U+2866C 𨙬
5 MJ031376 U+20778 𠝸 U+2D136 𭄶
6 MJ031861 U+20A44 𠩄 U+2B826 𫠦
7 MJ034361 U+21C79 𡱹 U+21C8F 𡲏
8 MJ034394 U+21CAA 𡲪 U+21978 𡥸
9 MJ036619 U+229FA 𢧺 U+229E3 𢧣
@mandel59
mandel59 / tetration-cobweb.ipynb
Last active November 26, 2022 10:24
√2の肩に無限に√2を乗せたらなぜ2になるのか、その図解
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mandel59
mandel59 / ambiguous-sources-2022-11-16.tsv
Last active November 21, 2022 20:12
This is the list of characters and their sources, whose IDS structure are ambiguous. Generated from BabelStone IDS.TXT (2022-11-16)
B,H,M,S,U,V,X,Z,UCS2003
K
G,K,M,T,U
Z
G,S,T,Z
Z
B,H,J,U,V,X
B
S,U,X,Z
S,X,Z
@mandel59
mandel59 / 2022-08-07-Fix-7-entries.patch
Created August 6, 2022 19:09
Patch for BabelStone's IDS.TXT 2022-08-07
From 5744eee9f8eae1f499d024631eedddea114d64e6 Mon Sep 17 00:00:00 2001
From: Ryusei Yamaguchi <mandel59@gmail.com>
Date: Sun, 7 Aug 2022 04:06:49 +0900
Subject: [PATCH] Fix 7 entries
U+5448, U+59C9, U+8821, U+947D, U+9855, U+20957, U+2BAA2
---
IDS.TXT | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
@mandel59
mandel59 / jgquery.erq
Created July 17, 2022 14:01
常用漢字と規範字の対応表を作るErqクエリ
-- 常用漢字と規範字の対応表
with joyo_itaiji (常用漢字, 異体字) as (joyo_kangxi {漢字, 康熙字典体}; joyo {漢字, 漢字} distinct)
with joyo_zvar (常用漢字, 異体字) as (
j: joyo_itaiji
join u: unihan_variant on u.property = 'kZVariant' and u.UCS = j.異体字
{常用漢字, 異体字};
j: joyo_itaiji
join m: mjsm_JIS包摂規準UCS統合規則 on j.異体字 = m.縮退UCS
join mji on mji.MJ文字図形名 = m.MJ文字図形名
[実装したUCS is not null]