我正在编写一个 Scala 方法来复数字符串:
def plural(value: String) = {
value match {
case "fish" | "dice" | "sheep" => value
case "foot" => value.dropRight(3) + "eet"
case "woman" | "man" => value.dropRight(2) + "en"
case "tooth" => value.dropRight(4) + "eeth"
case _ => value.takeRight(2).toLowerCase() match {
case "sh" | "ch" => value + "es"
case "ay" => value + "s"
case _ => value.takeRight(1).toLowerCase() match {
case "s" => value + "es"
case "y" => value.dropRight(1) + "ies"
case _ => value + "s"
}
}
}
}
这显然没有涵盖英语中的所有特殊情况。我想知道是否存在为此的库方法?(并用于查找复数字符串的可能单数集合)。
在此先感谢您的帮助。