sanzang 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 988a94b60e0d495fa6acc7d549db71651c120ede
4
- data.tar.gz: d7ee8eea313da3675d0bf361187a28bf29b1d5d6
3
+ metadata.gz: 681ecd0867d5627edb42f6382642cc0840cf1c9f
4
+ data.tar.gz: 0f21e00fe6951814816d10ab13e6084537565298
5
5
  SHA512:
6
- metadata.gz: d87950bf395184c0cb2ac661810d97f07bf36669c7366c556850f9e85cf51f05280c817b2bafa3c37c9b0ba30dfcf895b91c9372d672bc654f5e4d8063cbb706
7
- data.tar.gz: 1df1b05c839c2f55ff0f85f96b08676ee9335c8a96aaf73cb137d0ff9963e4bd10c1401145c5959232d8e955d1f59d9572ddc1d781b846d42003a085c4b81375
6
+ metadata.gz: ea7c5c63dd221190f739dd087044aa4c4f9b9ce2f64062c5b3cb12cf89d045c69415c2411fb6aa1391cdde45af3c5be970d0510ee12c121d3d5e0907fe19fb59
7
+ data.tar.gz: dcbbf6fa87912f41054b6f6af0cd9a9a7fd7b03e042067dfe8788c4366dfd4a4a2ef41a858ac8818c80e4ddd00faa90a8cd60918668f49dd664c90be31cb320e
@@ -49,25 +49,22 @@ format is simple delimited text. At runtime, the translation rules in this file
49
49
  are applied to the source text to generate the translation listing.
50
50
 
51
51
  In a translation table text file, each line is a translation rule containing a
52
- source term and its equivalent meanings in other languages. Each line starts
53
- with "~|", has records delimited by "|", and ends with "|~". In the translation
54
- table, the first column represents the source language, while the subsequent
55
- columns represent destination languages. In this example, we want to create a
56
- table capable of rendering the following title into English:
52
+ source term and its equivalent meanings in other languages. Each rule has terms
53
+ separated by the "|" character. In the translation table, the first column
54
+ represents the source language, while subsequent columns represent destination
55
+ languages. In this example, we want to create a table capable of rendering the
56
+ following title into English:
57
57
 
58
58
  金剛般若波羅蜜經
59
59
 
60
60
  We start by creating a new text file, named _table.txt_, or something similar.
61
61
  In this text file, we may add the following rules:
62
62
 
63
- ~|波羅蜜| pāramitā|~
64
- ~|金剛| diamond|~
65
- ~|般若| prajñā|~
66
- ~|經| sūtra/classic|~
63
+ 波羅蜜|pāramitā
64
+ 金剛|diamond
65
+ 般若|prajñā
66
+ 經|sūtra/classic
67
67
 
68
- Notice that spaces were included prior to the English equivalents. This is
69
- because Chinese does not typically include spaces between words, so we need to
70
- insert our own leading spaces as part of the translation rules we are defining.
71
68
  After we have written this table file, we can then run the \Sanzang translation
72
69
  engine with our table. When it reads the Chinese title as the input text, it
73
70
  then produces the following translation listing:
@@ -75,23 +75,23 @@ module Sanzang::Platform
75
75
  elsif File.readable?("/proc/cpuinfo")
76
76
  IO.read("/proc/cpuinfo").scan(/^processor/).size
77
77
  elsif File.executable?("/usr/bin/hwprefs")
78
- IO.popen(%w[/usr/bin/hwprefs thread_count]).read.to_i
78
+ IO.popen("/usr/bin/hwprefs thread_count").read.to_i
79
79
  elsif File.executable?("/usr/sbin/psrinfo")
80
80
  IO.popen("/usr/sbin/psrinfo").read.scan(/^.*on-*line/).size
81
81
  elsif File.executable?("/usr/sbin/ioscan")
82
- IO.popen(%w[/usr/sbin/ioscan -kC processor]) do |out|
82
+ IO.popen("/usr/sbin/ioscan -kC processor") do |out|
83
83
  out.read.scan(/^.*processor/).size
84
84
  end
85
85
  elsif File.executable?("/usr/sbin/pmcycles")
86
- IO.popen(%w[/usr/sbin/pmcycles -m]).read.count("\n")
86
+ IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
87
87
  elsif File.executable?("/usr/sbin/lsdev")
88
- IO.popen(%w[/usr/sbin/lsdev -Cc processor -S 1]).read.count("\n")
88
+ IO.popen("/usr/sbin/lsdev -Cc processor -S 1").read.count("\n")
89
89
  elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /IRIX/i
90
- IO.popen(%w[/usr/sbin/sysconf NPROC_ONLN]).read.to_i
90
+ IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
91
91
  elsif File.executable?("/usr/sbin/sysctl")
92
- IO.popen(%w[/usr/sbin/sysctl -n hw.ncpu]).read.to_i
92
+ IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
93
93
  elsif File.executable?("/sbin/sysctl")
94
- IO.popen(%w[/sbin/sysctl -n hw.ncpu]).read.to_i
94
+ IO.popen("/sbin/sysctl -n hw.ncpu").read.to_i
95
95
  else
96
96
  nil
97
97
  end
@@ -42,10 +42,12 @@ module Sanzang
42
42
  def initialize(rules)
43
43
  contents = rules.kind_of?(String) ? rules : rules.read
44
44
  contents.encode!(Encoding::UTF_8)
45
- contents.strip!
46
- contents.gsub!(/^\s*|\s*$|\r/, "")
47
- contents.gsub!("~|", "")
48
- contents.gsub!("|~", "")
45
+ contents.strip! # Rm outside empty lines
46
+ contents.gsub!("~|", "") # Rm left delimiter
47
+ contents.gsub!("|~", "") # Rm right delimiter
48
+ contents.gsub!(/^\s*|\s*$|\r/, "") # Rm beginning & ending whitespace
49
+ contents.gsub!(/\s*\|\s*/, "|") # Rm whitespace around delimiters
50
+
49
51
  @records = contents.split("\n").collect {|r| r.split("|") }
50
52
 
51
53
  if @records.length < 1
@@ -57,8 +57,9 @@ module Sanzang
57
57
  1.upto(@table.width - 1) do |column_i|
58
58
  translation = String.new(source_text)
59
59
  vocab_terms.each do |term|
60
- translation.gsub!(term[0], term[column_i])
60
+ translation.gsub!(term[0], "\0#{term[column_i]}\0")
61
61
  end
62
+ translation.gsub!(/\0+/, " ")
62
63
  text_collection << translation
63
64
  end
64
65
  text_collection
@@ -19,6 +19,6 @@ module Sanzang
19
19
 
20
20
  # Current version number of Sanzang
21
21
  #
22
- VERSION = "1.0.9"
22
+ VERSION = "1.1.0"
23
23
 
24
24
  end
@@ -27,13 +27,13 @@ class TestSanzang < Test::Unit::TestCase
27
27
 
28
28
  def stage_3
29
29
  "[1.1]     大唐三藏法師玄奘奉\r\n" \
30
- << "[1.2]      dà táng sānzàng fǎshī xuánzàng fèng\r\n" \
30
+ << "[1.2]      dà táng sānzàng fǎshī xuánzàng fèng \r\n" \
31
31
  << "[1.3]      great tang tripiṭaka dharma-master xuanzang " \
32
- << "reverently\r\n" \
32
+ << "reverently \r\n" \
33
33
  << "\r\n" \
34
34
  << "[2.1]  詔譯\r\n" \
35
- << "[2.2]   zhào yì\r\n" \
36
- << "[2.3]   imperial-order translate/interpret\r\n" \
35
+ << "[2.2]   zhào yì \r\n" \
36
+ << "[2.3]   imperial-order translate/interpret \r\n" \
37
37
  << "\r\n"
38
38
  end
39
39
 
@@ -1,8 +1,8 @@
1
1
  [1.1]     大唐三藏法師玄奘奉
2
- [1.2]      dà táng sānzàng fǎshī xuánzàng fèng
3
- [1.3]      great tang tripiṭaka dharma-master xuanzang reverently
2
+ [1.2]      dà táng sānzàng fǎshī xuánzàng fèng
3
+ [1.3]      great tang tripiṭaka dharma-master xuanzang reverently
4
4
 
5
5
  [2.1]  詔譯
6
- [2.2]   zhào yì
7
- [2.3]   imperial-order translate/interpret
6
+ [2.2]   zhào yì
7
+ [2.3]   imperial-order translate/interpret
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanzang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lapis Lazuli Texts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-29 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel