cbeta 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcf9ef4eadd1b7188ce702525779f72776bf2fc1
4
- data.tar.gz: 2ae5aabed92d18399607e6a6c8c88f80e5a0e5e1
3
+ metadata.gz: 6092b53e41c7b3b5349f07190489bae0c46d97ec
4
+ data.tar.gz: b55ea721ae79a3f5216a83948852ef77af6b8ebf
5
5
  SHA512:
6
- metadata.gz: e644a266bf3184b172e2cd342e064d9069dd38277d09bce36a408ac1230c2dccba89783bd32b011324f3fe9ae61d7a70c62f69787bb565e9e3759b5e8109b9ac
7
- data.tar.gz: a25c3f6c86459fe60f7521c11313076dfd6592758472309cf6c02506863bdf5da336627ccbc2f8f405d74b82cd1a757c9d13e5a1c06bfa899dca6da58509a970
6
+ metadata.gz: 6464971bec0dae90891e6959b390bea68b263181b8e7289349e9e8cbdb013912a3788996ef33e3f05df61d8464329e41ea7f6e75136339f22ae86fdcca6e649c
7
+ data.tar.gz: ce8f46383e2616d971b2127854115e75b78a672acc509c700d78c45ca40209e3b66893220881f56fc1914f0316968b24551f9c506109b27e1e2128de5723ba91
@@ -0,0 +1,23 @@
1
+ id,chinese_name,english_name,nickname,abbreviation,editor,publish_place,publish_date
2
+ T,大正新脩大藏經,Taishō Tripiṭaka,大正藏,【大】,大正新修大藏經刊行會,東京: 大藏出版株式會社,1988
3
+ X,卍新纂大日本續藏經,Manji Shinsan Dainihon Zokuzōkyō,新纂卍續藏,【卍續】,河村照孝,東京: 株式會社國書刊行會,1975-1989
4
+ R,卍續藏經-新文豐版,Manji Zokuzōkyō - Xinwenfeng Edition,卍續藏,,,京都.藏經書院 原刊 / 台北: 新文豐,1994
5
+ Z,卍大日本續藏經,Manji Dainihon Zokuzōkyō,,,,京都: 藏經書院,1905-1912
6
+ J,嘉興大藏經-新文豐版,Jiaxing Canon - Xinwenfeng Edition,嘉興藏,【嘉興】,,徑山藏版版藏 / 台北: 新文豐,1987
7
+ H,正史佛教資料類編,Passages concerning Buddhism from the Official Histories,正史,【正史】,杜斗城,蘭州: 甘肅文化出版社,2006
8
+ W,藏外佛教文獻,Buddhist Texts not contained in the Tripiṭaka,藏外,【藏外】,方廣錩,北京: 宗教文化出版社,1995-2003
9
+ I,北朝佛教石刻拓片百品,Selections of Buddhist Stone Rubbings from the Northern Dynasties,佛拓,,顏娟英,台北: 中央研究院歷史語言研究所,2008
10
+ F,房山石經,Fangshan shijing,,【房山】,中國佛教圖書文物館,北京: 華夏出版社,2000
11
+ A,趙城金藏,Jin Edition of the Canon,趙城藏,【金藏】,,北京: 北京圖書館出版社,2008
12
+ K,高麗大藏經,Tripiṭaka Koreana,高麗藏,【麗】,,高麗大藏經完刊推進委員會 原刊 / 台北: 新文豐,1982
13
+ Q,磧砂大藏經-新文豐版,Qisha Edition of the Canon - Xinwenfeng Edition,磧砂藏,【磧砂】,延聖院大藏經局,台北: 新文豐,1987
14
+ S,宋藏遺珍-新文豐版,Songzang yizhen - Xinwenfeng Edition,,【宋遺】,範成,台北: 新文豐,1978
15
+ U,洪武南藏,Southern Hongwu Edition of the Canon,初刻南藏,【洪武】,,成都: 四川省佛教協會,1999
16
+ N,永樂南藏,Southern Yongle Edition of the Canon,再刻南藏,【南藏】,,,
17
+ P,永樂北藏,Northern Yongle Edition of the Canon,北藏,【北藏】,永樂北藏整理委員會,北京: 線裝書局,2000
18
+ L,乾隆大藏經-新文豐版,Qianlong Edition of the Canon - Xinwenfeng Edition,清藏、龍藏、乾隆藏,【龍】,,台北: 新文豐,1991
19
+ M,卍正藏經-新文豐版,Manji Daizōkyō - Xinwenfeng Edition,卍正藏,【卍正】,,京都.藏經書院 原刊 / 台北: 新文豐,1980
20
+ G,佛教大藏經,Fojiao Canon,,【佛教】,佛教書局,台北: 佛教書局,1978
21
+ B,大藏經補編,Supplement to the Dazangjing,,【補編】,藍吉富,台北: 華宇出版社,1985
22
+ C,中華大藏經-中華書局版,Zhonghua Canon - Zhonghua shuju Edition,中華藏,【中華】,中華大藏經編輯局,北京: 中華書局,1984-1997
23
+ ,中研院史語所的修訂用字,,,【史】,,,
@@ -3,7 +3,33 @@
3
3
  #
4
4
  # 存取 CBETA 資源的 Ruby 工具
5
5
 
6
+ require 'csv'
7
+
6
8
  class CBETA
9
+ # 載入藏經資料
10
+ def initialize()
11
+ fn = File.join(File.dirname(__FILE__), 'canons.csv')
12
+ text = File.read(fn)
13
+ @canon_abbr = {}
14
+ CSV.parse(text, :headers => true) do |row|
15
+ next if row['abbreviation'].nil?
16
+ next if row['abbreviation'].empty?
17
+ @canon_abbr[row['id']] = row['abbreviation']
18
+ end
19
+ end
20
+
21
+ # 取得藏經略符
22
+ #
23
+ # @param id [String] 藏經 ID, 例如大正藏的 ID 是 "T"
24
+ # @return [String] 藏經略符,例如 "【大】"
25
+ #
26
+ # @example
27
+ # cbeta = CBETA.new
28
+ # cbeta.get_canon_abbr('T') # return "【大】"
29
+ def get_canon_abbr(id)
30
+ return nil unless @canon_abbr.key? id
31
+ @canon_abbr[id]
32
+ end
7
33
  end
8
34
  require 'cbeta/gaiji'
9
35
  require 'cbeta/bm_to_text'
@@ -8,7 +8,7 @@ class CBETA::Gaiji
8
8
  @gaijis = JSON.parse(File.read(fn))
9
9
  end
10
10
 
11
- # 傳入,傳回 hash 缺字資訊
11
+ # 取得缺字資訊
12
12
  #
13
13
  # @param cb [String] 缺字 CB 碼
14
14
  # @return [Hash{String => Strin, Array<String>}] 缺字資訊
@@ -31,6 +31,8 @@ class CBETA::Gaiji
31
31
 
32
32
  # 傳入缺字 CB 碼,傳回注音 array
33
33
  #
34
+ # 資料來源:CBETA 於 2015.5.15 提供的 MS Access 缺字資料庫
35
+ #
34
36
  # @param cb [String] 缺字 CB 碼
35
37
  # @return [Array<String>]
36
38
  #
@@ -11,7 +11,7 @@ PASS=['back', 'teiHeader']
11
11
  # 某版用字缺的符號
12
12
  MISSING = '-'
13
13
 
14
- # 處理 CBETA XML P5a
14
+ # Convert CBETA XML P5a to HTML
15
15
  #
16
16
  # CBETA XML P5a 可由此取得: https://github.com/cbeta-git/xml-p5a
17
17
  #
@@ -23,6 +23,7 @@ class CBETA::P5aToHTML
23
23
  def initialize(xml_root, out_root)
24
24
  @xml_root = xml_root
25
25
  @out_root = out_root
26
+ @cbeta = CBETA.new
26
27
  @gaijis = CBETA::Gaiji.new
27
28
 
28
29
  # 載入 unicode 1.1 字集列表
@@ -121,7 +122,7 @@ class CBETA::P5aToHTML
121
122
  cell['rowspan'] = e['rows'] if e.key? 'rows'
122
123
  cell['colspan'] = e['cols'] if e.key? 'cols'
123
124
  cell.inner_html = traverse(e)
124
- cell.to_xml(:encoding => 'UTF-8')
125
+ to_html(cell)
125
126
  end
126
127
 
127
128
  def handle_collection(c)
@@ -288,7 +289,7 @@ class CBETA::P5aToHTML
288
289
  end
289
290
  @first_l = false
290
291
  end
291
- r = cell.to_s
292
+ r = to_html(cell)
292
293
 
293
294
  unless @lg_row_open
294
295
  r = "\n<div class='lg-row'>" + r
@@ -356,7 +357,7 @@ class CBETA::P5aToHTML
356
357
  node.inner_html += '</div><!-- end of lg -->'
357
358
  @lg_row_open = false
358
359
  end
359
- r = "\n" + node.to_s
360
+ r = "\n" + to_html(node)
360
361
  end
361
362
  r
362
363
  end
@@ -597,11 +598,10 @@ eos
597
598
 
598
599
  def handle_vol(vol)
599
600
  puts "convert volumn: #{vol}"
600
- if vol.start_with? 'T'
601
- @orig = "【大】"
602
- else
603
- abort "未處理底本"
604
- end
601
+
602
+ @orig = @cbeta.get_canon_abbr(vol[0])
603
+ abort "未處理底本" if @orig.nil?
604
+
605
605
  @vol = vol
606
606
  @series = vol[0]
607
607
  @out_folder = File.join(@out_root, @series, vol)
@@ -700,6 +700,10 @@ eos
700
700
  text
701
701
  end
702
702
 
703
+ def to_html(e)
704
+ e.to_xml(encoding: 'UTF-8', :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
705
+ end
706
+
703
707
  def traverse(e, mode='html')
704
708
  r = ''
705
709
  e.children.each { |c|
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: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Chou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-06-10 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
@@ -16,6 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - lib/canons.csv
19
20
  - lib/cbeta.rb
20
21
  - lib/cbeta/bm_to_text.rb
21
22
  - lib/cbeta/gaiji.json
@@ -48,3 +49,4 @@ signing_key:
48
49
  specification_version: 4
49
50
  summary: CBETA Tools
50
51
  test_files: []
52
+ has_rdoc: