You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, my team have encountered expected incorrect behaviour when custom dictionaries are misconfigured (incorrect order, case, incorrect newlines), so I've made a function to find these errors.
The code can be wrapped in a new spellr command to validate dictionaries.
Or it can be optionally be called when spell checking (for setups with small dictionaries).
Also you can spec test bundled dictionaries like this, if there is no validation currently
deffind_duplicates(array)prev=nilindexes=[]array.each_with_indexdo |curr,index|
indexes.append(index)ifprev == currprev=currendindexesenddeffind_not_ascending(array)prev=nilindexes=[]array.each_with_indexdo |curr,index|
indexes.append(index)ifprev && curr < prevprev=currendindexesenddeffind_not_lowercase(array)indexes=[]array.each_with_indexdo |curr,index|
indexes.append(index)unlesscurr == curr.downcaseendindexesenderror_type="error"errors=[]Dir.glob('.spellr_wordlists/*.txt').selectdo |file|
nextunlessFile.file?filecontents=File.readlines(file)find_not_ascending(contents).eachdo |index|
errors.append"#{file}:#{index+1}: #{error_type}: words must be ordered ascending"endfind_duplicates(contents).eachdo |index|
errors.append"#{file}:#{index+1}: #{error_type}: duplicate word"endfind_not_lowercase(contents).eachdo |index|
errors.append"#{file}:#{index+1}: #{error_type}: words must be lowercase"endifcontents.count > 0ifcontents.first.length == 1errors.append"#{file}:0: #{error_type}: first line must not be empty"endunlesscontents.last.end_with?"\n"errors.append"#{file}:#{contents.count}: #{error_type}: must have newline at the end of file"endendend
The text was updated successfully, but these errors were encountered:
Hi, my team have encountered expected incorrect behaviour when custom dictionaries are misconfigured (incorrect order, case, incorrect newlines), so I've made a function to find these errors.
The code can be wrapped in a new spellr command to validate dictionaries.
Or it can be optionally be called when spell checking (for setups with small dictionaries).
Also you can spec test bundled dictionaries like this, if there is no validation currently
The text was updated successfully, but these errors were encountered: