onlyoffice_language_helper 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onlyoffice_language_helper/detect_language.rb +4 -0
- data/lib/onlyoffice_language_helper/name.rb +1 -0
- data/lib/onlyoffice_language_helper/spell_checker.rb +19 -0
- data/lib/onlyoffice_language_helper/spell_checker/config.rb +3 -0
- data/lib/onlyoffice_language_helper/spell_checker/dictionaries_threads.rb +5 -0
- data/lib/onlyoffice_language_helper/version.rb +2 -1
- metadata +121 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7dacc49bd982030e1bbeb32cef0c6cfbe05c638cde4d8e78610b000f1a8c7be
|
4
|
+
data.tar.gz: c9952a740dc42eedd48329498286e7b02777f2873b527ab782ca92c98443a531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e572ad5b79647ad9b26a8b9102ec4de89d077f9dae5a71aeb4c08798fdbba483ffc121d7deee57929e07fed55749e9f94f3d5a96df761792691c468cc5c25f1
|
7
|
+
data.tar.gz: e7671a85fc20055c9bb782ef71bcb980ad8074543c9ef21a81ca8003a31dc273abb11c5fdc19e6707627b8d11be7e83c0a560297a6e52cd88320b46ffbef099d
|
@@ -10,11 +10,15 @@ module OnlyofficeLanguageHelper
|
|
10
10
|
# @return [Array, String] initialized keys
|
11
11
|
attr_accessor :api_keys
|
12
12
|
|
13
|
+
# Detect language of text
|
14
|
+
# @param text [String] text to detect
|
15
|
+
# @return [String] possible language
|
13
16
|
def detect_language(text)
|
14
17
|
change_key_on_active
|
15
18
|
DetectLanguage.detect(text)
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [Array<String>] list of all possible languages
|
18
22
|
def all_languages
|
19
23
|
change_key_on_active
|
20
24
|
DetectLanguage.languages
|
@@ -21,6 +21,7 @@ module OnlyofficeLanguageHelper
|
|
21
21
|
include HTTParty
|
22
22
|
attr_reader :config
|
23
23
|
|
24
|
+
# Configure Spellchecker
|
24
25
|
def self.configure
|
25
26
|
OnlyofficeLoggerHelper.log('Begin configuring SpellChecker')
|
26
27
|
config
|
@@ -31,6 +32,9 @@ module OnlyofficeLanguageHelper
|
|
31
32
|
OnlyofficeLoggerHelper.log('Configuring complete!')
|
32
33
|
end
|
33
34
|
|
35
|
+
# Check in all known dictionaries
|
36
|
+
# @param string [String] string to check
|
37
|
+
# @return [Array<Hash>] result of check
|
34
38
|
def self.check_in_all_dictionaries(string)
|
35
39
|
check_configuration
|
36
40
|
@dictionaries ||= DictionariesThreads.new
|
@@ -40,15 +44,26 @@ module OnlyofficeLanguageHelper
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
47
|
+
# Get path to dic aff
|
48
|
+
# @param extension [String] extension of dictionaries
|
49
|
+
# @param language [String] language to get
|
50
|
+
# @return [String] path
|
43
51
|
def self.path_to_dic_aff(extension, language = config.expected_language)
|
44
52
|
"#{config.dictionaries_path}/dictionaries/"\
|
45
53
|
"#{language}/#{language}.#{extension}"
|
46
54
|
end
|
47
55
|
|
56
|
+
# Split text by words
|
57
|
+
# @param string [String] multi-word text
|
58
|
+
# @return [Array<String>] uniq words
|
48
59
|
def self.split_text_by_words(string)
|
49
60
|
string.to_s.scan(/\b[[:word:]['-]]+\b/u).uniq
|
50
61
|
end
|
51
62
|
|
63
|
+
# Parse spellchecker result
|
64
|
+
# @param word [String] word to check
|
65
|
+
# @param spellcheck_result [Hash] param to set result
|
66
|
+
# @return [Hash] value of result
|
52
67
|
def self.parse_spellcheck_result(word, spellcheck_result)
|
53
68
|
unless spellcheck_result[config.expected_language]
|
54
69
|
warn("Word '#{word}' was not found in "\
|
@@ -58,20 +73,24 @@ module OnlyofficeLanguageHelper
|
|
58
73
|
{ word => spellcheck_result }
|
59
74
|
end
|
60
75
|
|
76
|
+
# @return [Config] get current config
|
61
77
|
def self.config
|
62
78
|
@config ||= Config.new
|
63
79
|
end
|
64
80
|
|
81
|
+
# @return [nil] Reset config to default
|
65
82
|
def self.reset_config
|
66
83
|
@config = Config.new
|
67
84
|
end
|
68
85
|
|
86
|
+
# @return [nil] check if current config is right
|
69
87
|
def self.check_configuration
|
70
88
|
return if @dictionary
|
71
89
|
|
72
90
|
raise 'Call SpellChecker.configure method before using it!'
|
73
91
|
end
|
74
92
|
|
93
|
+
# @return [nil] check if current language has dictonaries
|
75
94
|
def self.check_language
|
76
95
|
unless File.exist?(path_to_dic_aff(:dic)) ||
|
77
96
|
File.exist?(path_to_dic_aff(:aff))
|
@@ -4,13 +4,16 @@ module OnlyofficeLanguageHelper
|
|
4
4
|
module SpellChecker
|
5
5
|
# Spellchecker config
|
6
6
|
class Config
|
7
|
+
# @return [String] language to expect
|
7
8
|
attr_accessor :expected_language
|
9
|
+
# @return [String] path to lang file
|
8
10
|
attr_accessor :dictionaries_path
|
9
11
|
|
10
12
|
def initialize
|
11
13
|
default_configuration
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [nil] default configuration for SpellChecker
|
14
17
|
def default_configuration
|
15
18
|
@expected_language = 'en_US'
|
16
19
|
@dictionaries_path = File.dirname(__dir__)
|
@@ -21,16 +21,21 @@ module OnlyofficeLanguageHelper
|
|
21
21
|
init_threads_data
|
22
22
|
end
|
23
23
|
|
24
|
+
# @return [Array<Thread>] list of checker threads
|
24
25
|
def threads
|
25
26
|
@threads ||= init_threads
|
26
27
|
end
|
27
28
|
|
29
|
+
# Check current word
|
30
|
+
# @param word [String] word to check
|
31
|
+
# @return [Hash] result of check
|
28
32
|
def check_word(word)
|
29
33
|
@result = {}
|
30
34
|
@word = word.to_s
|
31
35
|
start_threads
|
32
36
|
end
|
33
37
|
|
38
|
+
# @return [Hash] start threads and return results
|
34
39
|
def start_threads
|
35
40
|
threads.each(&:run)
|
36
41
|
until @result.length == @dictionaries.length
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_language_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: detect_language
|
@@ -17,56 +17,56 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1
|
20
|
+
version: '1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1
|
27
|
+
version: '1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: httparty
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 0.10.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 0.10.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: hunspell-ffi
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0
|
48
|
+
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0
|
55
|
+
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: onlyoffice_file_helper
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0
|
62
|
+
version: '0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0
|
69
|
+
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: onlyoffice_logger_helper
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,28 +87,126 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '1
|
90
|
+
version: '1'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '1
|
97
|
+
version: '1'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: codecov
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: overcommit
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
98
126
|
- !ruby/object:Gem::Dependency
|
99
127
|
name: rake
|
100
128
|
requirement: !ruby/object:Gem::Requirement
|
101
129
|
requirements:
|
102
130
|
- - "~>"
|
103
131
|
- !ruby/object:Gem::Version
|
104
|
-
version: '13
|
132
|
+
version: '13'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '13'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rspec
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: rubocop
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '1'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '1'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: rubocop-performance
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '1'
|
105
175
|
type: :development
|
106
176
|
prerelease: false
|
107
177
|
version_requirements: !ruby/object:Gem::Requirement
|
108
178
|
requirements:
|
109
179
|
- - "~>"
|
110
180
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
181
|
+
version: '1'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: rubocop-rspec
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '2'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '2'
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: yard
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 0.9.20
|
203
|
+
type: :development
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: 0.9.20
|
112
210
|
description: ONLYOFFICE Helper Gem for language operation. Used in QA
|
113
211
|
email:
|
114
212
|
- shockwavenn@gmail.com
|
@@ -225,15 +323,15 @@ files:
|
|
225
323
|
- lib/onlyoffice_language_helper/spell_checker/config.rb
|
226
324
|
- lib/onlyoffice_language_helper/spell_checker/dictionaries_threads.rb
|
227
325
|
- lib/onlyoffice_language_helper/version.rb
|
228
|
-
homepage: https://github.com/
|
326
|
+
homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_language_helper
|
229
327
|
licenses:
|
230
328
|
- AGPL-3.0
|
231
329
|
metadata:
|
232
|
-
bug_tracker_uri: https://github.com/
|
233
|
-
changelog_uri: https://github.com/
|
330
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_language_helper/issues
|
331
|
+
changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_language_helper/blob/master/CHANGELOG.md
|
234
332
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_language_helper
|
235
|
-
homepage_uri: https://github.com/
|
236
|
-
source_code_uri: https://github.com/
|
333
|
+
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_language_helper
|
334
|
+
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_language_helper
|
237
335
|
post_install_message:
|
238
336
|
rdoc_options: []
|
239
337
|
require_paths:
|
@@ -242,14 +340,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
340
|
requirements:
|
243
341
|
- - ">="
|
244
342
|
- !ruby/object:Gem::Version
|
245
|
-
version: '
|
343
|
+
version: '2.5'
|
246
344
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
345
|
requirements:
|
248
346
|
- - ">="
|
249
347
|
- !ruby/object:Gem::Version
|
250
348
|
version: '0'
|
251
349
|
requirements: []
|
252
|
-
rubygems_version: 3.1.
|
350
|
+
rubygems_version: 3.1.4
|
253
351
|
signing_key:
|
254
352
|
specification_version: 4
|
255
353
|
summary: ONLYOFFICE Helper Gem for language operation
|