clausewitz-spelling 0.1.18 → 0.1.19
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/Gemfile.lock +1 -1
- data/lib/clausewitz/spelling/checker.rb +10 -4
- data/lib/clausewitz/spelling/results.rb +11 -0
- data/lib/clausewitz/spelling/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b8f238c7ccf5a99e18aea147d865baa3eba23e
|
4
|
+
data.tar.gz: 737b15a9ea8c6dfb3b1279d1170986aa9b080e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 523a1c3c5cbed97de4454eca5422a181846544338e7fc108457f924f2a9a3ba9f3b1b1329679e5358f958b12b10d94972bc6a05767fc5feacf7b9bb804444ce5
|
7
|
+
data.tar.gz: 3206f38862471223cc8fd4096cb398b1b42864b15ef8a60bb82de1e507f4bf497bfb86e7e46fbbe57d8eb643141f18d4e42c2f22940314e36c3e6b82feaa4cf6
|
data/Gemfile.lock
CHANGED
@@ -74,13 +74,13 @@ module Clausewitz; module Spelling
|
|
74
74
|
if ignored_keys.include?(key)
|
75
75
|
IgnoredEntryResult.new(key)
|
76
76
|
else
|
77
|
-
check_entry(aspell_checker, wordlist, key, entry)
|
77
|
+
check_entry(lc, aspell_checker, wordlist, key, entry)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
LangResults.new(lc.clausewitz_name, checks)
|
81
81
|
end
|
82
82
|
|
83
|
-
def check_entry(checker, wordlist, key, entry)
|
83
|
+
def check_entry(lc, checker, wordlist, key, entry)
|
84
84
|
# We don't want to pay attention to scripted localisation, so we'll strip
|
85
85
|
# it out before we start.
|
86
86
|
# TODO: Look into supporting escaped square brackets as part of the
|
@@ -117,7 +117,7 @@ module Clausewitz; module Spelling
|
|
117
117
|
#end.join(" ")
|
118
118
|
|
119
119
|
opts = {
|
120
|
-
language:
|
120
|
+
language: lc.base.to_sym,
|
121
121
|
punctuation: :none,
|
122
122
|
downcase: false
|
123
123
|
}
|
@@ -131,6 +131,7 @@ module Clausewitz; module Spelling
|
|
131
131
|
|
132
132
|
def check_word(checker, wordlist, word)
|
133
133
|
return if is_number?(word)
|
134
|
+
return if is_plural_number?(word)
|
134
135
|
return if is_ordinal?(word)
|
135
136
|
return if is_percentage?(word)
|
136
137
|
return if is_icon?(word)
|
@@ -143,6 +144,10 @@ module Clausewitz; module Spelling
|
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
147
|
+
def is_plural_number?(word)
|
148
|
+
word =~ /\d+'s/
|
149
|
+
end
|
150
|
+
|
146
151
|
def is_psalm?(word)
|
147
152
|
word =~ /^\d+:\d+$/
|
148
153
|
end
|
@@ -159,7 +164,8 @@ module Clausewitz; module Spelling
|
|
159
164
|
aspell_suggestions = checker.suggestions(word)
|
160
165
|
|
161
166
|
custom_suggestions = wordlist.select do |dict_word|
|
162
|
-
|
167
|
+
min = [word.size, dict_word.size].min
|
168
|
+
DamerauLevenshtein.distance(word, dict_word) < min
|
163
169
|
end
|
164
170
|
|
165
171
|
aspell_suggestions.each { |sug| suggestions.add(sug) }
|
@@ -146,6 +146,17 @@ module Clausewitz; module Spelling
|
|
146
146
|
def failed?
|
147
147
|
true
|
148
148
|
end
|
149
|
+
|
150
|
+
def to_s
|
151
|
+
to_str
|
152
|
+
end
|
153
|
+
|
154
|
+
def to_str(indent = 0)
|
155
|
+
spacer = ' ' * indent
|
156
|
+
secondspacer = ' ' * (indent + 2)
|
157
|
+
"#{spacer}#{@filepath} is invalid\n".red +
|
158
|
+
"#{secondspacer}#{@error.message}".red
|
159
|
+
end
|
149
160
|
end
|
150
161
|
|
151
162
|
# Result capturing problems parsing a readable file.
|