Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# to check if keyswords like 'programs','schemes', etc. present in sentences
def prog_sent(text):
patterns = [r'\b(?i)'+'plan'+r'\b',
r'\b(?i)'+'programme'+r'\b',
r'\b(?i)'+'scheme'+r'\b',
r'\b(?i)'+'campaign'+r'\b',
r'\b(?i)'+'initiative'+r'\b',
r'\b(?i)'+'conference'+r'\b',
r'\b(?i)'+'agreement'+r'\b',
r'\b(?i)'+'alliance'+r'\b']
output = []
flag = 0
for pat in patterns:
if re.search(pat, text) != None:
flag = 1
break
return flag
# apply function
df2['Check_Schemes'] = df2['Sent'].apply(prog_sent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment