I am trying to do something very simple - I have a dictionary (sentence_dict) where the values are either a single sentence or a list of sentences. I am trying to check if two names are in a sentence and if so, create a new dictionary with that sentence as the value and the original sentence_dict key as the key.
However, when I try to do:
from nltk.tokenize import sent_tokenize
name1 = 'Trump'
name2 = 'Gates'
mentioned_text_dict = {}
for k, v in sentence_dict.iteritems():
for i in v:
if name1 and name2 in i:
mentioned_text_dict[k] = i
My resulting dictionary has values that are sentences with EITHER name1 or name2, not both.
Any help would be greatly appreciated.