cbeta 3.7.0 → 3.7.1
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
- checksums.yaml.gz.sig +0 -0
- data/lib/cbeta/p5a_checker.rb +22 -18
- data/lib/cbeta.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02f6421948b47e5d049f7e5a695b5c7b4b73519401e6bd13a24ba4e96b685eb3
|
|
4
|
+
data.tar.gz: 8f8bcd8c63d9dbc3b54aa9dfdd841b95b8819776c2a185ff04dee106ee3f538a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbb2320988bcccc49f6daf616a78ff7e64bffcb94fe989d6c68955952dce891bf79ec580e7911a0099b343c0aaf675b5f6cde189dc344a734a5848b46a4101d5
|
|
7
|
+
data.tar.gz: 6dd81d74d311de2e7339fa045a9a2e78b94710a47e2eb9e9ebe0108611401ce51c02d1dabe27b31fd0c6488ed0e2d3527311df0de5ceff64fba479ad7cb65c24
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/cbeta/p5a_checker.rb
CHANGED
|
@@ -17,6 +17,7 @@ require_relative 'cbeta_share'
|
|
|
17
17
|
# * [E12] note 直接出現在 lg 下
|
|
18
18
|
# * [E13] tt 直接出現在 lg 下
|
|
19
19
|
# * [E14] <anchor type="right"> 不應直接出現在 div 或 body 下
|
|
20
|
+
# * [E15] <note> corresp 無對應的 <note>
|
|
20
21
|
#
|
|
21
22
|
# * 警告類型
|
|
22
23
|
# * [W01] 夾注包夾注
|
|
@@ -33,7 +34,7 @@ class CBETA::P5aChecker
|
|
|
33
34
|
@xml_root = xml_root
|
|
34
35
|
@figures = figures
|
|
35
36
|
@log = log
|
|
36
|
-
@errors =
|
|
37
|
+
@errors = []
|
|
37
38
|
@g_errors = {}
|
|
38
39
|
end
|
|
39
40
|
|
|
@@ -118,17 +119,17 @@ class CBETA::P5aChecker
|
|
|
118
119
|
def display_errors
|
|
119
120
|
@g_errors.keys.sort.each do |k|
|
|
120
121
|
s = @g_errors[k].to_a.join(',')
|
|
121
|
-
@errors << "#{k} 無缺字資料,出現於:#{s}
|
|
122
|
+
@errors << "#{k} 無缺字資料,出現於:#{s}"
|
|
122
123
|
end
|
|
123
124
|
|
|
124
125
|
if @errors.empty?
|
|
125
126
|
puts "檢查完成,未發現錯誤。"
|
|
126
127
|
elsif @log.nil?
|
|
127
|
-
puts "
|
|
128
|
-
puts @errors
|
|
128
|
+
puts "發現 #{@errors.size} 錯誤:"
|
|
129
|
+
puts @errors.join("\n")
|
|
129
130
|
else
|
|
130
|
-
File.write(@log, @errors)
|
|
131
|
-
puts "
|
|
131
|
+
File.write(@log, @errors.join("\n"))
|
|
132
|
+
puts "發現 #{@errors.size} 錯誤,請查看 #{@log}"
|
|
132
133
|
end
|
|
133
134
|
end
|
|
134
135
|
|
|
@@ -197,13 +198,9 @@ class CBETA::P5aChecker
|
|
|
197
198
|
end
|
|
198
199
|
|
|
199
200
|
def e_note(e)
|
|
200
|
-
if e.parent.name == 'div'
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if e.parent.name == 'lg'
|
|
205
|
-
error "[E12] note 直接出現在 lg 下"
|
|
206
|
-
end
|
|
201
|
+
error "[E11] note 直接出現在 div 下" if e.parent.name == 'div'
|
|
202
|
+
error "[E12] note 直接出現在 lg 下" if e.parent.name == 'lg'
|
|
203
|
+
e_note_corresp(e) if e.key?('corresp')
|
|
207
204
|
|
|
208
205
|
unless e['place'] == 'inline'
|
|
209
206
|
traverse(e)
|
|
@@ -213,11 +210,18 @@ class CBETA::P5aChecker
|
|
|
213
210
|
if @element_stack.include?('inline_note')
|
|
214
211
|
error "[W01] 夾注包夾注"
|
|
215
212
|
end
|
|
213
|
+
|
|
216
214
|
@element_stack << 'inline_note'
|
|
217
215
|
traverse(e)
|
|
218
216
|
@element_stack.pop
|
|
219
217
|
end
|
|
220
218
|
|
|
219
|
+
def e_note_corresp(e)
|
|
220
|
+
n = e['corresp'].delete_prefix('#')
|
|
221
|
+
return if @notes.include?(n)
|
|
222
|
+
error "[E15] note corresp #{n} 無對應 note"
|
|
223
|
+
end
|
|
224
|
+
|
|
221
225
|
def e_p(e)
|
|
222
226
|
if e.parent.name == 'list'
|
|
223
227
|
error "[E10] p 不應直接出現在 list 下"
|
|
@@ -261,8 +265,8 @@ class CBETA::P5aChecker
|
|
|
261
265
|
end
|
|
262
266
|
|
|
263
267
|
def error(msg)
|
|
264
|
-
s = "#{msg}, #{@basename}, lb: #{@lb}
|
|
265
|
-
|
|
268
|
+
s = "#{msg}, #{@basename}, lb: #{@lb}"
|
|
269
|
+
puts "\n#{s}"
|
|
266
270
|
@errors << s
|
|
267
271
|
end
|
|
268
272
|
|
|
@@ -281,7 +285,7 @@ class CBETA::P5aChecker
|
|
|
281
285
|
|
|
282
286
|
s = File.read(fn)
|
|
283
287
|
if s.include? "\u200B"
|
|
284
|
-
@errors << "#{@basename} 含有 U+200B Zero Width Space
|
|
288
|
+
@errors << "#{@basename} 含有 U+200B Zero Width Space 字元"
|
|
285
289
|
end
|
|
286
290
|
|
|
287
291
|
doc = Nokogiri::XML(s)
|
|
@@ -292,7 +296,7 @@ class CBETA::P5aChecker
|
|
|
292
296
|
@element_stack = []
|
|
293
297
|
traverse(doc.root)
|
|
294
298
|
else
|
|
295
|
-
@errors << "錯誤: #{@basename} not well-formed
|
|
299
|
+
@errors << "錯誤: #{@basename} not well-formed"
|
|
296
300
|
end
|
|
297
301
|
end
|
|
298
302
|
|
|
@@ -315,7 +319,7 @@ class CBETA::P5aChecker
|
|
|
315
319
|
end
|
|
316
320
|
|
|
317
321
|
def handle_vol(folder)
|
|
318
|
-
|
|
322
|
+
print "\rcheck vol: #{File.basename(folder)} "
|
|
319
323
|
Dir.entries(folder).sort.each do |f|
|
|
320
324
|
next if f.start_with? '.'
|
|
321
325
|
path = File.join(folder, f)
|
data/lib/cbeta.rb
CHANGED
|
@@ -47,6 +47,8 @@ class CBETA
|
|
|
47
47
|
# @param lb[String] 例如 "0001a01" 或 "0757b29"
|
|
48
48
|
# @return [String] CBETA 行首資訊,例如 "T01n0001_p0001a01" 或 "T25n1510ap0757b29"
|
|
49
49
|
def self.get_linehead(file_basename, lb)
|
|
50
|
+
return nil if file_basename.nil?
|
|
51
|
+
|
|
50
52
|
if file_basename.match(/^(T\d\dn0220)/)
|
|
51
53
|
r = $1
|
|
52
54
|
else
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cbeta
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ray Chou
|
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
|
34
34
|
xyQse8slbARanDyyT6HCYtlaKD9WYw647tkJhyY2GniloCNcOJS0URvhlulLzJYg
|
|
35
35
|
9CrAxVAO2NMeM6tbxg1VjYbqopjoLCwLdAJouA==
|
|
36
36
|
-----END CERTIFICATE-----
|
|
37
|
-
date: 2025-
|
|
37
|
+
date: 2025-11-12 00:00:00.000000000 Z
|
|
38
38
|
dependencies:
|
|
39
39
|
- !ruby/object:Gem::Dependency
|
|
40
40
|
name: unihan2
|
metadata.gz.sig
CHANGED
|
Binary file
|