tataki 0.0.2 → 0.0.3
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/lib/tataki/converters/skk_jisyo.rb +13 -13
- data/lib/tataki/version.rb +1 -1
- data/spec/tataki/converters/skk_jisyo_spec.rb +19 -8
- 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: aa8fec9bc8527b014ade8528d1cd9cefa2223c59
|
4
|
+
data.tar.gz: 39f9543bbcdf66bb83fc3062a019c126064cbde2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b330894a4b2bd8d159b6ebabb3be71486ba820f87feee4a744682a83e3a93936acbeacd48bfd44cf80ecec99f197b2da6d354e97e2048e067fe1bfe73492e0
|
7
|
+
data.tar.gz: ff9e1b5643bb7d748bfe0fadfcd191ebf270103198662d5e2f6c2d4aa3171d8c29bc4bebbe8a58ce4cbf67853ea9a8d87a5f2a43d4c1c5de2cbdff158627c4a5
|
@@ -7,30 +7,30 @@ require "trie"
|
|
7
7
|
module Tataki
|
8
8
|
module Converter
|
9
9
|
class SkkJisyo < Base
|
10
|
+
DEFAULT_CONFIG_PATH = "../../../../data/skk-jisyo.yml"
|
10
11
|
DEFAULT_JISYO_SUFFIXES = %w[M]
|
11
12
|
|
12
|
-
def initialize(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
config_file = File.expand_path("../../../../data/skk-jisyo.yml", __FILE__)
|
13
|
+
def initialize(jisyo_types = DEFAULT_JISYO_SUFFIXES)
|
14
|
+
@jisyo_paths = jisyo_types.map{|suffix| Skk::Jisyo.path(suffix) }
|
15
|
+
@trie_cache_path = trie_cache_path(jisyo_types.join("_"))
|
16
|
+
|
17
|
+
config_file = File.expand_path(DEFAULT_CONFIG_PATH, __FILE__)
|
18
18
|
config_data = YAML.load_file(config_file)
|
19
19
|
@roman_data = config_data["roman_table"]
|
20
20
|
@ignore_kana = config_data["ignore_kana"]
|
21
|
-
@trie = setup_jisyo
|
21
|
+
@trie = setup_jisyo.freeze
|
22
22
|
end
|
23
23
|
|
24
|
-
def setup_jisyo
|
25
|
-
if File.exist?(
|
26
|
-
trie = Marshal.load(File.read(
|
24
|
+
def setup_jisyo
|
25
|
+
if File.exist?(@trie_cache_path)
|
26
|
+
trie = Marshal.load(File.read(@trie_cache_path))
|
27
27
|
else
|
28
28
|
trie = Trie.new
|
29
|
-
|
29
|
+
@jisyo_paths.each do |jisyo_path|
|
30
30
|
add_jisyo(trie, jisyo_path)
|
31
31
|
end
|
32
|
-
File.binwrite(
|
33
|
-
File.write("#{
|
32
|
+
File.binwrite(@trie_cache_path, Marshal.dump(trie))
|
33
|
+
File.write("#{@trie_cache_path}.timestamp", Time.now.to_s)
|
34
34
|
end
|
35
35
|
trie
|
36
36
|
end
|
data/lib/tataki/version.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
describe Tataki::Converter::SkkJisyo do
|
5
|
-
let(:converter) { Tataki::Converter::SkkJisyo.new }
|
6
5
|
|
7
6
|
describe ".to_kana" do
|
8
7
|
shared_examples "converts_kana" do |sentence, kana|
|
@@ -11,12 +10,24 @@ describe Tataki::Converter::SkkJisyo do
|
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
context "with default config" do
|
14
|
+
let(:converter) { Tataki::Converter::SkkJisyo.new }
|
15
|
+
|
16
|
+
include_examples "converts_kana", "", ""
|
17
|
+
include_examples "converts_kana", "漢字", "かんじ"
|
18
|
+
include_examples "converts_kana", "漢字変換する", "かんじへんかんする"
|
19
|
+
include_examples "converts_kana", "隣りの", "となりの"
|
20
|
+
include_examples "converts_kana", "隣りはよく柿食う", "となりはよくかきくう"
|
21
|
+
include_examples "converts_kana", "安心安全", "あんしんあんぜん"
|
22
|
+
include_examples "converts_kana", "毎朝新聞配達をしています", "まいあさしんぶんはいたつをしています"
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with jinmei jisyo" do
|
26
|
+
let(:converter) { Tataki::Converter::SkkJisyo.new(%w[jinmei]) }
|
27
|
+
|
28
|
+
include_examples "converts_kana", "", ""
|
29
|
+
include_examples "converts_kana", "漢字", "漢字"
|
30
|
+
include_examples "converts_kana", "半澤直樹", "はんざわなおき"
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tataki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hogelog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: skk-jisyo
|