google_translate_diff 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/google_translate_diff/tokenizer.rb +5 -2
- data/lib/google_translate_diff/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1886972d6b13f5558879a22a90c4b1dad5e0ef20
|
4
|
+
data.tar.gz: fba14de63dcba2f52ad7752cc38ef95c44d2bcc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d184d364e9b85d1544306540df86bac03b9e58cd33ebbf57cbad15e3abb5c976162bb907789002104fcf9edb9eee933720b4d598aa37e61fa401b948b58ee7
|
7
|
+
data.tar.gz: 411f437b92949a07bffc122ca533f4109d9b62fbb946fc2781f4b4005892efa533563c7c4645060bbbfc7e2f7ac0b0bfaf8fc1d58545924a3be221207fea2f02
|
data/README.md
CHANGED
@@ -10,11 +10,11 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
|
|
10
10
|
attr_reader :texts, :tokens, :prev, :pos
|
11
11
|
|
12
12
|
def start_element(name)
|
13
|
-
@skip = true if name
|
13
|
+
@skip = true if SKIP.include?(name)
|
14
14
|
end
|
15
15
|
|
16
16
|
def end_element(name)
|
17
|
-
@skip = false if name
|
17
|
+
@skip = false if SKIP.include?(name)
|
18
18
|
end
|
19
19
|
|
20
20
|
def text(value)
|
@@ -65,10 +65,13 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
|
|
65
65
|
def tokenize(value)
|
66
66
|
return [] if value.nil?
|
67
67
|
tokenizer = new(value).tap do |h|
|
68
|
+
Ox.default_options = { mode: :generic, effort: :tolerant, smart: true }
|
68
69
|
Ox.sax_parse(h, StringIO.new(value))
|
69
70
|
h.cut_last_token
|
70
71
|
end
|
71
72
|
tokenizer.tokens
|
72
73
|
end
|
73
74
|
end
|
75
|
+
|
76
|
+
SKIP = %i(script style).freeze
|
74
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_translate_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.6.
|
199
|
+
rubygems_version: 2.6.12
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Google Translate API wrapper for Ruby which helps to translate only changes
|