module

Xerp::Query::Terms

Constants

RRF_K = 60

Reciprocal Rank Fusion constant (standard value from literature)

Class methods

extract(db : DB::Database, query_tokens : Array(String), expanded_tokens : Hash(String, Array(Expansion::ExpandedToken)), opts : TermsOptions) : Array(SalientTerm)

Main entry point - dispatches based on source option.

Source
extract_combined(db : DB::Database, query_tokens : Array(String), expanded_tokens : Hash(String, Array(Expansion::ExpandedToken)), opts : TermsOptions) : Array(SalientTerm)

Extracts terms from both sources and combines using Reciprocal Rank Fusion. RRF score = 1/(k + scope_rank) + 1/(k + vector_rank) Terms in both sources naturally get higher scores.

Source
extract_from_model(db : DB::Database, query_tokens : Array(String), opts : TermsOptions, model : String) : Array(SalientTerm)

Extracts terms from a single vector model.

Source
extract_from_scope(db : DB::Database, query_tokens : Array(String), expanded_tokens : Hash(String, Array(Expansion::ExpandedToken)), opts : TermsOptions) : Array(SalientTerm)

Extracts the most salient terms from blocks matching a query. salience(term) = Σ (block_score × tf(term, block)) × idf(term)

Source
extract_from_vectors(db : DB::Database, query_tokens : Array(String), opts : TermsOptions) : Array(SalientTerm)

Extracts terms from trained vectors (neighbors).

Source

Nested types