In the process of creating a script generation application, I realized that phrase keywords can be either singular or plural, and in excel, there is no easy way to tell the difference between words. That gave me an idea... a function that would figure out if something is singular or plural. This way I would know that the article to use after a keyword phrase would be "is" if singular or "are" if plural.
English is fairly consistent with plural and singular, with "s" being the key... but not always. Think of words like bus or lens that both end with "s", these are singular not plural. And how about when a keyword phrase includes "with" like a "The bus with a red door"? The correct way to phrase this is "The bus with the red door is big", so it's singular making the noun to identify being the word before the word "with". My code is below:
Public Function isitplural(t As String) As Boolean
Dim w() As String
singwords = Array("bus", "lens", "news", "billiards", "Brussels", "United States", "mumps", "measles", "acoustics", "aerobics", "aerodynamics", "aeronautics", "athletics", "classics", "economics", "electronics", "genetics", "linguistics", "logistics", "mathematics", "mechanics", "obstetrics", "physics", "politics", "statistics", "thermodynamics", "GAMES", "billiards", "bowls", "cards", "darts", "ILLNESSES", "diabetes", "measles", "mumps", "rabies", "draughts", "skittles", "rickets", "shingles")
pluralwords = Array("alumnae", "alumni", "antennae", "bacteria", "bureaux", "cacti", "cherubim", "children", "criteria", "curricula", "data", "days-off", "deer", "dice", "die", "editors-in-chief", "feet", "fish", "foci", "fora", "formulae", "fruit", "fungi", "geese", "hippopotami", "kine", "lice", "media", "men", "mice", "mothers-in-law", "nautili", "nuclei", "octopi", "octopus", "oxen", "people", "phenomena", "salmon", "sheep", "stadia", "stimuli", "stimulus", "supernovae", "syllabi", "teeth ", "tuna", "women", "woodlice")
w() = Split(t, " ")
d = 0
a = w(UBound(w)) 'last word
For Each c In w
If c = "with" Then
a = w(d - 1)
Exit For
End If
d = d + 1
Next
'check if ends with s
If LCase(Right(a, 1)) = "s" Then
'it might be plural, but need to check plural words
isitplural = True
For Each b In singwords
If LCase(a) = LCase(b) Then
' it's probably not pural but a proper noun that ends with s
isitplural = False
'its one of those singular words like lens or bus
Exit Function
End If
Next
Else
isitplural = False
'it still might be plural... check the singwords
For Each b In pluralwords
If LCase(a) = LCase(b) Then
itisplural = True 'it is one of those weird plural words
Exit Function
End If
Next
End If
End Function
I'm still looking for words to add to my array of singular rule breakers or singular words that end with an 's', and I'm still looking for those plural rule breakers... the ones that end with an 's' and aren't plural.