Skip to content

Instantly share code, notes, and snippets.

@atrinh0
Last active June 1, 2024 20:38
Show Gist options
  • Save atrinh0/c7817dc2619d2ae00a021273e45843db to your computer and use it in GitHub Desktop.
Save atrinh0/c7817dc2619d2ae00a021273e45843db to your computer and use it in GitHub Desktop.
Foundation Pluraliser Potential Issues
import SwiftUI
struct ContentView: View {
// sample of data was compiled using the following sources:
// https://birdgei.com/2011/08/30/list-of-100-irregular-plural-nouns-in-english/
// https://www.grammarly.com/blog/plural-nouns/
// https://www.thoughtco.com/irregular-plural-nouns-in-english-1692634
// https://www.ef.co.uk/english-resources/english-grammar/singular-and-plural-nouns/
// google
// apologies for any vulgar language in the sample set
// also for any confusion that may arise from American/English spelling differences
// there are multiple accepted forms of spelling
// this script will only highlight those that do not have any matches
let samples = [
"abyss,abysses",
"addendum,addenda,addendums",
"aircraft,aircraft",
"alumna,alumnae",
"alumnus,alumni",
"analysis,analyses",
"anathema,anathemata,anathemas",
"antenna,antennae,antennas",
"antithesis,antitheses",
"apex,apices,apexes",
"appendix,appendices",
"aquarium,aquaria,aquariums",
"arch,arches",
"atlas,atlases",
"automaton,automata",
"axe,axes",
"axis,axes",
"baby,babies",
"bacillus,bacilli",
"bacterium,bacteria",
"basis,bases",
"batch,batches",
"beach,beaches",
"beau,beaux,beaus",
"belief,beliefs",
"bison,bison",
"blitz,blitzes",
"boy,boys",
"brush,brushes",
"buffalo,buffalo,buffaloes,buffalos",
"bureau,bureaux,bureaus",
"bus,buses",
"cactus,cactuses,cacti",
"calf,calves",
"campus,campuses",
"cat,cats",
"cat-o’-nine-tail,cat-o’-nine-tails",
"cello,celli,cellos",
"census,censuses",
"château,châteaux,châteaus",
"chef,chefs",
"cherry,cherries",
"chief,chiefs",
"chief of staff,chiefs of staff",
"child,children",
"church,churches",
"circus,circuses",
"city,cities",
"cod,cod",
"codex,codices",
"concerto,concerti,concertos",
"copy,copies",
"corpus,corpora",
"corrigendum,corrigenda",
"crisis,crises",
"criterion,criteria,criterions",
"curriculum,curricula,curriculums",
"datum,data",
"deer,deers,deer",
"diagnosis,diagnoses",
"dictionary,dictionaries",
"die,dice,dies",
"dogma,dogmata,dogmas",
"domino,dominoes",
"dormouse,dormice",
"duck,ducks",
"dwarf,dwarves,dwarfs",
"echo,echoes",
"elf,elves",
"ellipsis,ellipses",
"emphasis,emphases",
"encyclopedia,encyclopedias",
"erratum,errata",
"family,families",
"faux pas,faux pas",
"fax,faxes",
"fez,fezzes,fezes",
"fish,fish,fishes",
"flush,flushes",
"fly,flies",
"focus,foci,focuses",
"foot,feet,foot",
"formula,formulae,formulas",
"forum,forums",
"fungus,fungi,funguses",
"gas,gasses,gases",
"genesis,geneses",
"genus,genera,genuses",
"goose,geese",
"governor-general,governors-general,governor-generals",
"graffito,graffiti",
"grouse,grouse,grouses",
"half,halves",
"halo,halos",
"head of state,heads of states,heads of state",
"hero,heroes",
"hippopotamus,hippopotami,hippopotamuses",
"hoax,hoaxes",
"hoof,hooves,hoofs",
"house,houses",
"hypothesis,hypotheses",
"index,indices,indexes",
"iris,irises",
"jack-in-the-box,jacks-in-the-box,jack-in-the-boxes",
"jack-o’-lantern,jack-o’-lanterns",
"kiss,kisses",
"knife,knives",
"lady,ladies",
"larva,larvae,larvas",
"leaf,leaves",
"lemma,lemmata,lemmas",
"libretto,libretti,librettos",
"life,lives",
"loaf,loaves",
"locus,loci",
"louse,lice",
"lunch,lunches",
"man,men",
"man-child,men-children",
"mango,mangoes",
"manservant,menservants",
"marsh,marshes",
"matrix,matrices,matrixes",
"medium,media,mediums",
"memorandum,memorandums,memoranda",
"mess,messes",
"millennium,millennia",
"minutia,minutiae",
"moose,moose",
"motto,mottoes,mottos",
"mouse,mice",
"nanny,nannies",
"nebula,nebulae,nebulas",
"nemesis,nemeses",
"neurosis,neuroses",
"nucleus,nuclei,nucleuses",
"nuptial,nuptials",
"oasis,oases",
"octopus,octopuses,octopi,octopodes",
"offspring,offspring,offsprings",
"opus,opera,opuses",
"ovum,ova",
"ox,oxen,ox",
"parenthesis,parentheses",
"party,parties",
"pass,passes",
"passerby,passersby",
"penny,pennies",
"person,people",
"phalanx,phalanges,phalanxes",
"phenomenon,phenomena,phenomenons",
"photo,photos",
"phylum,phyla",
"piano,pianos",
"pike,pike",
"plateau,plateaux,plateaus",
"platypus,platypuses,platypi,platypodes",
"polyhedron,polyhedra,polyhedrons",
"poppy,poppies",
"potato,potatoes",
"prospectus,prospectuses",
"puppy,puppies",
"quiz,quizzes",
"radius,radii,radiuses",
"ray,rays",
"referendum,referenda,referendums",
"reflex,reflexes",
"roof,roofs",
"runner-up,runners-up",
"salmon,salmon,salmons",
"samurai,samurai",
"scarf,scarves,scarfs",
"schema,schemata,schemas",
"scratch,scratches",
"self,selves",
"series,series",
"sheaf,sheaves",
"sheep,sheep",
"shelf,shelves",
"shrimp,shrimp,shrimps",
"son of a bitch,sons of bitches",
"son-in-law,sons-in-law",
"species,species",
"spectrum,spectra",
"splash,splashes",
"spy,spies",
"squid,squid,squids",
"status,statuses",
"stigma,stigmata,stigmas",
"stimulus,stimuli",
"stitch,stitches",
"stoma,stomata,stomas",
"story,stories",
"stratum,strata",
"stylus,styli",
"succubus,succubi",
"swine,swine,swines",
"syllabus,syllabi,syllabuses",
"symposium,symposia,symposiums",
"synopsis,synopses",
"tableau,tableaux,tableaus",
"tax,taxes",
"terminus,termini,terminuses",
"testis,testes",
"thesis,theses",
"thief,thieves",
"tiding,tidings",
"tomato,tomatoes",
"tooth,teeth",
"tornado,tornadoes",
"trout,trout,trouts",
"truss,trusses",
"try,tries",
"tuna,tuna,tunas",
"uterus,uteri,uteruses",
"vertebra,vertebrae,vertebras",
"vertex,vertices,vertexes",
"victual,victuals",
"virus,viruses",
"viscus,viscera",
"vita,vitae",
"volcano,volcanoes,volcanos",
"vortex,vortices,vortexes",
"waltz,waltzes",
"wash,washes",
"watch,watches",
"wharf,wharves,wharfs",
"wife,wives",
"will-o’-the-wisp,will-o’-the-wisps",
"wolf,wolves",
"woman,women"
]
var body: some View {
NavigationView {
List(potentialIssues()) { issue in
issue.text
}
.navigationTitle("Potential Pluraliser Issues")
.navigationBarTitleDisplayMode(.inline)
}
}
func potentialIssues() -> [IdentifiableText] {
samples.compactMap { sample in
let components = sample.components(separatedBy: ",")
let singular = components[0]
let plural = components[1]
let pluralForm = AttributedString(localized: "^[\(2) \(singular)](inflect: true)")
.description
.components(separatedBy: " {")[0]
let expectedPluralForm = "2 \(plural)"
var expectedString = expectedPluralForm
if pluralForm == expectedPluralForm {
return nil
}
if components.count == 3 {
let expectedPluralForm2 = "2 \(components[2])"
expectedString += " or \(expectedPluralForm2)"
if pluralForm == expectedPluralForm2 {
return nil
}
}
if components.count == 4 {
let expectedPluralForm3 = "2 \(components[3])"
expectedString += " or \(expectedPluralForm3)"
if pluralForm == expectedPluralForm3 {
return nil
}
}
print("\(singular)\n\(expectedString) (expected)\n\(pluralForm) (was returned)\n\n")
return IdentifiableText(text: Text("**\(singular)**\n\(expectedString) (expected)\n\(pluralForm) (was returned)"))
}
}
}
struct IdentifiableText: Identifiable {
let id = UUID()
let text: Text
}
@atrinh0
Copy link
Author

atrinh0 commented Jun 9, 2021

Screenshot 2021-06-10 at 11 12 14

@atrinh0
Copy link
Author

atrinh0 commented Jun 9, 2021

Output

antithesis
2 antitheses (expected)
2 antitheses' (was returned)


appendix
2 appendices (expected)
2 appendix (was returned)


axe
2 axes (expected)
2 axe (was returned)


axis
2 axes (expected)
2 axis (was returned)


bison
2 bison (expected)
2 bison's (was returned)


buffalo
2 buffalo or 2 buffalos (expected)
2 buffaloes (was returned)


cat-o’-nine-tail
2 cat-o’-nine-tails (expected)
2 cats-o’-nines-tails (was returned)


château
2 châteaux or 2 châteaus (expected)
2 châteaux's (was returned)


chief
2 chiefs (expected)
2 chiefs' (was returned)


chief of staff
2 chiefs of staff (expected)
2 chiefs' of staffs (was returned)


cod
2 cod (expected)
2 cod's (was returned)


corrigendum
2 corrigenda (expected)
2 corrigendum (was returned)


die
2 dice or 2 dies (expected)
2 die (was returned)


encyclopedia
2 encyclopedias (expected)
2 encyclopedia (was returned)


fish
2 fish or 2 fishes (expected)
2 fish's (was returned)


focus
2 foci or 2 focuses (expected)
2 focus (was returned)


genesis
2 geneses (expected)
2 genesis (was returned)


governor-general
2 governors-general or 2 governor-generals (expected)
2 governors-generals (was returned)


graffito
2 graffiti (expected)
2 graffito (was returned)


jack-in-the-box
2 jacks-in-the-box or 2 jack-in-the-boxes (expected)
2 jacks-in-the-boxes (was returned)


jack-o’-lantern
2 jack-o’-lanterns (expected)
2 jacks-o’-lanterns (was returned)


lemma
2 lemmata or 2 lemmas (expected)
2 lemma (was returned)


manservant
2 menservants (expected)
2 manservant (was returned)


moose
2 moose (expected)
2 moose's (was returned)


nanny
2 nannies (expected)
2 nanny (was returned)


ovum
2 ova (expected)
2 ovum (was returned)


passerby
2 passersby (expected)
2 passerby's (was returned)


penny
2 pennies (expected)
2 penny (was returned)


pike
2 pike (expected)
2 pikes (was returned)


samurai
2 samurai (expected)
2 samurais (was returned)


schema
2 schemata or 2 schemas (expected)
2 schema (was returned)


series
2 series (expected)
2 series' (was returned)


sheaf
2 sheaves (expected)
2 sheafed (was returned)


sheep
2 sheep (expected)
2 sheep's (was returned)


son of a bitch
2 sons of bitches (expected)
2 sons of a bitch (was returned)


son-in-law
2 sons-in-law (expected)
2 sons-in-laws (was returned)


species
2 species (expected)
2 species' (was returned)


stylus
2 styli (expected)
2 styluses (was returned)


succubus
2 succubi (expected)
2 succubus (was returned)


testis
2 testes (expected)
2 testis (was returned)


tiding
2 tidings (expected)
2 tided (was returned)


trout
2 trout or 2 trouts (expected)
2 trout's (was returned)


victual
2 victuals (expected)
2 victual (was returned)


vita
2 vitae (expected)
2 vita (was returned)


will-o’-the-wisp
2 will-o’-the-wisps (expected)
2 wills-o’-the-wisps (was returned)

@atrinh0
Copy link
Author

atrinh0 commented Jun 10, 2021

Radar raised: FB9149411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment