[Tutor] Difficult loop?
John Fouhy
john at fouhy.net
Thu Oct 16 01:58:51 CEST 2008
2008/10/16 Emad Nawfal (عماد نوفل) <emadnawfal at gmail.com>:
> The focus letter will always be # 6 on the line. A is not a short vowel,
> and it is not followed by a short vowel, so the last character should be
> "_", not a "u"
Oh, I see. I misunderstood the meaning of "followed by". I can fix
that by changing one function in my code:
def nextSV(s, idx):
""" Find the next short vowel, or ~ + short vowel.
s :: string to search
idx :: index to start from
Return: short vowel, or ~ + short vowel, or _ if no following short vowel.
"""
try:
if s[idx+1] in shortVowels:
return s[idx+1]
elif s[idx+1] == double:
return s[idx+1:idx+3]
else:
return '_'
except IndexError:
return '_'
> The purpose of this program is to calculate vector similarities in the
> context of the letters in a machine learning approach called "Memory-based
> learning"
I did wonder what it was for ;-)
--
John.
More information about the Tutor
mailing list