def general_inquirer_features(phrase): features = {} #Add General Inquirer Features lastTags = None tagDict = defaultdict(lambda: 0) for word in phrase: #print word negated = ('_neg' in word) if negated: word = word[:-4] weight = 1 if not negated else 0 wordTags = lexInq.getTags(word) #print 'wordTags: ', wordTags if wordTags != None: for tag in wordTags: #print '\t', tag tagDict[tag] += weight lastTags = wordTags #print #print 'tagDict: ', tagDict for key in tagDict: if tagDict[key] > 0: features[('Tag-count', key)] = tagDict[key] if lastTags != None: for tag in lastTags: features[('Tag-last', tag)] = 1 return features
def general_inquirer_features(phrase): features = {} #Add General Inquirer Features lastTags = None tagDict = defaultdict(lambda:0) for word in phrase: #print word negated = ('_neg' in word) if negated: word = word[:-4] weight = 1 if not negated else 0 wordTags = lexInq.getTags(word) #print 'wordTags: ', wordTags if wordTags != None: for tag in wordTags: #print '\t', tag tagDict[tag] += weight lastTags = wordTags #print #print 'tagDict: ', tagDict for key in tagDict: if tagDict[key] > 0: features[('Tag-count',key)] = tagDict[key] if lastTags != None: for tag in lastTags: features[('Tag-last',tag)] = 1 return features
def general_inquirer_features(phrase): features = {} tagDict = defaultdict(lambda: 0) # Add General Inquirer Features lastTags = None # tagDict = lexInq.getBlankDict() for word in phrase: print word wordTags = lexInq.getTags(word) if wordTags != None: for tag in wordTags: print "\t", tag tagDict[tag] += 1 lastTags = wordTags print for key in tagDict: if tagDict[key] > 0: features[("Tag-count", key)] = tagDict[key] if lastTags != None: for tag in lastTags: features[("Tag-last", tag)] = 1 return features
def general_inquirer_features(phrase): features = {} tagDict = defaultdict(lambda: 0) #Add General Inquirer Features lastTags = None #tagDict = lexInq.getBlankDict() for word in phrase: print word wordTags = lexInq.getTags(word) if wordTags != None: for tag in wordTags: print '\t', tag tagDict[tag] += 1 lastTags = wordTags print for key in tagDict: if tagDict[key] > 0: features[('Tag-count', key)] = tagDict[key] if lastTags != None: for tag in lastTags: features[('Tag-last', tag)] = 1 return features