search: ignore punctuation
Ignore punctuation when searching. Makes the search experience a bit nicer. Resolves #378.
This commit is contained in:
parent
245896e4a7
commit
8ea637ff05
3 changed files with 17 additions and 11 deletions
|
@ -7,12 +7,13 @@
|
||||||
|
|
||||||
#### What's Improved
|
#### What's Improved
|
||||||
- Accept `REPLAYGAIN_*` adjustment information on OPUS files alongside
|
- Accept `REPLAYGAIN_*` adjustment information on OPUS files alongside
|
||||||
`R128_*` adjustments.
|
`R128_*` adjustments
|
||||||
- List updates are now consistent across the app
|
- List updates are now consistent across the app
|
||||||
- Fixed jarring header update in detail view
|
- Fixed jarring header update in detail view
|
||||||
- Search view now trims search queries
|
- Search view now trims search queries
|
||||||
- Audio effect (equalizer) session is now broadcast when playing/pausing
|
- Audio effect (equalizer) session is now broadcast when playing/pausing
|
||||||
rather than on start/stop.
|
rather than on start/stop
|
||||||
|
- Searching now ignores punctuation
|
||||||
|
|
||||||
#### What's Fixed
|
#### What's Fixed
|
||||||
- Fixed MP4-AAC files not playing due to an accidental audio extractor
|
- Fixed MP4-AAC files not playing due to an accidental audio extractor
|
||||||
|
|
|
@ -159,11 +159,14 @@ private constructor(private val rawSong: RawSong, private val future: Future<Tra
|
||||||
textFrames["TCON"]?.let { rawSong.genreNames = it }
|
textFrames["TCON"]?.let { rawSong.genreNames = it }
|
||||||
|
|
||||||
// Compilation Flag
|
// Compilation Flag
|
||||||
(textFrames["TCMP"] ?: textFrames["TXXX:compilation"] ?: textFrames["TXXX:itunescompilation"])?.let {
|
(textFrames["TCMP"]
|
||||||
if (it.size != 1 || it[0] != "1") return@let
|
?: textFrames["TXXX:compilation"] ?: textFrames["TXXX:itunescompilation"])
|
||||||
rawSong.albumArtistNames = rawSong.albumArtistNames.ifEmpty { COMPILATION_ALBUM_ARTISTS }
|
?.let {
|
||||||
rawSong.releaseTypes = rawSong.releaseTypes.ifEmpty { COMPILATION_RELEASE_TYPES }
|
if (it.size != 1 || it[0] != "1") return@let
|
||||||
}
|
rawSong.albumArtistNames =
|
||||||
|
rawSong.albumArtistNames.ifEmpty { COMPILATION_ALBUM_ARTISTS }
|
||||||
|
rawSong.releaseTypes = rawSong.releaseTypes.ifEmpty { COMPILATION_RELEASE_TYPES }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,7 +271,8 @@ private constructor(private val rawSong: RawSong, private val future: Future<Tra
|
||||||
// Compilation Flag
|
// Compilation Flag
|
||||||
(comments["compilation"] ?: comments["itunescompilation"])?.let {
|
(comments["compilation"] ?: comments["itunescompilation"])?.let {
|
||||||
if (it.size != 1 || it[0] != "1") return@let
|
if (it.size != 1 || it[0] != "1") return@let
|
||||||
rawSong.albumArtistNames = rawSong.albumArtistNames.ifEmpty { COMPILATION_ALBUM_ARTISTS }
|
rawSong.albumArtistNames =
|
||||||
|
rawSong.albumArtistNames.ifEmpty { COMPILATION_ALBUM_ARTISTS }
|
||||||
rawSong.releaseTypes = rawSong.releaseTypes.ifEmpty { COMPILATION_RELEASE_TYPES }
|
rawSong.releaseTypes = rawSong.releaseTypes.ifEmpty { COMPILATION_RELEASE_TYPES }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ class SearchEngineImpl @Inject constructor(@ApplicationContext private val conte
|
||||||
// which
|
// which
|
||||||
// could make it match the query.
|
// could make it match the query.
|
||||||
val normalizedName =
|
val normalizedName =
|
||||||
NORMALIZATION_SANITIZE_REGEX.replace(
|
NORMALIZE_POST_PROCESSING_REGEX.replace(
|
||||||
Normalizer.normalize(name, Normalizer.Form.NFKD), "")
|
Normalizer.normalize(name, Normalizer.Form.NFKD), "")
|
||||||
if (normalizedName.contains(query, ignoreCase = true)) {
|
if (normalizedName.contains(query, ignoreCase = true)) {
|
||||||
return@filter true
|
return@filter true
|
||||||
|
@ -115,8 +115,9 @@ class SearchEngineImpl @Inject constructor(@ApplicationContext private val conte
|
||||||
private companion object {
|
private companion object {
|
||||||
/**
|
/**
|
||||||
* Converts the output of [Normalizer] to remove any junk characters added by it's
|
* Converts the output of [Normalizer] to remove any junk characters added by it's
|
||||||
* replacements.
|
* replacements, alongside punctuation.
|
||||||
*/
|
*/
|
||||||
val NORMALIZATION_SANITIZE_REGEX = Regex("\\p{InCombiningDiacriticalMarks}+")
|
val NORMALIZE_POST_PROCESSING_REGEX =
|
||||||
|
Regex("(\\p{InCombiningDiacriticalMarks}+)|(\\p{Punct})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue