1
0
Fork 0
mirror of https://github.com/ethauvin/kotlin-pluralizer.git synced 2025-04-24 16:27:12 -07:00

check uncountables against the lower-cased string

This commit is contained in:
Marwan 2017-01-29 12:58:39 -05:00
parent 322fdd6d0e
commit 3177a1ff16

View file

@ -45,7 +45,7 @@ fun String.singularize(count: Int): String {
} }
private fun String.pluralizer(): String { private fun String.pluralizer(): String {
if (unCountable().contains(this)) return this if (unCountable().contains(this.toLowerCase())) return this
val rule = pluralizeRules().last { Pattern.compile(it.component1(), Pattern.CASE_INSENSITIVE).matcher(this).find() } val rule = pluralizeRules().last { Pattern.compile(it.component1(), Pattern.CASE_INSENSITIVE).matcher(this).find() }
var found = Pattern.compile(rule.component1(), Pattern.CASE_INSENSITIVE).matcher(this).replaceAll(rule.component2()) var found = Pattern.compile(rule.component1(), Pattern.CASE_INSENSITIVE).matcher(this).replaceAll(rule.component2())
val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) } val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) }
@ -56,7 +56,7 @@ private fun String.pluralizer(): String {
} }
private fun String.singularizer(): String { private fun String.singularizer(): String {
if (unCountable().contains(this)) { if (unCountable().contains(this.toLowerCase())) {
return this return this
} }
val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) } val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) }