Created
October 9, 2012 14:42
-
-
Save language-engineering/3859257 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 gzip, os | |
| #Create an empty set ready to be filled with dictionary terms | |
| urban_dictionary = set() | |
| #Get a file pointer to the compressed file containing urban dictionary terms | |
| f = gzip.open(os.path.join('t:\\','Departments','Informatics','LanguageEngineering','data','UrbanDictionary','terms.gz')) | |
| #Fill set with urban dictionary entries | |
| for line in f: | |
| urban_dictionary.add(line.strip()) | |
| #Close the file | |
| f.close() | |
| #Example usage: | |
| if "amazeballs" in urban_dictionary: | |
| print "'amazeballs' is in the dictionary!" | |
| else: | |
| print "'amazeballs' is not in the dictionary!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment