sanzang 1.0.0 → 1.0.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
- data/README +9 -7
- data/lib/sanzang/command/batch.rb +2 -0
- data/lib/sanzang/command/reflow.rb +16 -4
- data/lib/sanzang/command/translate.rb +2 -0
- data/lib/sanzang/translation_table.rb +6 -0
- data/lib/sanzang/translator.rb +15 -11
- data/lib/sanzang/version.rb +1 -1
- 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: e45b8e0b9f093af18eaa9f9cc4b2c670ea0eb044
|
4
|
+
data.tar.gz: cc4cbc73c335dd6d5e3294c3f6826bdb52877398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec8dbbc4bfeb9b6c1ec02e284e2274eb8941d7195cbb49bedf3080256d5239da5632350adeee111f776127a954c0ff555419895339557c8bcc633d82459da835
|
7
|
+
data.tar.gz: 3c941b3b382d93e9cc8036aeb6616d572e7f1e6f251e73c622e8212e655b5faf56e507a35d2bb335e92e1b52310263591534665dd14793dcba63c87ba8883386
|
data/README
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
\Sanzang is a compact and simple cross-platform machine translation system.
|
6
6
|
This program is especially useful for translating from CJK languages (Chinese,
|
7
|
-
|
7
|
+
Japanese, and Korean), and it is very suitable for ancient and otherwise
|
8
8
|
difficult texts. Due to its origins in translating texts from the Chinese
|
9
9
|
Buddhist canon, the program is called \Sanzang (三藏), a literal translation of
|
10
10
|
the Sanskrit word "Tripitaka," which is a general term for the Buddhist canon.
|
@@ -16,18 +16,20 @@ As demonstrated by the _sanzang_ program itself:
|
|
16
16
|
[1.3] tripiṭaka
|
17
17
|
|
18
18
|
Anyone can learn how to use \Sanzang, and use it to read and analyze texts.
|
19
|
-
Unlike most other systems, \Sanzang is small and approachable.
|
20
|
-
develop
|
21
|
-
file
|
19
|
+
Unlike most other systems, \Sanzang is small and approachable. Users can
|
20
|
+
develop their own translation rules, and these rules are simply stored in a
|
21
|
+
text file and applied at runtime.
|
22
22
|
|
23
23
|
\Sanzang is free software ("free as in freedom"), and it is released under the
|
24
24
|
GNU General Public License, version 3.
|
25
25
|
|
26
|
+
For full details on how to install and use \Sanzang, please see the MANUAL.
|
27
|
+
|
26
28
|
== Quick Install
|
27
29
|
|
28
30
|
To install \Sanzang, the prerequisite is Ruby 1.9 or later. After Ruby has been
|
29
|
-
installed, you can run the _gem_ command from a command shell to
|
30
|
-
download and install \Sanzang onto your computer.
|
31
|
+
installed, you can then run the _gem_ command from a command shell to
|
32
|
+
automatically download and install \Sanzang onto your computer.
|
31
33
|
|
32
34
|
# gem install sanzang
|
33
35
|
|
@@ -47,4 +49,4 @@ This command should show a summary of your platform for running \Sanzang.
|
|
47
49
|
Processors found: 4
|
48
50
|
Sanzang version: 1.0.0
|
49
51
|
|
50
|
-
You now have \Sanzang installed
|
52
|
+
You now have \Sanzang installed on your computer.
|
@@ -41,6 +41,19 @@ module Sanzang::Command
|
|
41
41
|
@outfile = nil
|
42
42
|
end
|
43
43
|
|
44
|
+
def valid_encodings
|
45
|
+
all_enc = Encoding.list.collect {|e| e.to_s }.sort do |x,y|
|
46
|
+
x.upcase <=> y.upcase
|
47
|
+
end
|
48
|
+
all_enc.find_all do |e|
|
49
|
+
begin
|
50
|
+
Encoding::Converter.search_convpath(e, Encoding::UTF_8)
|
51
|
+
rescue Encoding::ConverterNotFoundError
|
52
|
+
e == "UTF-8" ? true : false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
44
57
|
# Run the reflow command with the given arguments. The parameter _args_
|
45
58
|
# would typically be an array of command options and parameters. Calling
|
46
59
|
# this with the "-h" or "--help" option will print full usage information
|
@@ -75,6 +88,8 @@ module Sanzang::Command
|
|
75
88
|
return 0
|
76
89
|
rescue SystemExit => err
|
77
90
|
return err.status
|
91
|
+
rescue Errno::EPIPE => err
|
92
|
+
return 0
|
78
93
|
rescue Exception => err
|
79
94
|
$stderr.puts err.backtrace
|
80
95
|
$stderr.puts "\nERROR: #{err.inspect}\n\n"
|
@@ -116,10 +131,7 @@ module Sanzang::Command
|
|
116
131
|
@encoding = Encoding.find(v)
|
117
132
|
end
|
118
133
|
op.on("-L", "--list-encodings", "list possible encodings") do |v|
|
119
|
-
|
120
|
-
x.to_s.upcase <=> y.to_s.upcase
|
121
|
-
end
|
122
|
-
puts encodings
|
134
|
+
puts valid_encodings
|
123
135
|
exit 0
|
124
136
|
end
|
125
137
|
op.on("-i", "--infile=FILE", "read input text from FILE") do |v|
|
@@ -52,6 +52,12 @@ module Sanzang
|
|
52
52
|
rec.strip.gsub(left, "").gsub(right, "").split(separator)
|
53
53
|
end
|
54
54
|
|
55
|
+
if @records.length < 1
|
56
|
+
raise "Table must have at least 1 row"
|
57
|
+
elsif @records[0].length < 2
|
58
|
+
raise "Table must have at least 2 columns"
|
59
|
+
end
|
60
|
+
|
55
61
|
@width = records[0].length
|
56
62
|
0.upto(@records.length - 1) do |i|
|
57
63
|
if @records[i].length != @width
|
data/lib/sanzang/translator.rb
CHANGED
@@ -85,21 +85,25 @@ module Sanzang
|
|
85
85
|
end
|
86
86
|
|
87
87
|
# Read a text from _input_ and write its translation listing to _output_.
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
# them directly.
|
88
|
+
# If a parameter is a string, it is interpreted as the path to a file, and
|
89
|
+
# the relevant file is opened and used. Otherwise, the parameter is treated
|
90
|
+
# as an open IO object.
|
92
91
|
#
|
93
92
|
def translate_io(input, output)
|
94
|
-
if input.
|
95
|
-
|
93
|
+
if input.kind_of?(String)
|
94
|
+
io_in = File.open(input, "rb", encoding: @table.encoding)
|
95
|
+
else
|
96
|
+
io_in = input
|
96
97
|
end
|
97
|
-
if output.
|
98
|
-
|
98
|
+
if output.kind_of?(String)
|
99
|
+
io_out = File.open(output, "wb", encoding: @table.encoding)
|
100
|
+
else
|
101
|
+
io_out = output
|
99
102
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
+
io_out.write(gen_listing(io_in.read))
|
104
|
+
ensure
|
105
|
+
io_in.close if input.kind_of?(String) and not io_in.closed?
|
106
|
+
io_out.close if output.kind_of?(String) and not io_out.closed?
|
103
107
|
end
|
104
108
|
|
105
109
|
# The TranslationTable used by the Translator
|
data/lib/sanzang/version.rb
CHANGED
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.0.1
|
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-
|
11
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|