feat: add implementation of name sorting with transliteration
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package org.oxycblt.musikr.tag.interpret
|
package org.oxycblt.musikr.tag.interpret
|
||||||
|
|
||||||
|
import android.icu.text.Transliterator
|
||||||
|
import android.os.Build
|
||||||
import java.text.CollationKey
|
import java.text.CollationKey
|
||||||
import java.text.Collator
|
import java.text.Collator
|
||||||
import org.oxycblt.musikr.tag.Name
|
import org.oxycblt.musikr.tag.Name
|
||||||
@@ -84,7 +86,7 @@ private data class IntelligentKnownName(override val raw: String, override val s
|
|||||||
private fun parseTokens(name: String): List<Token> {
|
private fun parseTokens(name: String): List<Token> {
|
||||||
// TODO: This routine is consuming much of the song building runtime, find a way to
|
// TODO: This routine is consuming much of the song building runtime, find a way to
|
||||||
// optimize it
|
// optimize it
|
||||||
val stripped =
|
var stripped =
|
||||||
name
|
name
|
||||||
// Remove excess punctuation from the string, as those usually aren't
|
// Remove excess punctuation from the string, as those usually aren't
|
||||||
// considered in sorting.
|
// considered in sorting.
|
||||||
@@ -101,6 +103,13 @@ private data class IntelligentKnownName(override val raw: String, override val s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transliterate to latin if available
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Transliterator.getAvailableIDs()
|
||||||
|
.toList().contains("Any-Latin")
|
||||||
|
) {
|
||||||
|
stripped = Transliterator.getInstance("Any-Latin;").transliterate(stripped)
|
||||||
|
}
|
||||||
|
|
||||||
// To properly compare numeric components in names, we have to split them up into
|
// To properly compare numeric components in names, we have to split them up into
|
||||||
// individual lexicographic and numeric tokens and then individually compare them
|
// individual lexicographic and numeric tokens and then individually compare them
|
||||||
// with special logic.
|
// with special logic.
|
||||||
|
|||||||
Reference in New Issue
Block a user