the objective is to extract from the text the sentences before the word Definition or indications
def extract(doc):
if( len(doc) != 0 ):
if ('Definition' in doc):
sentence = doc.split('Definition')[0]
elif ('Definition' not in doc and 'indications' in doc):
sentence = doc.split('indications')[0]
return sentence
else :
return doc
It return error : UnboundLocalError: local variable 'sentence' referenced before assignment