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 +4 -4
- data/MANUAL.rdoc +9 -12
- data/lib/sanzang/platform.rb +7 -7
- data/lib/sanzang/translation_table.rb +6 -4
- data/lib/sanzang/translator.rb +2 -1
- data/lib/sanzang/version.rb +1 -1
- data/test/tc_simple_translation.rb +4 -4
- data/test/utf-8/stage_3.txt +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 681ecd0867d5627edb42f6382642cc0840cf1c9f
|
4
|
+
data.tar.gz: 0f21e00fe6951814816d10ab13e6084537565298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea7c5c63dd221190f739dd087044aa4c4f9b9ce2f64062c5b3cb12cf89d045c69415c2411fb6aa1391cdde45af3c5be970d0510ee12c121d3d5e0907fe19fb59
|
7
|
+
data.tar.gz: dcbbf6fa87912f41054b6f6af0cd9a9a7fd7b03e042067dfe8788c4366dfd4a4a2ef41a858ac8818c80e4ddd00faa90a8cd60918668f49dd664c90be31cb320e
|
data/MANUAL.rdoc
CHANGED
@@ -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
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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:
|
data/lib/sanzang/platform.rb
CHANGED
@@ -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(
|
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(
|
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(
|
86
|
+
IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
|
87
87
|
elsif File.executable?("/usr/sbin/lsdev")
|
88
|
-
IO.popen(
|
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(
|
90
|
+
IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
|
91
91
|
elsif File.executable?("/usr/sbin/sysctl")
|
92
|
-
IO.popen(
|
92
|
+
IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
|
93
93
|
elsif File.executable?("/sbin/sysctl")
|
94
|
-
IO.popen(
|
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!(
|
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
|
data/lib/sanzang/translator.rb
CHANGED
@@ -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
|
data/lib/sanzang/version.rb
CHANGED
@@ -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
|
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
|
|
data/test/utf-8/stage_3.txt
CHANGED
@@ -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
|
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:
|
11
|
+
date: 2014-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|