Skip to content

Commit

Permalink
Merged in r2-3032-fix-error-calculate_solr_fields (pull request #6941)
Browse files Browse the repository at this point in the history
R2-3032 Error on calculate_solr_fields script
  • Loading branch information
aespinoza-quoin authored and pnabutovsky committed Sep 27, 2024
2 parents d993a5d + c72976a commit 5cebec8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/services/language_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def latin?(value)
end

def tokenize(value)
return [] unless value.is_a?(String)

value&.split&.map do |elem|
diacriticless = strip_diacritics(elem)
# NOTE: Text::Metaphone produces upcase strings. Upcasing to keep consistent output.
Expand Down
10 changes: 10 additions & 0 deletions spec/services/language_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@
).to eq(['فتح', 'أصلا', 'عنف', 'طفل', 'ملف', 'راح إلى محطة', 'احمد', 'محمد'])
end
end

describe 'when values include an integer' do
it 'should skip integer values' do
expect(
[0, 1, 'sample'].map do |elem|
LanguageService.tokenize(elem).uniq
end
).to match_array([[], [], ['SMPL']])
end
end
end

0 comments on commit 5cebec8

Please sign in to comment.