Skip to content

Commit fc6ae8f

Browse files
committed
Implement #205
Currently at Levenshtein ≥ 2, but this should be discussed!
1 parent 98713c1 commit fc6ae8f

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/models/name.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def all_public
188188
# parameters are:
189189
# - method: One of +:similarity+ (default) or +:levenshtein+
190190
# - threshold: Limit to find matches,
191-
# by default 0.7 (similarity) or 3 (levenshtein)
191+
# by default 0.7 (similarity) or 2 (levenshtein)
192192
# - limit: Maximum number of results to return
193193
# - selection: Pre-selection of names included in the search. One of:
194194
# - all_valid: (default) All validly published names
@@ -223,7 +223,7 @@ def fuzzy_match(
223223
.order('score DESC')
224224
.limit(limit)
225225
when :levenshtein
226-
threshold ||= 3
226+
threshold ||= 2
227227
selection
228228
.select("id, name, levenshtein(name, #{clean_query}) AS score")
229229
.where('levenshtein(name, ?) <= ?', query, threshold)

app/models/name/quality_checks.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ class QcWarning
175175
recommendations: %w[9.1]
176176
}.merge(@@link_to_edit_spelling),
177177
# - Recommendation 9.1 covered in § Rule 9b
178-
# - Recommendation 9.2 [TODO: issue #6]:
178+
# - Recommendation 9.2:
179+
# TODO [issue #205]: Discuss the default implementation, since it
180+
# involves Levenshtein ≥ 2 instead of 3, as stipulated in the SeqCode,
181+
# because the latter returns too many clearly distinct options. For
182+
# example, Burarchaeum would be "too similar" to: Halarchaeum,
183+
# Hadarchaeum, Salarchaeum, and Gugararchaeum, all of which are clearly
184+
# different
179185
similar_names_validly_published: {
180186
message: lambda { |w|
181187
similar = w.name.similar_names(:valid).limit(5)
@@ -189,7 +195,8 @@ class QcWarning
189195
}.merge(@@link_to_edit_spelling),
190196
similar_names_in_register_list: {
191197
message: lambda { |w|
192-
similar = w.name.similar_names(:register).limit(5).map(&:name)
198+
similar = w.name.similar_names(:register).limit(5)
199+
.map(&:reload).map(&:name_html)
193200
<<~MSG.html_safe
194201
Name is similar in spelling to: #{similar.to_sentence}.
195202
Consider variations that are less prone to confusion

0 commit comments

Comments
 (0)