tml 5.6.4 → 5.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tml/config.rb +7 -7
- data/lib/tml/tokenizers/dom.rb +10 -4
- data/lib/tml/version.rb +1 -1
- 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: c34d0e6209b1b34c4143f0b16ecbc73aec7a5324
|
4
|
+
data.tar.gz: 20f9c409c786a9a67cb76e74eb3cdbe285f9eb3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee0f8b41b9d66d8d1f05172df2318eade8f05c408f299137fb45e791b3cd03b0ac20da55e8c28cda300faa08c736c8f0d9dfdec49fbae47dfc4094cef5bf2dc
|
7
|
+
data.tar.gz: 690f0c2581fcdc822a8e63c45265fdcce2eb2a4b9298a700dd9845b9429ef1911395acf1995946bbcd9aa7d91764e638277db9dc404d438421c16c9c3334e2af
|
data/lib/tml/config.rb
CHANGED
@@ -156,7 +156,7 @@ module Tml
|
|
156
156
|
regex: /(&[^;]*;)/
|
157
157
|
},
|
158
158
|
date: {
|
159
|
-
enabled:
|
159
|
+
enabled: false,
|
160
160
|
formats: [
|
161
161
|
[/((Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d+,\s+\d+)/, "{month} {day}, {year}"],
|
162
162
|
[/((January|February|March|April|May|June|July|August|September|October|November|December)\s+\d+,\s+\d+)/, "{month} {day}, {year}"],
|
@@ -166,12 +166,12 @@ module Tml
|
|
166
166
|
name: 'date'
|
167
167
|
},
|
168
168
|
rules: [
|
169
|
-
{enabled:
|
170
|
-
{enabled:
|
171
|
-
{enabled:
|
172
|
-
{enabled:
|
173
|
-
{enabled:
|
174
|
-
{enabled:
|
169
|
+
{enabled: false, name: 'time', regex: /(\d{1,2}:\d{1,2}\s+([A-Z]{2,3}|am|pm|AM|PM)?)/},
|
170
|
+
{enabled: false, name: 'phone', regex: /((\d{1}-)?\d{3}-\d{3}-\d{4}|\d?\(\d{3}\)\s*\d{3}-\d{4}|(\d.)?\d{3}.\d{3}.\d{4})/},
|
171
|
+
{enabled: false, name: 'email', regex: /([-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|io|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?)/},
|
172
|
+
{enabled: false, name: 'price', regex: /(\$\d*(,\d*)*(\.\d*)?)/},
|
173
|
+
{enabled: false, name: 'fraction', regex: /(\d+\/\d+)/},
|
174
|
+
{enabled: false, name: 'num', regex: /(\b\d*(,\d*)*(\.\d*)?%?\b)/}
|
175
175
|
]
|
176
176
|
}
|
177
177
|
}
|
data/lib/tml/tokenizers/dom.rb
CHANGED
@@ -103,6 +103,8 @@ module Tml
|
|
103
103
|
|
104
104
|
def translate_tml(tml)
|
105
105
|
return tml if empty_string?(tml)
|
106
|
+
pp tml
|
107
|
+
|
106
108
|
tml = generate_data_tokens(tml)
|
107
109
|
|
108
110
|
if option('split_sentences')
|
@@ -147,9 +149,9 @@ module Tml
|
|
147
149
|
value = sanitize_value(buffer)
|
148
150
|
|
149
151
|
return '{' + token + '}' if self_closing_node?(node)
|
150
|
-
return '[' + token + ': ' + value + ']' if short_token?(token, value)
|
152
|
+
# return '[' + token + ': ' + value + ']' if short_token?(token, value)
|
151
153
|
|
152
|
-
'
|
154
|
+
'<' + token + '>' + value + '</' + token + '>'
|
153
155
|
end
|
154
156
|
|
155
157
|
def option(name)
|
@@ -162,8 +164,12 @@ module Tml
|
|
162
164
|
end
|
163
165
|
|
164
166
|
def empty_string?(tml)
|
165
|
-
tml = tml.gsub(/[\s\n\r\t]/, '')
|
166
|
-
tml == ''
|
167
|
+
tml = tml.gsub(/[\s\n\r\t]/, '').gsub(/[\u0080-\u00ff]/, '')
|
168
|
+
return true if tml == ''
|
169
|
+
return true if tml.match(/\A\$\{[^\}]+\}\z/) # ignore variables ${var_name}
|
170
|
+
return true if tml.match(/\A\$?\d+\.?\d+\z/) # ignore prices and numbers
|
171
|
+
|
172
|
+
false
|
167
173
|
end
|
168
174
|
|
169
175
|
def reset_context
|
data/lib/tml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.6.
|
4
|
+
version: 5.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Berkovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|