# Task 2: English Plural Nouns
GREEK = {
"criteria": ("criteri", "criterion"),
"phenomena": ("phenomen", "phenomenon"),
"analyses": ("analys", "analysis"),
"oases": ("oas", "oasis")
}
def analyse(plural):
word = plural.strip()
if not word:
return "", ""
low = word.lower()
capital = word[0].isupper()
def fix(text):
return text.capitalize() if capital else text
# Special plural forms
if low in GREEK:
stem, lemma = GREEK[low]
return fix(stem), fix(lemma)
# Find the singular stem
if low.endswith("ies"):
stem = low[:-2]
elif low.endswith("ves"):
stem = low[:-2]
elif low.endswith("oes"):
stem = low[:-2]
elif low.endswith("es"):
stem = low[:-2]
elif low.endswith("s"):
stem = low[:-1]
else:
stem = low
# Find the singular lemma
if low.endswith("ves"):
lemma = stem[:-1] + "fe"
elif low.endswith("ies"):
lemma = stem[:-1] + "y"
else:
lemma = stem
return fix(stem), fix(lemma)
if __name__ == "__main__":
words = [
"Wives", "Knives", "analyses", "oases",
"babies", "countries", "criteria",
"Phenomena", "toys", "Cats",
"boxes", "potatoes"
]
print(f"{'Plural':<12}{'Stem':<12}{'Lemma'}")
for word in words:
stem, lemma = analyse(word)
print(f"{word:<12}{stem:<12}{lemma}")