Regex Syllables, Harlan Grove?

P

PJ

Good Morning, I am not very sofisticated when it comes to these
things,is there a way to count syllables using regex. If I had the
word "understand" in A1 I would like it to return 3. I need to do this
for a reader reliablility formula that I am working on. Any help would
be greatly appreciated. Thanks in advance!
 
T

Tom Hutchins

I can't help you with regex, but you could use the following user-defined
function to count the vowels in a cell:

Public Function CountVowels(TxtIn As String) As Long
Dim x As Long
CountVowels = 0
For x = 1 To Len(TxtIn)
Select Case UCase(Mid(TxtIn, x, 1))
Case "A", "E", "I", "O", "U"
CountVowels = CountVowels + 1
Case Else
'do nothing
End Select
Next x
End Function

This code should be palced in a general VBA module in your workbook.

You would call it like this (enter as a formula in a cell):

=CountVowels(A1)

If you are new to user-defined functions (macros), this link to Jon
Peltier's site may be helpful:
http://peltiertech.com/WordPress/2008/03/09/how-to-use-someone-elses-macro/

Hope this helps,

Hutch
 
G

Glenn

Not sure that helps with a word like "house".

Tom said:
I can't help you with regex, but you could use the following user-defined
function to count the vowels in a cell:

Public Function CountVowels(TxtIn As String) As Long
Dim x As Long
CountVowels = 0
For x = 1 To Len(TxtIn)
Select Case UCase(Mid(TxtIn, x, 1))
Case "A", "E", "I", "O", "U"
CountVowels = CountVowels + 1
Case Else
'do nothing
End Select
Next x
End Function

This code should be palced in a general VBA module in your workbook.

You would call it like this (enter as a formula in a cell):

=CountVowels(A1)

If you are new to user-defined functions (macros), this link to Jon
Peltier's site may be helpful:
http://peltiertech.com/WordPress/2008/03/09/how-to-use-someone-elses-macro/

Hope this helps,

Hutch
 
H

Harlan Grove

PJ said:
Good Morning, I am not very sofisticated when it comes to these
things,is there a way to count syllables using regex. If I had the
word "understand" in A1 I would like it to return 3. I need to do this
for a reader reliablility formula that I am working on. Any help would
be greatly appreciated. Thanks in advance!

Can't do this with regular expressions.

Since most languages using single phoneme alphabets (e.g., Latin,
Cyrillic, Greek, Arabic) have no consistent rules with regard to
dividing words into syllables, there's no alternative to looking up
words in a dictionary list to determine the number of syllables. The
dictionary list would need to look something like

the the
foobar foo bar
banana ba na na

that is, the word in the first field, the syllables in the subsequent
fields, so the number of syllables equals the number of fields in the
matching record less one.
 
P

PJ

Can't do this with regular expressions.

Since most languages using single phoneme alphabets (e.g., Latin,
Cyrillic, Greek, Arabic) have no consistent rules with regard to
dividing words into syllables, there's no alternative to looking up
words in a dictionary list to determine the number of syllables. The
dictionary list would need to look something like

the     the
foobar  foo     bar
banana  ba      na      na

that is, the word in the first field, the syllables in the subsequent
fields, so the number of syllables equals the number of fields in the
matching record less one.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top