bloomf-0.3
توضیحات
Simple Bloom Filter implmentation in Python
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bloomf-0.3 |
| نام | bloomf |
| نسخه کتابخانه | 0.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Sambhav Jain |
| ایمیل نویسنده | sambhavjain2612@gmail.com |
| آدرس صفحه اصلی | https://github.com/sambhav2612/karumanchi/tree/master/bloom-filter |
| آدرس اینترنتی | https://pypi.org/project/bloomf/ |
| مجوز | - |
# Bloom Filter
Implemented in Python 3.
- The price we pay for efficiency through bloom filters is that it is probabilistic in nature that means, there might be some **_False Positive_** results. False positive means, it might tell that given username is already taken but actually it’s not.
- Not being **_False Negative_** such that telling that username doesn't exist while it is there, i.e., if exists it reports it's existenece in terms of maybe, else if not present it is 100% confident to report the same.
- Deleting elements from filter is not possible because, if we delete a single element by clearing bits at indices generated by k hash functions, it might cause deletion of few other elements.
## Installation
**`pip install bloomf==0.2`**
Distributed as a [PyPi](https://pypi.org/project/bloomf/) Package.
## Usage
You can use this bloom filter as follows -
```python
from bloomf import BloomFilter
n = 10 # number of items to be added
p = 0.04 # FP Probablity
filter = BloomFilter(n, p)
print("Size of bit array: {}" . format(filter.size))
print("False positive Probability: {}" . format(filter.fp_prob))
print("Number of hash functions: {}" . format(filter.hash_count))
word_present = ['abound', 'abounds', 'abundance', 'abundant', 'accessable', 'bloom', 'blossom', 'bolster', 'bonny', 'bonus', 'bonuses']
word_absent = ['bluff', 'cheater', 'hate', 'war', 'humanity', 'racism', 'hurt', 'facebook', 'sambhav', 'twitter']
for i in word_present:
filter.add(i)
test_words = word_present[:5] + word_absent
for word in test_words:
if filter.check(word):
if word in word_absent:
print("'{}' is a false positive!" . format(word))
else:
print("'{}' is a probably present!" . format(word))
else:
print("'{}' is 100% not present!" . format(word))
```
### Dependencies
- bitarray
- mmh3
نحوه نصب
نصب پکیج whl bloomf-0.3:
pip install bloomf-0.3.whl
نصب پکیج tar.gz bloomf-0.3:
pip install bloomf-0.3.tar.gz