konjak 0.0.7 → 0.0.8
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/konjak/segment/gtt.rb +1 -0
- data/lib/konjak/segment.rb +6 -0
- data/lib/konjak/tmx_segmentor/text_strategy.rb +2 -2
- data/lib/konjak/version.rb +1 -1
- data/spec/konjak_translate_spec.rb +37 -11
- 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: cdc98142b5ed2a6814a96cf76c8d9c0f7bd2c5d2
|
4
|
+
data.tar.gz: f286772061e56d381e8f4f227e47ae9bfa259362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca86d1d1693776a7b3a5e57c687daf199d879cbb2e01c6ad6d806def612d1cc01e1c0938b91cf87b837406cb4bdbeee713a4c5d2043c1319faf3e22fc6798beb
|
7
|
+
data.tar.gz: 4339756d7df8a10a218d906cb12b85af05389056ebddef23219f9f6ecdd75f6c12f9010a4b5164faed85ee72a7e2a3f80f44151dde99cb51b7c8438ce3b92888
|
data/lib/konjak/segment/gtt.rb
CHANGED
data/lib/konjak/segment.rb
CHANGED
@@ -15,6 +15,12 @@ module Konjak
|
|
15
15
|
[Text, BeginPairedTag, EndPairedTag, IsolatedTag, Placeholder, Highlight].any? {|c| c === element }
|
16
16
|
end
|
17
17
|
|
18
|
+
def compile_pattern
|
19
|
+
regexp = Regexp.escape(text)
|
20
|
+
regexp = regexp.gsub(/(\\\s|\n)/m) { '\s+' }
|
21
|
+
Regexp.compile(regexp)
|
22
|
+
end
|
23
|
+
|
18
24
|
def translation_unit
|
19
25
|
TranslationUnit.new(translation_unit_variant.parent)
|
20
26
|
end
|
@@ -9,11 +9,11 @@ module Konjak
|
|
9
9
|
|
10
10
|
def split(translation_unit, text)
|
11
11
|
segment = translation_unit.variant(@lang).segment
|
12
|
-
|
12
|
+
pattern = segment.compile_pattern
|
13
13
|
|
14
14
|
texts = []
|
15
15
|
while true
|
16
|
-
head, match, tail = text.partition(
|
16
|
+
head, match, tail = text.partition(pattern)
|
17
17
|
break if match.empty? || text.length < min_segment_length
|
18
18
|
texts << head unless head.empty?
|
19
19
|
|
data/lib/konjak/version.rb
CHANGED
@@ -8,20 +8,30 @@ this is data (with a non-standard character: ).
|
|
8
8
|
this is data (with a non-standard character: ).
|
9
9
|
DOC
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
it { is_expected.to eq <<EXPECT }
|
11
|
+
let(:expected) { <<EXPECT }
|
14
12
|
this is données (avec un caractère non standard: ).
|
15
13
|
this is données (avec un caractère non standard: ).
|
16
14
|
EXPECT
|
17
15
|
|
16
|
+
subject { Konjak.translate(doc, sample_tmx, 'EN', 'FR-CA').join }
|
17
|
+
|
18
|
+
it { is_expected.to eq expected }
|
19
|
+
|
20
|
+
context 'when blanks between words is not exactly match' do
|
21
|
+
let(:doc) { <<DOC }
|
22
|
+
this is data (with a non-standard
|
23
|
+
|
24
|
+
character: ).
|
25
|
+
this is data (with a non-standard character: ).
|
26
|
+
DOC
|
27
|
+
|
28
|
+
it { is_expected.to eq expected }
|
29
|
+
end
|
30
|
+
|
18
31
|
context 'when passed Tmx' do
|
19
32
|
subject { Konjak.translate(doc, Konjak.parse(sample_tmx), 'EN', 'FR-CA').join }
|
20
33
|
|
21
|
-
it { is_expected.to eq
|
22
|
-
this is données (avec un caractère non standard: ).
|
23
|
-
this is données (avec un caractère non standard: ).
|
24
|
-
EXPECT
|
34
|
+
it { is_expected.to eq expected }
|
25
35
|
end
|
26
36
|
|
27
37
|
context 'when format is GTT' do
|
@@ -32,13 +42,29 @@ This is <a href="http://example.com">example</a>.
|
|
32
42
|
And This is <b>example</b>. Yey.
|
33
43
|
And This is example.
|
34
44
|
GTT_HTML
|
35
|
-
|
36
|
-
subject { Konjak.translate(doc, gtt_tmx, 'en', 'ja', format: :gtt_html).join }
|
37
|
-
|
38
|
-
it { is_expected.to eq <<EXPECT }
|
45
|
+
let(:expected) { <<EXPECT }
|
39
46
|
これは、 <a href="http://example.com">例</a> 。
|
40
47
|
And これは、 <b>例</b> 。 Yey.
|
41
48
|
And This is example.
|
42
49
|
EXPECT
|
50
|
+
|
51
|
+
subject { Konjak.translate(doc, gtt_tmx, 'en', 'ja', format: :gtt_html).join }
|
52
|
+
|
53
|
+
it { is_expected.to eq expected }
|
54
|
+
|
55
|
+
context 'when blanks between words is not exactly match' do
|
56
|
+
let(:doc) { <<GTT_HTML }
|
57
|
+
This is <a href="http://example.com">example</a>.
|
58
|
+
And This
|
59
|
+
is
|
60
|
+
|
61
|
+
|
62
|
+
<b>example</b>. Yey.
|
63
|
+
And This is example.
|
64
|
+
GTT_HTML
|
65
|
+
|
66
|
+
it { is_expected.to eq expected }
|
67
|
+
end
|
68
|
+
|
43
69
|
end
|
44
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konjak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seiei Higa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mem
|