def test_from_error(): bf = BloomFilter.from_error_rate(1000) for ii in range(0, 1000, 20): bf.add(ii) for ii in range(0, 1000, 20): assert ii in bf
def __init__(self, name: Optional[str] = None, data: Optional[dict] = None) -> None: """Initialize a new table. name (str): Optional table name for reference. data (dict): Initial data, used to hint Bloom Filter. DOCS: https://spacy.io/api/lookups#table.init """ OrderedDict.__init__(self) self.name = name # Assume a default size of 1M items self.default_size = 1e6 size = max(len(data), 1) if data is not None else self.default_size self.bloom = BloomFilter.from_error_rate(size) if data: self.update(data)
def __init__(self, name=None, data=None): """Initialize a new table. name (unicode): Optional table name for reference. data (dict): Initial data, used to hint Bloom Filter. RETURNS (Table): The newly created object. DOCS: https://spacy.io/api/lookups#table.init """ OrderedDict.__init__(self) self.name = name # Assume a default size of 1M items self.default_size = 1e6 size = len(data) if data and len(data) > 0 else self.default_size self.bloom = BloomFilter.from_error_rate(size) if data: self.update(data)