Last active
June 1, 2024 20:38
-
-
Save atrinh0/c7817dc2619d2ae00a021273e45843db to your computer and use it in GitHub Desktop.
Foundation Pluraliser Potential Issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ | |
// 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Radar raised:
FB9149411