I want to check in what combination do these values exist and one condition is that hashtag can not exit alone so the combination is 4C1 + 5C2 + 5C3 + 5C4 + 5C5 that makes up these conditional statements.
I want to know whether there is a more efficient way of doing this by using dictionary methods in python.
My Dictionary
data = { 'all_words': '', 'exact_phrase': '', 'any_words': '', 'not_words': '', 'hashtag': ''}
My conditional statements
if self.all_words is not None and (self.any_words, self.exact_phrase, self.not_words, self.hashtag is None):
c.Search = self.all_words
elif self.any_words is not None and (self.all_words, self.exact_phrase, self.not_words, self.hashtag is None):
c.Search = self.any_words
elif self.exact_phrase is not None and (self.all_words, self.any_words, self.not_words, self.hashtag is None):
c.Search = self.exact_phrase
elif self.hashtag is not None and (self.all_words, self.any_words, self.not_words, self.exact_phrase is None):
c.Search = self.hashtag
elif (self.all_words, self.any_words is not None) and (self.exact_phrase, self.not_words, self.hashtag is None):
c.Search = self.all_words + " " + self.any_words
elif (self.all_words, self.exact_phrase is not None) and (self.any_words, self.not_words, self.hashtag is None):
c.Search = self.all_words + " " + self.exact_phrase
elif (self.all_words, self.not_words is not None) and (self.any_words, self.exact_phrase, self.hashtag is None):
c.Search = self.all_words + " " + self.not_words
elif (self.all_words, self.hashtag is not None) and (self.any_words, self.exact_phrase, self.not_words is None):
c.Search = self.all_words + " " + self.hashtag
elif (self.any_words, self.exact_phrase is not None) and (self.all_words, self.hashtag, self.not_words is None):
c.Search = self.exact_phrase + " " + self.any_words
elif (self.any_words, self.hashtag is not None) and (self.all_words, self.exact_phrase, self.not_words is None):
c.Search = self.any_words + " " + self.hashtag
elif (self.any_words, self.not_words is not None) and (self.all_words, self.exact_phrase, self.hashtag is None):
c.Search = self.any_words + " " + self.not_words
elif (self.exact_phrase, self.hashtag is not None) and (self.all_words, self.any_words, self.not_words is None):
c.Search = self.exact_phrase + " " + self.hashtag
elif (self.exact_phrase, self.not_words is not None) and (self.all_words, self.any_words, self.hashtag is None):
c.Search = self.exact_phrase + " " + self.not_words
elif (self.not_words, self.hashtag is not None) and (self.all_words, self.any_words, self.exact_phrase is None):
c.Search = self.not_words + " " + self.hashtag
elif (self.all_words, self.any_words, self.exact_phrase is not None) and (self.hashtag, self.not_words is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.any_words
elif (self.all_words, self.any_words, self.not_words is not None) and (self.hashtag, self.exact_phrase is None):
c.Search = self.all_words + " " + self.any_words + " " + self.not_words
elif (self.all_words, self.any_words, self.hashtag is not None) and (self.not_words, self.exact_phrase is None):
c.Search = self.all_words + " " + self.any_words + " " + self.hashtag
elif (self.all_words, self.exact_phrase, self.not_words is not None) and (self.any_words, self.hashtag is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.not_words
elif (self.all_words, self.exact_phrase, self.hashtag is not None) and (self.any_words, self.not_words is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.hashtag
elif (self.all_words, self.not_words, self.hashtag is not None) and (self.any_words, self.not_words is None):
c.Search = self.all_words + " " + self.not_words + " " + self.hashtag
elif (self.exact_phrase, self.any_words, self.not_words is not None) and (self.hashtag, self.all_words is None):
c.Search = self.exact_phrase + " " + self.any_words + " " + self.not_words
elif (self.exact_phrase, self.any_words, self.hashtag is not None) and (self.not_words, self.all_words is None):
c.Search = self.exact_phrase + " " + self.any_words + " " + self.hashtag
elif (self.any_words, self.not_words, self.hashtag is not None) and (self.all_words, self.exact_phrase is None):
c.Search = self.any_words + " " + self.not_words + " " + self.hashtag
elif (self.exact_phrase, self.not_words, self.hashtag is not None) and (self.all_words, self.any_words is None):
c.Search = self.exact_phrase + " " + self.not_words + " " + self.hashtag
elif (self.all_words, self.exact_phrase, self.any_words, self.not_words is not None) and (self.hashtag is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.any_words + " " + self.not_words
elif (self.all_words, self.exact_phrase, self.any_words, self.hashtag is not None) and (self.not_words is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.any_words + " " + self.hashtag
elif (self.all_words, self.any_words, self.not_words, self.hashtag is not None) and (self.exact_phrase is None):
c.Search = self.all_words + " " + self.any_words + " " + self.not_words + " " + self.hashtag
elif (self.all_words, self.exact_phrase, self.not_words, self.hashtag is not None) and (self.any_words is None):
c.Search = self.all_words + " " + self.exact_phrase + " " + self.not_words + " " + self.hashtag
elif (self.exact_phrase, self.any_words, self.not_words, self.hashtag is not None) and (self.all_words is None):
c.Search = self.exact_phrase + " " + self.any_words + " " + self.not_words + " " + self.hashtag
elif (self.all_words, self.exact_phrase, self.any_words, self.not_words, self.hashtag) is not None:
c.Search = self.all_words + " " + self.exact_phrase + " " + self.any_words + " " + self.not_words + " " + self.hashtag
Aucun commentaire:
Enregistrer un commentaire