I wrote a code in python but I am not sure why it never get match while it should be able, would you mind check what is the issue in my code?
my assumption is my select query creating list of list "('bad' , ), ('worse' , ), but I am not sure how to remove it " ,"
I am using visual studio and python 3.5:
if len(list(set(words) & set(badlst))) > 0:
index +=1
words :(data details) ['term', 'saving', 'insurance', 'cost', '?', 'upgrade', 'plan', 'always', 'preferred', 'client', ',', 'bad', 'agent', 'explained', ...]
badlst : (data details) [('bad',), ('worse',), ('incorrigible',), ('poor',), ('dreadful',), ('atrocious',), ('cheap',), ('unacceptable',), ('sad',), ('lousy',), ('crummy',), ('awful',), ('rough',), ('synthetic',), ...]
I generate badlst as below:
def readInsCmp(column, tablename, whereCondition):
command = "select "+ column+" from "+ tablename +" where "+ whereCondition
c.execute(command)
namelist = c.fetchall()
return namelist
badlst = readInsCmp("distinct(word)","wordVals","value=-1")
Words parameter is based on parse some input from excel file:
sentenceArr = sent_tokenize(content)
for sentence in sentenceArr:
words = [word for word in nltk.word_tokenize(sentence) if word not in stopwords.words('english')]