Jump to content

Recommended Posts

Posted (edited)

;===============================================================================
; Function Name:   _Grammar_RemovePluralization()
; Description:     Converts Plural to Singular
; Syntax:          _Grammar_RemovePluralization($sStr)
; Parameter(s):    $sStr - String or file to test
; Requirement(s):
; Return Value(s): - Success = Corrected string, @Extended contains the number of changes made
;                  - Failure = Sets @Error to 2 if $sStr is not valid
;                              returns the string ($sStr) if aint or ain't are not found in the string
; Author(s):       David Hatcher (John117) Formerly (Hatcheda)
; Modification(s): Authenticity assisted with StringRegExpReplace
; Note(s):    Additional functionality for Geosoft's Grammar.au3
; Example(s):
#cs
    
#ce
;===============================================================================
Func _Grammar_RemovePluralization($sStr)
    If FileExists($sStr) Then $sStr = FileRead($sStr)
    If Not $sStr Then Return SetError(2, 0)
    Local $iCount = 0
    $sStr = StringReplace($sStr, "alumni", "alumnus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "cacti", "cactus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "focuses", "focus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "foci", "focus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "funguses", "fungus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "fungi", "fungus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "nuclei", "nucleus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "radii", "radius")
    $iCount += @extended
    $sStr = StringReplace($sStr, "stimuli", "stimulus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "axes", "axis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "analyses", "analysis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "bases", "basis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "crises", "crisis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "diagnoses", "diagnosis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "ellipses", "ellipsis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "hypotheses", "hypothesis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "oases", "oasis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "paralyses", "paralysis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "parentheses", "parenthesis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "syntheses", "synthesis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "synopses", "synopsis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "theses", "thesis")
    $iCount += @extended
    $sStr = StringReplace($sStr, "appendices", "appendix")
    $iCount += @extended
    $sStr = StringReplace($sStr, "indexes", "index")
    $iCount += @extended
    $sStr = StringReplace($sStr, "indeces", "index")
    $iCount += @extended
    $sStr = StringReplace($sStr, "matrixes", "matrix")
    $iCount += @extended
    $sStr = StringReplace($sStr, "matrices", "matrix")
    $iCount += @extended
    $sStr = StringReplace($sStr, "beaux", "beau")
    $iCount += @extended
    $sStr = StringReplace($sStr, "bureaux", "bureau")
    $iCount += @extended
    $sStr = StringReplace($sStr, "bureaus", "bureau")
    $iCount += @extended
    $sStr = StringReplace($sStr, "tableaus", "tableau")
    $iCount += @extended
    $sStr = StringReplace($sStr, "tableaux", "tableau")
    $iCount += @extended
    $sStr = StringReplace($sStr, "children", "child")
    $iCount += @extended
    $sStr = StringReplace($sStr, "men", "man")
    $iCount += @extended
    $sStr = StringReplace($sStr, "oxen", "ox")
    $iCount += @extended
    $sStr = StringReplace($sStr, "calves", "calf")
    $iCount += @extended
    $sStr = StringReplace($sStr, "women", "woman")
    $iCount += @extended
    $sStr = StringReplace($sStr, "bacteria", "bacterium")
    $iCount += @extended
    $sStr = StringReplace($sStr, "corpora", "corpus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "criteria", "criterion")
    $iCount += @extended
    $sStr = StringReplace($sStr, "curricula", "curriculum")
    $iCount += @extended
    $sStr = StringReplace($sStr, "data", "datum")
    $iCount += @extended
    $sStr = StringReplace($sStr, "genera", "genus")
    $iCount += @extended
    $sStr = StringReplace($sStr, "media", "medium")
    $iCount += @extended
    $sStr = StringReplace($sStr, "memoranda", "memorandum")
    $iCount += @extended
    $sStr = StringReplace($sStr, "phenomena", "phenomenon")
    $iCount += @extended
    $sStr = StringReplace($sStr, "strata", "stratum")
    $iCount += @extended
    $sStr = StringReplace($sStr, "feet", "foot")
    $iCount += @extended
    $sStr = StringReplace($sStr, "geese", "goose")
    $iCount += @extended
    $sStr = StringReplace($sStr, "teeth", "tooth")
    $iCount += @extended
    $sStr = StringReplace($sStr, "antennas", "antenna")
    $iCount += @extended
    $sStr = StringReplace($sStr, "antennae", "antenna")
    $iCount += @extended
    $sStr = StringReplace($sStr, "formulas", "formula")
    $iCount += @extended
    $sStr = StringReplace($sStr, "formulae", "formula")
    $iCount += @extended
    $sStr = StringReplace($sStr, "nebulae", "nebula")
    $iCount += @extended
    $sStr = StringReplace($sStr, "vertebrae", "vertebra")
    $iCount += @extended
    $sStr = StringReplace($sStr, "vitae", "vita")
    $iCount += @extended
    $sStr = StringReplace($sStr, "mice", "mouse")
    $iCount += @extended
    $sStr = StringReplace($sStr, "pies", "pie")
    $iCount += @extended
    $sStr = StringRegExpReplace($sStr, '(?i)(?<=\w)([^aeiou\W])s\b', '\1')
    $iCount += @extended
    $sStr = StringRegExpReplace($sStr, '(?i)(?<=\w)([^aeiou\W])ies\b', '\1y')
    $iCount += @extended
    SetExtended($iCount)
    Return $sStr
EndFunc   ;==>_Grammar_RemovePluralization

Edited by John117
Posted

axes is also the plural of both ax and axe

analyses is also the plural of analyse

bases is also the plural of base

paralyses is also the plural of paralyse

focus (verb) has the plurals focuses and focusses (esp. Brit. and Can.)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...