unihan_lang 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.md +24 -0
- data/README.ja.md +85 -0
- data/README.md +54 -23
- data/lib/unihan_lang/chinese_processor.rb +12 -16
- data/lib/unihan_lang/version.rb +1 -1
- data/lib/unihan_lang.rb +0 -1
- data/unihan_lang.gemspec +2 -2
- metadata +7 -8
- data/data/traditional_chinese_list.txt +0 -6017
- data/test.rb +0 -58
- data/traditional_characters.txt +0 -0
data/test.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# rubocop:disable all
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
|
|
4
|
-
require "unihan_lang"
|
|
5
|
-
|
|
6
|
-
unihan = UnihanLang::Unihan.new
|
|
7
|
-
|
|
8
|
-
test_cases = %w(
|
|
9
|
-
繁體字
|
|
10
|
-
简体字
|
|
11
|
-
日本語
|
|
12
|
-
中文
|
|
13
|
-
漢字
|
|
14
|
-
汉字
|
|
15
|
-
東京
|
|
16
|
-
北京
|
|
17
|
-
台北
|
|
18
|
-
ひらがな
|
|
19
|
-
カタカナ
|
|
20
|
-
漢字とひらがな
|
|
21
|
-
こんにちは世界
|
|
22
|
-
你好世界
|
|
23
|
-
你好世界
|
|
24
|
-
實際的例子
|
|
25
|
-
实际的例子
|
|
26
|
-
現実の例
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
test_cases.each do |word|
|
|
30
|
-
puts "\nTesting '#{word}':"
|
|
31
|
-
puts "zh_tw?: #{unihan.zh_tw?(word)}"
|
|
32
|
-
puts "zh_cn?: #{unihan.zh_cn?(word)}"
|
|
33
|
-
puts "ja?: #{unihan.ja?(word)}"
|
|
34
|
-
puts "Language: #{unihan.determine_language(word)}"
|
|
35
|
-
puts "Character details:"
|
|
36
|
-
word.each_char do |char|
|
|
37
|
-
print "#{char}: "
|
|
38
|
-
chinese_processor = unihan.instance_variable_get(:@chinese_processor)
|
|
39
|
-
japanese_processor = unihan.instance_variable_get(:@japanese_processor)
|
|
40
|
-
in_zh_tw = chinese_processor.zh_tw.include?(char)
|
|
41
|
-
in_zh_cn = chinese_processor.zh_cn.include?(char)
|
|
42
|
-
in_common = chinese_processor.common.include?(char)
|
|
43
|
-
is_chinese = chinese_processor.chinese?(char)
|
|
44
|
-
is_japanese = japanese_processor.japanese?(char.to_s)
|
|
45
|
-
is_kana = char =~ /[\p{Hiragana}\p{Katakana}ー]/
|
|
46
|
-
print "ZH_TW " if in_zh_tw
|
|
47
|
-
print "ZH_CN " if in_zh_cn
|
|
48
|
-
print "Common " if in_common
|
|
49
|
-
print "Chinese " if is_chinese
|
|
50
|
-
print "Japanese " if is_japanese
|
|
51
|
-
print "KANA " if is_kana
|
|
52
|
-
if !in_zh_tw && !in_zh_cn && !in_common && !is_chinese && !is_japanese && !is_kana
|
|
53
|
-
print "UNKNOWN"
|
|
54
|
-
end
|
|
55
|
-
puts
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
# rubocop:enable all
|
data/traditional_characters.txt
DELETED
|
File without changes
|