class ngrams_engine_t API
Classngrams_engine_tQueries filed at one or more N-gram widths, overlapped with any number of candidate batches, and sketching any batch of texts at those widths.8
ngrams_engine_tHolds nothing, so every verb refuses.
ngrams_engine_t() noexcept=default; ngrams_engine_t(ngrams_engine_t && other) noexcept; operator=
ngrams_engine_t & operator=(ngrams_engine_t && other) noexcept; ~ngrams_engine_t
~ngrams_engine_t() noexcept; queries_countQueries filed, the first axis of every overlap output, or zero to only sketch.
std::size_t queries_count() const noexcept; widths_countWindow widths, the last axis of every overlap output.
std::size_t widths_count() const noexcept; overlapsShares of every query's distinct N-grams each candidate holds, per width, into a [queries, candidates, widths] block with a unit-strided width axis.
status_t overlaps(
strings_view_t candidates,
float radius,
std::span<float> shares,
std::size_t shares_query_stride,
std::size_t shares_candidate_stride,
sz_stream_t stream = nullptr) noexcept; Parameters
candidates | in | The texts probed against the queries. |
|---|---|---|
radius | in | The share of a query's distinct N-grams a pair may miss and stay exact. |
shares | out | The block, device-reachable on a device. |
shares_query_stride | in | Bytes from one query's plane to the next. |
shares_candidate_stride | in | Bytes from one candidate's row to the next. |
stream | in | Null on the CPU, or the stream of the engine's device. |
Statuses
unexpected_dimensions_ksharesis shorter than the block.
sketchesOne MinHash sketch of slots bytes per text of texts, at the engine's widths.
status_t sketches(
strings_view_t texts,
std::size_t slots,
std::span<std::uint8_t> sketches,
std::size_t sketches_stride,
sz_stream_t stream = nullptr) noexcept; Parameters
texts | in | The texts to sketch. |
|---|---|---|
slots | in | Bytes of one sketch. |
sketches | out | The sketches, device-reachable on a device. |
sketches_stride | in | Bytes from one sketch to the next. |
stream | in | Null on the CPU, or the stream of the engine's device. |
Statuses
unexpected_dimensions_ksketchesis shorter than the sketches.
makeFiles queries at every width in window_widths with the best of capabilities.
expected<ngrams_engine_t> make(
strings_view_t queries,
std::span<std::size_t const> window_widths,
std::size_t candidates_budget,
sz_allocator_t *allocator = nullptr,
sz_capability_t capabilities = default_capabilities(),
sz_stream_t stream = nullptr) noexcept; Parameters
queries | in | The texts whose N-grams are filed, or none to only sketch. |
|---|---|---|
window_widths | in | Window widths in bytes, each at least one, the last axis of every overlap output. |
candidates_budget | in | Candidates one round may carry where a backend keeps state per candidate, zero asking for its default. |
allocator | in | Source of the engine's blocks, kept until it is destroyed, or null for the unified allocator of capabilities. |
capabilities | in | Capabilities to pick from. |
stream | in | Null on the CPU, or the stream of the device capabilities describes. |