forked from brinkar/bloomdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindict
executable file
·29 lines (22 loc) · 807 Bytes
/
indict
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env python
# -*- python -*-
"""Prints out whether words might be in the dictionary or not."""
import sys, gzip, cPickle
import bloom
# Poor man's argument handling
skipMisses = '-s' in sys.argv
if skipMisses:
sys.argv.remove ('-s')
wordstocheck = sys.argv[1:]
# Load up our special data structure. cPickle loads up a preexisting
# BloomFilter object from disk and returns it to us. The class is
# implemented in bloom.py.
bf = cPickle.load (gzip.GzipFile ('dictbf.dat.gz', 'rb', 9))
# Compute the false-positive rate of the filter.
# FIXME: do something useful with this number?
fp = bf.fprate ()
for word in wordstocheck:
if bf.maycontain (word):
print word, 'MIGHT BE in the dictionary'
elif not skipMisses:
print word, 'is DEFINITELY NOT in the dictionary'