1
0
mirror of https://github.com/KanjiVG/kanjivg.git synced 2026-04-20 04:20:44 +02:00

Add an index and a file which generates it

This commit is contained in:
Ben Bullock
2023-02-07 16:14:32 +09:00
parent 8bf00d54ad
commit b6f7ab58be
2 changed files with 25279 additions and 0 deletions

25248
kvg-index.json Normal file

File diff suppressed because it is too large Load Diff

31
make-index.pl Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env perl
use warnings;
use strict;
use utf8;
use FindBin '$Bin';
use v5.32;
no warnings qw(experimental::signatures);
use feature qw(signatures say);
# Requires install. cpanm JSON::Create
use JSON::Create 'write_json';
my %index;
my @files = <$Bin/kanji/*.svg>;
for my $file (@files) {
my ($kanji, $ex) = file_to_kanji ($file);
if (! $kanji) {
next;
}
my $tfile = $file;
$tfile =~ s!.*/!!;
push @{$index{$kanji}}, $tfile;
}
write_json ("$Bin/kvg-index.json", \%index, indent => 1, sort => 1);
exit;
sub file_to_kanji ($file) {
if ($file !~ m!([0-9a-f]{5})(-.*)?\.svg!) {
warn "Could not get kanji from $file";
return (undef, undef);
}
return chr (hex ($1)), $2;
}