Class: CBETA::P5aChecker

Inherits:
Object
  • Object
show all
Includes:
CbetaShare
Defined in:
lib/cbeta/p5a_checker.rb

Overview

檢查 CBETA XML P5a

  • 錯誤類型

    • E01

      行號重複

    • E02

      文字直接出現在 div 下

    • E03

      星號校勘 app 沒有對應的 note

    • E04

      rdg 缺少 wit 屬性“

    • E05

      圖檔 不存在

    • E06

      lb format error

    • E07

      lem 缺少 wit 屬性

    • E08

      item 下有多個 list

    • E09

      table cols 屬性值錯誤

    • E10

      不應直接出現在 list 下

  • 警告類型

    • W01

      夾注包夾注

    • W02

      出現罕用字元

Instance Method Summary collapse

Methods included from CbetaShare

#each_canon, #to_html

Constructor Details

#initialize(xml_root: nil, figures: nil, log: nil) ⇒ P5aChecker

Returns a new instance of P5aChecker.

Parameters:

  • xml_root (String) (defaults to: nil)

    來源 CBETA XML P5a 路徑

  • figures (String) (defaults to: nil)

    插圖 路徑 (可由 github.com/cbeta-git/CBR2X-figures 取得)

  • log (String) (defaults to: nil)

    Log file path



25
26
27
28
29
30
31
32
# File 'lib/cbeta/p5a_checker.rb', line 25

def initialize(xml_root: nil, figures: nil, log: nil)
  @gaijis = CBETA::Gaiji.new
  @xml_root = xml_root
  @figures = figures
  @log = log
  @errors = ''
  @g_errors = {}
end

Instance Method Details

#checkObject

檢查全部 CBETA XML P5a

Examples:

CBETA::P5aChecker.new(
  xml_root: '~/git-repos/cbeta-xml-p5a', 
  figures: '~/git-repos/CBR2X-figures', 
  log: '~/log/check-cbeta-xml.log'
).check


41
42
43
44
45
46
47
48
49
50
# File 'lib/cbeta/p5a_checker.rb', line 41

def check
  puts "xml: #{@xml_root}"
  each_canon(@xml_root) do |c|
    @canon = c
    path = File.join(@xml_root, @canon)
    handle_canon(path)
  end

  display_errors
end

#check_canon(canon) ⇒ Object

檢查某部藏經

Parameters:

  • canon (String)

    藏經 ID, example: “T”



54
55
56
57
58
59
# File 'lib/cbeta/p5a_checker.rb', line 54

def check_canon(canon)
  @canon = canon
  path = File.join(@xml_root, @canon)
  handle_canon(path)
  display_errors
end

#check_file(fn) ⇒ Object

檢查單一檔案

Examples:

CBETA::P5aChecker.new(
  figures: '~/git-repos/CBR2X-figures',
  log: '~/log/check-cbeta-xml.log'
).check_file('~/git-repos/cbeta-xml-p5a/A/A110/A110n1490.xml')


77
78
79
80
# File 'lib/cbeta/p5a_checker.rb', line 77

def check_file(fn)
  handle_file(fn)
  display_errors
end

#check_vol(vol) ⇒ Object

檢查某一冊

Parameters:

  • vol (String)

    冊號, example: “T01”



63
64
65
66
67
68
69
# File 'lib/cbeta/p5a_checker.rb', line 63

def check_vol(vol)
  @vol = vol
  @canon = CBETA.get_canon_from_vol(vol)
  path = File.join(@xml_root, @canon, vol)
  handle_vol(path)
  display_errors
end