Skip to content

Instantly share code, notes, and snippets.

@ravikiranj
Created May 8, 2012 21:46
Show Gist options
  • Select an option

  • Save ravikiranj/2639637 to your computer and use it in GitHub Desktop.

Select an option

Save ravikiranj/2639637 to your computer and use it in GitHub Desktop.
Extract Features Method
#get feature list stored in a file (for reuse)
featureList = getFeatureList('data/sampleTweetFeatureList.txt')
#start extract_features
def extract_features(tweet):
tweet_words = set(tweet)
features = {}
for word in featureList:
features['contains(%s)' % word] = (word in tweet_words)
return features
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment