I am missing something about how recursion work in Python. I have put in place the following method in place to tokenize a sentence:
def extractIngredientInfo(ingredientLine, sectionTitle):
print 'extractIngredientInfo' + ingredientLine
# set-up some default values for variables that will contains the extracted datas
usmeas = 'N.A'
othermeas = 'N.A'
p_ingredientalt = re.compile('\(or\s(.*?)\)')
malt = p_ingredientalt.search(ingredientLine)
if malt:
ingredientAlt = malt.group(1)
ingredientLine = ingredientLine.replace(malt.group(0), '').strip()
print 'NEW LINE TO TREAT(ALT)' + ingredientLine
extractIngredientInfo(ingredientLine, sectionTitle)
usmeas,othermeas = extractOneIngredientInfo(ingredientAlt)
print 'MALT'
ingredient
yield usmeas, othermeas
#return;
p_ingredientpurpose = re.compile('\(for\s(.*?)\)')
mpurpose = p_ingredientpurpose.search(ingredientLine)
if mpurpose:
ingredientPurpose = mpurpose.group(1)
ingredientLine = ingredientLine.replace(mpurpose.group(0), '').strip()
print 'NEW LINE TO TREAT(FOR)' + ingredientLine
extractIngredientInfo(ingredientLine, sectionTitle)
usmeas,othermeas = extractOneIngredientInfo(ingredientPurpose)
print 'MPURPOSE'
yield usmeas,othermeas
#return;
usmeas,othermeas = extractOneIngredientInfo(ingredientLine)
print 'FINAL'
yield usmeas, othermeas
when i am making a calling to this function, I have a match for malt
which should lead to an immediate call to the recursive function extractIngredientInfo
but this never happening (I don't see the second call to print 'extractIngredientInfo' + ingredientLine
. Is there any specific reason this is not happening?