imedic-tools 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7670f860570f73ef0fdf31fe278598246eab359159af59e8ebc3c1e5bc35aaef
4
- data.tar.gz: c472bf447d23344b7f34403f67bbc7408cc1f259662adcf0b2e29803fff382fa
3
+ metadata.gz: 7b12f55432c0980bb4248722a474b91a6678f4c89a811024b2ec84bc6b8a83c4
4
+ data.tar.gz: 363db496bfdf63cc0268da6d1fdbd9ed3a08f62ad402ae6f3cd417a166ab36ab
5
5
  SHA512:
6
- metadata.gz: 3ba08c54418c73016822bb12f24d4d4f47791dcc0d71c52bb0f431828f3b61ef09db7b92972971526a3218f49dba2dfed5f245c9db20e32885a2fbb42c440a14
7
- data.tar.gz: 57354a763840c018d3c1fec1bf7ec0ea4c4b798cecdde30e2a8e14d3d7033f422b2e9daf09e728e7887752f812add47891b7c8b7f9daaf5d5bf462fcaab23045
6
+ metadata.gz: a78cb266d1091617af255d53ece626f78222988360cdece620015e93c9e04c15a6e9d51c21a88b0069178351c2f34f2c2ac5dd10997a0e0830ab997ef048b772
7
+ data.tar.gz: fabdb4e014dcaf0d0aeeb06249e204c9a3fd2d2ce935b6eadbe3c7a486633044b188be7a28be2fed87a96ca143113722f6e28cbe6d26d469787ce4c73d2e0d33
data/README.md CHANGED
@@ -27,6 +27,7 @@ This gem includes three tools:
27
27
  - `atok2msime`: Converts ATOK word-list files to Microsoft IME format
28
28
  - `msime2atok`: Converts Microsoft IME word-list files to ATOK format
29
29
  - `atok2kotoeri`: Converts ATOK word-list files to Kotoeri CSV format
30
+ - `atok2atok`: Normalizes ATOK word-list files to UTF-16LE with a BOM and CRLF line endings
30
31
 
31
32
  Usage is common to all tools:
32
33
 
data/exe/atok2atok ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ def each_atok_line(file)
4
+ open_input(file) do |io|
5
+ io.each_line(chomp: true) do |line|
6
+ yield line.delete_suffix("\r")
7
+ end
8
+ end
9
+ end
10
+
11
+ def open_input(file)
12
+ if file == "-"
13
+ setup_input(STDIN)
14
+ yield STDIN
15
+ else
16
+ File.open(file, "rb") do |io|
17
+ setup_input(io)
18
+ yield io
19
+ end
20
+ end
21
+ end
22
+
23
+ def setup_input(io)
24
+ io.binmode
25
+ if (encoding = io.set_encoding_by_bom)
26
+ io.set_encoding(encoding, Encoding::UTF_8)
27
+ else
28
+ io.set_encoding(Encoding::UTF_8)
29
+ end
30
+ end
31
+
32
+ $stdout.set_encoding(Encoding::UTF_16LE, Encoding::UTF_8, crlf_newline: true)
33
+ $stdout.write("\uFEFF")
34
+
35
+ puts "!!ATOK_TANGO_TEXT_HEADER_1"
36
+
37
+ files = ARGV.empty? ? ["-"] : ARGV
38
+
39
+ files.each do |file|
40
+ each_atok_line(file) do |line|
41
+ next if line.empty? || line == "!!ATOK_TANGO_TEXT_HEADER_1"
42
+
43
+ puts line
44
+ end
45
+ end
data/imedic-tools.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  `git ls-files -z`.split("\x0")
25
25
  end
26
26
  spec.bindir = "exe"
27
- spec.executables = ["atok2kotoeri", "atok2msime", "msime2atok"]
27
+ spec.executables = ["atok2atok", "atok2kotoeri", "atok2msime", "msime2atok"]
28
28
  spec.require_paths = ["lib"]
29
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Imedic
4
4
  module Tools
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imedic-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori Musha
@@ -14,6 +14,7 @@ description: Command-line tools that convert Japanese input dictionary word-list
14
14
  email:
15
15
  - knu@idaemons.org
16
16
  executables:
17
+ - atok2atok
17
18
  - atok2kotoeri
18
19
  - atok2msime
19
20
  - msime2atok
@@ -27,6 +28,7 @@ files:
27
28
  - LICENSE
28
29
  - README.md
29
30
  - Rakefile
31
+ - exe/atok2atok
30
32
  - exe/atok2kotoeri
31
33
  - exe/atok2msime
32
34
  - exe/msime2atok