C++ · Fingerprints

Fingerprints

#include <stringzilla/ngrams.hpp> 6.0.0-rc.1 · cb8d956a

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/stringzilla/cpp/fingerprints.md' | claude -p "How would this fit my code?"

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.hpp:30 ↗
class ngrams_engine_t

See also

ngrams_engine_tHolds nothing, so every verb refuses.
ngrams.hpp:35 ↗
ngrams_engine_t() noexcept=default;
ngrams_engine_t(ngrams_engine_t && other) noexcept;
operator=
ngrams.hpp:37 ↗
ngrams_engine_t & operator=(ngrams_engine_t && other) noexcept;
~ngrams_engine_t
ngrams.hpp:41 ↗
~ngrams_engine_t() noexcept;
queries_countQueries filed, the first axis of every overlap output, or zero to only sketch.
ngrams.hpp:67 ↗
std::size_t queries_count() const noexcept;
widths_countWindow widths, the last axis of every overlap output.
ngrams.hpp:70 ↗
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.
ngrams.hpp:85 ↗
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

candidatesinThe texts probed against the queries.
radiusinThe share of a query's distinct N-grams a pair may miss and stay exact.
sharesoutThe block, device-reachable on a device.
shares_query_strideinBytes from one query's plane to the next.
shares_candidate_strideinBytes from one candidate's row to the next.
streaminNull on the CPU, or the stream of the engine's device.

Statuses

  • unexpected_dimensions_k shares is shorter than the block.
sketchesOne MinHash sketch of slots bytes per text of texts, at the engine's widths.
ngrams.hpp:106 ↗
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

textsinThe texts to sketch.
slotsinBytes of one sketch.
sketchesoutThe sketches, device-reachable on a device.
sketches_strideinBytes from one sketch to the next.
streaminNull on the CPU, or the stream of the engine's device.

Statuses

  • unexpected_dimensions_k sketches is shorter than the sketches.
makeFiles queries at every width in window_widths with the best of capabilities.
ngrams.hpp:55 ↗
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

queriesinThe texts whose N-grams are filed, or none to only sketch.
window_widthsinWindow widths in bytes, each at least one, the last axis of every overlap output.
candidates_budgetinCandidates one round may carry where a backend keeps state per candidate, zero asking for its default.
allocatorinSource of the engine's blocks, kept until it is destroyed, or null for the unified allocator of capabilities.
capabilitiesinCapabilities to pick from.
streaminNull on the CPU, or the stream of the device capabilities describes.