cbeta 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cbeta/gaiji.rb +7 -2
- data/lib/cbeta/unicode_service.rb +19 -0
- data/lib/cbeta.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6371fac001d191b3245ba02d1b3287cedfe46213bea091d9259d9d24c2454b7
|
4
|
+
data.tar.gz: f71e61e1598462fd02fed5eb8e1c0111ee259d1b3bb85424ce869a9f0ea0dad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcc4e69ae85ef617ab214e489842d6c82a4c61fa7326c5f3d9ada35f49e71b602bb4f7c4153aeb9e3aa5c978a52ac19cc926842ea2535e6518b4c518e80f274a
|
7
|
+
data.tar.gz: 837dc5642b1285cf602a66572908d0ac4b3b3a32e7a509ee1c19337ea5f9363b3cbf9b1d59cab65565f45dd39808eff511383521c633ecc08fe480c9c360a6bb
|
data/lib/cbeta/gaiji.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'unihan2'
|
2
3
|
|
3
4
|
# 存取 CBETA 缺字資料庫
|
4
5
|
class CBETA::Gaiji
|
5
6
|
|
6
7
|
# 載入 CBETA 缺字資料庫
|
7
8
|
def initialize
|
9
|
+
@us = CBETA::UnicodeService.new
|
8
10
|
folder = File.join(File.dirname(__FILE__), '../data')
|
9
11
|
fn = File.join(folder, 'cbeta_gaiji.json')
|
10
12
|
@gaijis = JSON.parse(File.read(fn))
|
@@ -73,9 +75,12 @@ class CBETA::Gaiji
|
|
73
75
|
|
74
76
|
if gid.start_with? 'CB'
|
75
77
|
cb_priority.each do |k|
|
76
|
-
|
78
|
+
case k
|
79
|
+
when 'PUA'
|
77
80
|
return CBETA.pua(gid)
|
78
|
-
|
81
|
+
when 'uni_char', 'norm_uni_char'
|
82
|
+
return g[k] if @us.level2?(g[k])
|
83
|
+
else
|
79
84
|
return g[k] unless g[k].empty?
|
80
85
|
end
|
81
86
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CBETA::UnicodeService
|
2
|
+
def initialize
|
3
|
+
@u2 = Unihan2.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def level1?(code)
|
7
|
+
return false if code.nil?
|
8
|
+
# Unicode 3.0 以內 在 mobile 可以正確顯示
|
9
|
+
v = @u2.ver(code)
|
10
|
+
raise "Unihan2.ver 回傳 nil, code: #{code}" if v.nil?
|
11
|
+
v <= 3
|
12
|
+
end
|
13
|
+
|
14
|
+
def level2?(code)
|
15
|
+
return false if code.nil?
|
16
|
+
# Unicode 10 以內 在 desktop 有字型可以顯示
|
17
|
+
@u2.ver(code) <= 10
|
18
|
+
end
|
19
|
+
end
|
data/lib/cbeta.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbeta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Chou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby gem for use Chinese Buddhist Text resources made by CBETA (http://www.cbeta.org).
|
14
14
|
email: zhoubx@gmail.com
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/cbeta/p5a_to_simple_html.rb
|
32
32
|
- lib/cbeta/p5a_to_text.rb
|
33
33
|
- lib/cbeta/p5a_validator.rb
|
34
|
+
- lib/cbeta/unicode_service.rb
|
34
35
|
- lib/cbeta/xml_document.rb
|
35
36
|
- lib/data/canons.csv
|
36
37
|
- lib/data/categories.json
|