sanzang 1.0.0 → 1.0.1

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: ee6e8f6e1b7cbd116de22589a0089faa73b35726
4
- data.tar.gz: 2110931d7a863e52dc6ade5b17c060d4dc9ab12e
3
+ metadata.gz: e45b8e0b9f093af18eaa9f9cc4b2c670ea0eb044
4
+ data.tar.gz: cc4cbc73c335dd6d5e3294c3f6826bdb52877398
5
5
  SHA512:
6
- metadata.gz: 65710d20a08d6b20f82d3c909468c8e5d03b54fd5f96657247d0eaededc587d1394c66183660e50c654990f0bccfcb1efc600af5672e518cbaa777cd9a5ba3f8
7
- data.tar.gz: 039837a397ed9f5561d5f2c6af23fe4a8991b305d134a7f4cfe6be3f67bad0506bf1ca6d8bf332586f51243a8bfbd1acb8302beb60b107e4ca165b56f66550ea
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
- Korean, and Japanese), and it is very suitable for ancient and otherwise
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. Any user can
20
- develop his or her own translation rules, and these are simply stored in a text
21
- file that the program can read. For full details, refer to the MANUAL.
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 automatically
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 and running on your computer.
52
+ You now have \Sanzang installed on your computer.
@@ -68,6 +68,8 @@ module Sanzang::Command
68
68
  return 0
69
69
  rescue SystemExit => err
70
70
  return err.status
71
+ rescue Errno::EPIPE => err
72
+ return 0
71
73
  rescue Exception => err
72
74
  $stderr.puts err.backtrace
73
75
  $stderr.puts "\nERROR: #{err.inspect}\n\n"
@@ -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
- encodings = Encoding.list.sort do |x,y|
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|
@@ -79,6 +79,8 @@ module Sanzang::Command
79
79
  return 0
80
80
  rescue SystemExit => err
81
81
  return err.status
82
+ rescue Errno::EPIPE => err
83
+ return 0
82
84
  rescue Exception => err
83
85
  $stderr.puts err.backtrace
84
86
  $stderr.puts "\nERROR: #{err.inspect}\n\n"
@@ -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
@@ -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
- # The parameters _input_ and _output_ can be either String objects or IO
89
- # objects. If they are strings, then they are interpreted as being file
90
- # paths. If they are not strings, then the I/O operations are performed on
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.class == String
95
- input = File.open(input, "r", external_encoding: @table.encoding)
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.class == String
98
- output = File.open(output, "w", external_encoding: @table.encoding)
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
- output.write(gen_listing(input.read))
101
- input.close
102
- output.close
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
@@ -20,6 +20,6 @@ module Sanzang
20
20
 
21
21
  # Current version number of Sanzang
22
22
  #
23
- VERSION = "1.0.0"
23
+ VERSION = "1.0.1"
24
24
 
25
25
  end
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.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-04-29 00:00:00.000000000 Z
11
+ date: 2013-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel