From 11854eb84457dd11176808cd03dd14c5f0d6cd4f Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Wed, 24 May 2023 12:02:53 +0900 Subject: [PATCH] tweak: rename and level constants --- .gitignore | 4 ++ src/ca/fosskers/kanji.clj | 27 +++++------ src/ca/fosskers/kanji/levels.clj | 24 +++++----- test/ca/fosskers/kanji/levels_test.clj | 64 +++++++++++++------------- 4 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e221955 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.cpcache/* +target/* +.clj-kondo/* +.lsp/* diff --git a/src/ca/fosskers/kanji.clj b/src/ca/fosskers/kanji.clj index ca5ec0e..5f8f01a 100644 --- a/src/ca/fosskers/kanji.clj +++ b/src/ca/fosskers/kanji.clj @@ -14,18 +14,18 @@ [] (transduce (mapcat (fn [[ks level]] (map (fn [c] [c level]) ks))) conj {} - [[kl/LEVEL-10 :ten] - [kl/LEVEL-09 :nine] - [kl/LEVEL-08 :eight] - [kl/LEVEL-07 :seven] - [kl/LEVEL-06 :six] - [kl/LEVEL-05 :five] - [kl/LEVEL-04 :four] - [kl/LEVEL-03 :three] - [kl/LEVEL-02-PRE :pre-two] - [kl/LEVEL-02 :two] - [kl/LEVEL-01-PRE :pre-one] - [kl/LEVEL-01 :one]])) + [[kl/level-10 :ten] + [kl/level-09 :nine] + [kl/level-08 :eight] + [kl/level-07 :seven] + [kl/level-06 :six] + [kl/level-05 :five] + [kl/level-04 :four] + [kl/level-03 :three] + [kl/level-02-pre :pre-two] + [kl/level-02 :two] + [kl/level-01-pre :pre-one] + [kl/level-01 :one]])) (defn- aggregate-map ([] {}) @@ -40,4 +40,5 @@ [table text] (transduce (comp (filter kanji?) (map table)) aggregate-map text)) -(level-counts (level-table) "和歌山県には高野山という、真言宗の大本山がある") +(comment + (level-counts (level-table) "和歌山県には高野山という、真言宗の大本山がある")) diff --git a/src/ca/fosskers/kanji/levels.clj b/src/ca/fosskers/kanji/levels.clj index 40474fb..05c1da0 100644 --- a/src/ca/fosskers/kanji/levels.clj +++ b/src/ca/fosskers/kanji/levels.clj @@ -1,23 +1,23 @@ (ns ca.fosskers.kanji.levels) -(defonce LEVEL-10 +(def level-10 (set (str "一七三上下中九二五人休先入八六円出力十千口右名四土夕大天女子字学小山川左年手文日" "早月木本村林校森正気水火犬玉王生田男町白百目石空立竹糸耳花草虫見貝赤足車金雨青音"))) -(defonce LEVEL-09 +(def level-09 (set (str "万丸交京今会体何作元兄光公内冬刀分切前北午半南原友古台合同回図国園地場声売夏外多" "夜太妹姉室家寺少岩工市帰広店弓引弟弱強当形後心思戸才教数新方明星春昼時晴曜書朝来" "東楽歌止歩母毎毛池汽活海点父牛理用画番直矢知社秋科答算米紙細組絵線羽考聞肉自船色" "茶行西親角言計記話語読谷買走近通週道遠里野長門間雪雲電頭顔風食首馬高魚鳥鳴麦黄黒"))) -(defonce LEVEL-08 +(def level-08 (set (str "丁世両主乗予事仕他代住使係倍全具写列助勉動勝化区医去反取受号向君味命和品員商問坂" "央始委守安定実客宮宿寒対局屋岸島州帳平幸度庫庭式役待急息悪悲想意感所打投拾持指放" "整旅族昔昭暑暗曲有服期板柱根植業様横橋次歯死氷決油波注泳洋流消深温港湖湯漢炭物球" "由申界畑病発登皮皿相県真着短研礼神祭福秒究章童笛第筆等箱級終緑練羊美習者育苦荷落" "葉薬血表詩調談豆負起路身転軽農返追送速進遊運部都配酒重鉄銀開院陽階集面題飲館駅鼻"))) -(defonce LEVEL-07 +(def level-07 (set (str "不争井付令以仲伝位低佐例便信倉候借健側働億兆児共兵典冷初別利刷副功加努労勇包卒協" "単博印参司各周唱器固城埼塩変夫失奈好媛季孫完官害富察岐岡崎巣差希席帯底府康建径徒" "徳必念愛成戦折挙改敗散料旗昨景最望未末札材束松果栃栄案梅梨械極標機欠残氏民求沖治" @@ -25,21 +25,21 @@ "芽英茨菜街衣要覚観訓試説課議貨賀軍輪辞辺連達選郡量録鏡関阜阪陸隊静順願類飛飯養香" "験鹿"))) -(defonce LEVEL-06 +(def level-06 (set (str "久仏仮件任似余価保修個停備像再刊判制則効務勢厚句可史告喜営因団囲圧在均型基堂報境" "墓増士夢妻婦容寄導居属布師常幹序弁張往得復志応快性情態慣技招授採接提損支政故救断" "旧易暴条枝査格桜検構武歴殺毒比永河液混減測準演潔災燃版犯状独率現留略益眼破確示祖" "禁移程税築粉精紀素経統絶綿総編績織罪義耕職肥能脈興舎航術衛製複規解設許証評講謝識" "護豊象財貧責貯貸費貿資賛賞質輸述迷逆造過適酸鉱銅防限険際雑非領額飼"))) -(defonce LEVEL-05 +(def level-05 (set (str "並乱乳亡仁供俳俵値傷優党冊処券刻割創劇勤危卵厳収后否吸呼善困垂域奏奮姿存孝宅宇宗" "宙宝宣密寸専射将尊就尺届展層己巻幕干幼庁座延律従忘忠恩憲我批承担拝拡捨探推揮操敬" "敵映晩暖暮朗机枚染株棒模権樹欲段沿泉洗派済源潮激灰熟片班異疑痛皇盛盟看砂磁私秘穀" "穴窓筋策簡糖系紅納純絹縦縮署翌聖肺胃背胸脳腸腹臓臨至舌若著蒸蔵蚕衆裁装裏補視覧討" "訪訳詞誌認誕誠誤論諸警貴賃退遺郵郷針銭鋼閉閣降陛除障難革頂預骨"))) -(defonce LEVEL-04 +(def level-04 (set (str "丈与丘丹乾互介仰伺依侵俗倒偉傍傾僧儀兼冒凡凶刈到刺剣剤劣勧匹占即却及叫召吐含吹咲" "唐嘆噴圏坊執堅堤塔壁壊壱奇奥奴妙姓威娘婚寂寝尋尽尾屈峠峰巡巨帽幅幾床弐弾彩影彼征" "御微徴忙怒怖恋恐恒恥恵悩惑惨慎慢慮憶戒戯扇払扱抗抜抱抵押拍拓拠振捕掘描握援搬摘撃" @@ -49,7 +49,7 @@ "薪被襲触訴詰詳誇誉謡豪販賦贈越趣距跡跳踊踏躍軒較載輝輩込迎迫逃透途遅違遣避郎釈鈍" "鉛鋭鎖鑑闘陣陰隠隣隷雄雅雌離雷需震霧露響項頼飾駆騒驚髪鬼鮮麗黙鼓齢"))) -(defonce LEVEL-03 +(def level-03 (set (str "乏乙了企伏伐伴伸佳侍促倣倹偶催債克免冗冠凍凝刑削励勘募匠匿卑卓卸厘又双吉吏哀哲啓" "喚喫嘱坑埋塊塗墜墨墳墾壇奉契奪如妨姫娯婆婿嫁嬢孔孤宴審寿封尿岳峡崩巧帆帝幻幽廉廊" "弧彫徐忌怠怪恨悔悟悦惜愚慈慌慕慨慰憂憎憩房抑択抽拘掃掌排掛控措掲揚換揺携搾摂撮擁" @@ -59,7 +59,7 @@ "辛辱逮遂遇遭遵邦邪郊郭酔酵鋳錠錬錯鍛鎮鐘閲阻陪陳陵陶隆随隔隻雇零霊顧飽餓駐騎髄魂" "魅魔鯨鶏"))) -(defonce LEVEL-02-PRE +(def level-02-pre (set (str "且丙亜享亭仙伯但併侮侯俊俸倫偏偵偽傑傘僕僚儒償充准凸凹刃剖剛剰劾勅勲升厄叔叙吟呈" "呉唆唇唯喝喪嗣嚇囚坪垣培堀堕堪塀塁塑塚塾壌壮奔奨妃妄妊妥姻娠媒嫌嫡宜宰宵寛寡寧寮" "尉尚尼履屯岬崇帥幣庶庸廃廷弊弔弦彰循徹忍恭悠患悼惰愁愉慶憤憾懇懐懲懸戻扉扶抄把披" @@ -70,14 +70,14 @@ "賄賓賜賠購践軟轄迅迭逐逓逝逸遍遮遷還邸酌酢酪酬酷醜醸釣鈴鉢銃銘閑閥附陥隅雰霜靴韻" "頑頒頻顕飢駄騰麻"))) -(defonce LEVEL-02 +(def level-02 (set (str "串丼乞亀伎侶俺傲僅冥冶凄刹剥勃勾匂叱呂呪咽哺唄唾喉喩嗅嘲堆塞填妖妬嫉宛尻崖嵐巾弄" "弥彙怨恣惧慄憧憬戚戴拉拭拳拶挨挫捉捗捻摯斑斬旦旺昧曖曽枕柵柿桁梗椅椎楷毀氾汎汰沃" "沙淫湧溺潰煎爪爽牙狙玩瑠璃璧瓦畏畿痕痩瘍眉睦瞭瞳稽窟箋箸籠綻緻罵羞羨肘股脇脊腎腫" "腺膝膳臆臼舷艶芯苛萎葛蓋蔑蔽藍藤虎虹蜂蜜袖裾訃詣詮誰諦諧謎貌貪貼賂賭踪蹴辣遜遡那" "酎醒采釜錦錮鍋鍵鎌闇隙韓頃須頓頬顎餅餌駒骸鬱鶴麓麺"))) -(defonce LEVEL-01-PRE +(def level-01-pre (set (str "丑丞乃之乍乎乘也亂云亘亙些亞亥亦亨亮什仇仔伊伍伶伽佃佑佛佼侃來俄俠俣俱倂倖倦倭假" "偓偲傭傳僑僞價僻儉儘儲允兇兎兒兜兩其册冴凌凧凪凰凱函剃剩劃劉劍劑劫勞勳勵勸勺勿匁" "匙匝匡匪區卜卦卯卷卽卿厨厩厭參叉叛叡叢叩只叶吃吊吋吞吠吻吾呆咳哉哨哩啄啐啞喋喧喬" @@ -110,7 +110,7 @@ "龍龜龝欄廊朗虜殺類隆塚晴猪益神祥福靖精羽諸都飯飼館侮僧免勉勤卑喝嘆器塀墨層悔慨憎" "懲敏既暑梅海渚漢煮琢碑社祉祈祐祖祝禍禎穀突節練繁署者臭著褐視謁謹賓贈逸難響頻"))) -(defonce LEVEL-01 +(def level-01 (set (str "乂几匕匚丫于兀孑孒尸已幺弋丐亢仂仄仆仍卅夬夭尹弌弖戈扎曰毋丕丱仗仞仟册刋匆卉卮叨" "叭叮叺圦夲孕屶弍戉朮艾辷价伉冱凩刎刔匈卍吁夸奸屹幵忖戌戍扛扞扠扣扨收朶朸朿汕犲聿" "艸芒阡羽估佇佗佚佛佝佞兌冏刪劬劭匣吝吩听吭吮吶吼吽呎呏圻址坎坏壯夾妝妣孚孛尨屁岌" diff --git a/test/ca/fosskers/kanji/levels_test.clj b/test/ca/fosskers/kanji/levels_test.clj index de8af56..54031e6 100644 --- a/test/ca/fosskers/kanji/levels_test.clj +++ b/test/ca/fosskers/kanji/levels_test.clj @@ -4,40 +4,40 @@ [clojure.set :as s])) (deftest list-lengths - (is (= 80 (count kl/LEVEL-10))) - (is (= 160 (count kl/LEVEL-09))) - (is (= 200 (count kl/LEVEL-08))) - (is (= 202 (count kl/LEVEL-07))) - (is (= 193 (count kl/LEVEL-06))) - (is (= 191 (count kl/LEVEL-05))) - (is (= 313 (count kl/LEVEL-04))) - (is (= 284 (count kl/LEVEL-03))) - (is (= 328 (count kl/LEVEL-02-PRE))) - (is (= 185 (count kl/LEVEL-02))) - (is (= 1238 (count kl/LEVEL-01-PRE))) - (is (= 2928 (count kl/LEVEL-01)))) + (is (= 80 (count kl/level-10))) + (is (= 160 (count kl/level-09))) + (is (= 200 (count kl/level-08))) + (is (= 202 (count kl/level-07))) + (is (= 193 (count kl/level-06))) + (is (= 191 (count kl/level-05))) + (is (= 313 (count kl/level-04))) + (is (= 284 (count kl/level-03))) + (is (= 328 (count kl/level-02-pre))) + (is (= 185 (count kl/level-02))) + (is (= 1238 (count kl/level-01-pre))) + (is (= 2928 (count kl/level-01)))) ;; PRE-1 and 1 have 396 known overlaps. (deftest no-overlap - (is (empty? (s/intersection kl/LEVEL-10 kl/LEVEL-09))) - (is (empty? (s/intersection kl/LEVEL-09 kl/LEVEL-08))) - (is (empty? (s/intersection kl/LEVEL-08 kl/LEVEL-07))) - (is (empty? (s/intersection kl/LEVEL-07 kl/LEVEL-06))) - (is (empty? (s/intersection kl/LEVEL-06 kl/LEVEL-05))) - (is (empty? (s/intersection kl/LEVEL-05 kl/LEVEL-04))) - (is (empty? (s/intersection kl/LEVEL-04 kl/LEVEL-03))) - (is (empty? (s/intersection kl/LEVEL-03 kl/LEVEL-02-PRE))) - (is (empty? (s/intersection kl/LEVEL-02-PRE kl/LEVEL-02))) - (is (empty? (s/intersection kl/LEVEL-02 kl/LEVEL-01-PRE)))) + (is (empty? (s/intersection kl/level-10 kl/level-09))) + (is (empty? (s/intersection kl/level-09 kl/level-08))) + (is (empty? (s/intersection kl/level-08 kl/level-07))) + (is (empty? (s/intersection kl/level-07 kl/level-06))) + (is (empty? (s/intersection kl/level-06 kl/level-05))) + (is (empty? (s/intersection kl/level-05 kl/level-04))) + (is (empty? (s/intersection kl/level-04 kl/level-03))) + (is (empty? (s/intersection kl/level-03 kl/level-02-pre))) + (is (empty? (s/intersection kl/level-02-pre kl/level-02))) + (is (empty? (s/intersection kl/level-02 kl/level-01-pre)))) (deftest jouyou - (is (= 2136 (count (s/union kl/LEVEL-10 - kl/LEVEL-09 - kl/LEVEL-08 - kl/LEVEL-07 - kl/LEVEL-06 - kl/LEVEL-05 - kl/LEVEL-04 - kl/LEVEL-03 - kl/LEVEL-02-PRE - kl/LEVEL-02))))) + (is (= 2136 (count (s/union kl/level-10 + kl/level-09 + kl/level-08 + kl/level-07 + kl/level-06 + kl/level-05 + kl/level-04 + kl/level-03 + kl/level-02-pre + kl/level-02))))) -- 2.45.2