Skip to content

Commit

Permalink
Kangxi radical
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoHao committed Sep 21, 2022
0 parents commit 99439f9
Show file tree
Hide file tree
Showing 4 changed files with 140,897 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 汉字部首数据 / 漢字部首資料<br>Hanzi Radical Data

## License

* `code/`: MIT license.
* `data/`: various.
* `data/unicode/`: [Unicode term of use](https://www.unicode.org/copyright.html) and [Unicode license agreement for data files and software](https://www.unicode.org/license.txt).
* `out/`: public domain.
20 changes: 20 additions & 0 deletions code/kangxi-radical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python3

import csv

result = []

for line in open('data-src/unihan/Unihan_RadicalStrokeCounts.txt').readlines():
line = line.strip()
if not len(line) or line[0] == '#':
continue
unicodeHex, prop, value = line.split('\t')
if prop == 'kRSKangXi':
radical, stroke = value.split('.')
radical = int(radical)
unicode = int(unicodeHex[2:], 16)
result.append((chr(unicode), chr(0x2f00 + radical - 1), unicodeHex, unicode, radical, stroke))

writer = csv.writer(open('out/kangxi.csv', 'w'))
writer.writerow(('Character','Kangxi Radical Character', 'Unicode (hex)', 'Unicode (dec)', 'Kangxi Radical Index', 'Kangxi Stroke'))
writer.writerows(result)
Loading

0 comments on commit 99439f9

Please sign in to comment.