Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created June 5, 2020 20:46
Show Gist options
  • Save aniruddha27/5904380db5ef63ee3edc97cb267c4fd7 to your computer and use it in GitHub Desktop.
Save aniruddha27/5904380db5ef63ee3edc97cb267c4fd7 to your computer and use it in GitHub Desktop.
# 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