Skip to content

Commit

Permalink
[enhancement] Handle initials in author normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
mikiher committed Oct 5, 2023
1 parent b2acdad commit f3555a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/finders/BookFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ class BookFinder {

cleanAuthorForCompares(author) {
if (!author) return ''
return this.replaceAccentedChars(author).toLowerCase()
let cleanAuthor = this.replaceAccentedChars(author).toLowerCase()
// separate initials
cleanAuthor = cleanAuthor.replace(/([a-z])\.([a-z])/g, '$1. $2')
// remove middle initials
cleanAuthor = cleanAuthor.replace(/(?<=\w\w)(\s+[a-z]\.?)+(?=\s+\w\w)/g, '')
return cleanAuthor
}

filterSearchResults(books, title, author, maxTitleDistance, maxAuthorDistance) {
Expand Down

0 comments on commit f3555a1

Please sign in to comment.