Skip to content

Commit

Permalink
fix typos (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
folkvir committed May 16, 2024
1 parent fcbef8a commit 5b0c613
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 81 deletions.
102 changes: 38 additions & 64 deletions README.md

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion examples/node.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ const items = ['alice', 'bob']
const errorRate = 0.04 // 4 % error rate
filter = bfs.BloomFilter.create(items.length, errorRate)
filter = bfs.BloomFilter.from(items, errorRate)
bfs.BloomFilter.fromJSON(filter.saveAsJSON())
bfs.BloomFilter.fromJSON(filter.saveAsJSON())

bfs.Hashing.lib = {
xxh64: (x, _) => 1n,
xxh128: (x, _) => 1n,
}
filter._hashing._lib = bfs.Hashing.lib
const hashes = filter._hashing.hashTwice('x')
assert(hashes.first === 1n)
assert(hashes.second === 1n)
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"import": "./dist/module/dist/counting-bloom-filter.js",
"require": "./dist/commonjs/dist/counting-bloom-filter.js"
},
"./partitionned-filter.js": {
"import": "./dist/module/dist/partitionned-bloom-filter.js",
"require": "./dist/commonjs/dist/partitionned-bloom-filter.js"
"./partitioned-filter.js": {
"import": "./dist/module/dist/partitioned-bloom-filter.js",
"require": "./dist/commonjs/dist/partitioned-bloom-filter.js"
},
"./scalable-filter.js": {
"import": "./dist/module/dist/scalable-bloom-filter.js",
Expand Down Expand Up @@ -123,7 +123,7 @@
"test:module": "node examples/node.mjs",
"test:lint-build": "yarn lint && yarn build",
"test": "yarn test:lint-build && yarn test:commonjs && yarn test:module && jest",
"doc": "typedoc --sort alphabetical --out docs/ --emit both --includeVersion src/index.ts",
"doc": "typedoc --sort alphabetical --out docs/ --emit both --includeVersion src/**/*.ts",
"clean": "rimraf docs/ dist/module/dist dist/commonjs/dist dist/website/rspack dist/website/webpack"
},
"repository": {
Expand All @@ -136,7 +136,7 @@
"bloom filter",
"probabilistic",
"datastructure",
"partitionned bloom filter",
"partitioned bloom filter",
"scalable bloom filter",
"counting bloom filter",
"invertible bloom filter",
Expand Down
6 changes: 3 additions & 3 deletions src/count-min-sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class CountMinSketch extends BaseFilter implements CountingFilter
/**
* Update the count min sketch with a new occurrence of an element
* @param element - The new element
* @param count - Number of occurences of the elemnt (defauls to one)
* @param count - Number of occurrences of the elemnt (defauls to one)
*/
public update(element: HashableInput, count = 1): void {
this._allSums += count
Expand All @@ -106,9 +106,9 @@ export default class CountMinSketch extends BaseFilter implements CountingFilter
}

/**
* Perform a point query: estimate the number of occurence of an element
* Perform a point query: estimate the number of occurrence of an element
* @param element - The element we want to count
* @return The estimate number of occurence of the element
* @return The estimate number of occurrence of the element
*/
public count(element: HashableInput): number {
let min = Infinity
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/counting-filter.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* A filter that can count occurences of items and estimate their frequencies.
* A filter that can count occurrences of items and estimate their frequencies.
* @author Thomas Minier
* @author Arnaud Grall
*/
export default interface CountingFilter<T> {
/**
* Update the count min sketch with a new occurrence of an element
* @param element - The new element
* @param count - Number of occurences of the elemnt (defauls to one)
* @param count - Number of occurrences of the elemnt (defauls to one)
*/
update(element: T, count: number): void

/**
* Perform a point query: estimate the number of occurence of an element
* Perform a point query: estimate the number of occurrence of an element
* @param element - The element we want to count
* @return The estimate number of occurence of the element
* @return The estimate number of occurrence of the element
*/
count(element: T): number
}
2 changes: 1 addition & 1 deletion src/scalable-bloom-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class ScalableBloomFilter
}

/**
* Create a Scalable Bloom Filter based on Partitionned Bloom Filter.
* Create a Scalable Bloom Filter based on Partitioned Bloom Filter.
* @param _size the starting size of the filter
* @param _error_rate ther error rate desired of the filter
* @param _ratio the tightening ration
Expand Down
6 changes: 3 additions & 3 deletions tests/hyperloglog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('should support update and cardinality estimations (count) operations', ()
)
}
})
test('should peforms the union of two HyperLogLog sketches', () => {
test('should performs the union of two HyperLogLog sketches', () => {
const first = new HyperLogLog(2 ** 4)
const second = new HyperLogLog(2 ** 4)
first.update('alice')
Expand Down Expand Up @@ -115,10 +115,10 @@ test('issue#(https://github.com/Callidon/bloom-filters/issues/69)', () => {
const sketch = new HyperLogLog(128)
// push 10000 distinct elements
const n = 2 ** 14
for (let i = 0; i<n; i++) {
for (let i = 0; i < n; i++) {
sketch.update(i.toString())
}
// count occurrences
expect(sketch.relative_error()).toEqual(1.04 / Math.sqrt(128))
expect(n - sketch.count()).toBeLessThan(n * sketch.relative_error() * 3)
})
})

0 comments on commit 5b0c613

Please sign in to comment.