Created
May 5, 2012 21:18
-
-
Save kwellman/2605638 to your computer and use it in GitHub Desktop.
Mining twitter blog post (make_regex.py)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def make_regex(query): | |
"""Returns a compiled regex. Use returned object like so regex.search(tweet)""" | |
s = r'(\s\S+){0,2}\s'.join(query.split()) | |
return re.compile(s, re.IGNORECASE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment