Skip to content

Instantly share code, notes, and snippets.

@language-engineering
Created October 9, 2012 14:42
Show Gist options
  • Select an option

  • Save language-engineering/3859257 to your computer and use it in GitHub Desktop.

Select an option

Save language-engineering/3859257 to your computer and use it in GitHub Desktop.
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