Skip to content

Commit

Permalink
Improve capital letters preservation
Browse files Browse the repository at this point in the history
Change-Id: Iab2f2baeef66771880aeb689121b66f80ab4482a
  • Loading branch information
sentinelt committed Jul 10, 2021
1 parent 8ff9a8b commit c65960c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/atteo/evo/inflector/English.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,20 @@ public English(MODE mode) {
});

// Words ending in -y take -ys
rule(new String[][] { { "([aeiou])y$", "$1ys" }, { "y$", "ies" }, });
rule(new String[][] { { "([aeiou]y)$", "$1s" }, { "y$", "ies" }, });

// Some words ending in -o take -os (including does preceded by a vowel)
categoryRule(CATEGORY_O_I, "o", "os");
categoryRule(CATEGORY_O_OS, "o", "os");
rule("([aeiou])o$", "$1os");
rule("([aeiou]o)$", "$1s");
// The rest take -oes
rule("o$", "oes");
rule("(o)$", "$1es");

rule("ulum$", "ula");
rule("(ul)um$", "$1a");

categoryRule(CATEGORY_A_ATA, "", "es");

rule("s$", "ses");
rule("(s)$", "$1es");

// Return empty string for empty string input
rule("^$", "");
Expand Down
20 changes: 16 additions & 4 deletions src/test/java/org/atteo/evo/inflector/EnglishInflectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,12 @@ public void exampleWordList() {
{ "quick_chateau", "quick_chateaus" },
{ "codex", "codices" },
{ "index", "indexes" },
{ "NightWolf", "NightWolves" },
{ "Milieu", "Milieus" },
{ "basis", "bases" },
{ "iris", "irises" },
{ "phalanx", "phalanxes" },
{ "tempo", "tempos" },
{ "foot", "feet" },
{ "series", "series" },
{ "WorldAtlas", "WorldAtlases" },
{ "wish", "wishes" },
{ "Bacterium", "Bacteria" },
{ "medium", "mediums" },
Expand All @@ -184,8 +181,23 @@ public void exampleWordList() {
{ "todo", "todos"},
{ "person", "persons"},
{ "baculumulum", "baculumula" }, // https://github.com/atteo/evo-inflector/pull/18
{ "", "" }
{ "", "" },
});
}

@Test
public void shouldPreserveCapitalLetters() {
check(new String[][] {
{ "Milieu", "Milieus" },
{ "NightWolf", "NightWolves" },
{ "WorldAtlas", "WorldAtlases" },
{ "SMS", "SMSes" },
{ "bacuLum", "bacuLa" },
{ "alO", "alOes" },
{ "luO", "luOs" },
{ "boY", "boYs" },
});

}

@Test
Expand Down

0 comments on commit c65960c

Please sign in to comment.