pub struct ContractIndex {
pub entries: Vec<ContractEntry>,
/* private fields */
}Expand description
In-memory contract index with inverted indexes for fast lookup.
Fields§
§entries: Vec<ContractEntry>Implementations§
Source§impl ContractIndex
impl ContractIndex
Sourcepub fn from_directory(dir: &Path) -> Result<Self, Box<dyn Error>>
pub fn from_directory(dir: &Path) -> Result<Self, Box<dyn Error>>
Build an index from a directory of YAML contracts.
Uses cached index from .pv/contracts.idx when fresh,
otherwise rebuilds and caches for next time.
Sourcepub fn from_directory_opts(
dir: &Path,
force_rebuild: bool,
) -> Result<Self, Box<dyn Error>>
pub fn from_directory_opts( dir: &Path, force_rebuild: bool, ) -> Result<Self, Box<dyn Error>>
Build an index with option to force rebuild (skip cache).
Sourcepub fn build_from_directory(dir: &Path) -> Result<Self, Box<dyn Error>>
pub fn build_from_directory(dir: &Path) -> Result<Self, Box<dyn Error>>
Build an index from a directory without cache.
Sourcepub fn from_entries(entries: Vec<ContractEntry>) -> Self
pub fn from_entries(entries: Vec<ContractEntry>) -> Self
Build an index from pre-parsed entries.
Sourcepub fn get_by_stem(&self, stem: &str) -> Option<&ContractEntry>
pub fn get_by_stem(&self, stem: &str) -> Option<&ContractEntry>
Look up a contract by exact stem.
Sourcepub fn cached_score(&self, stem: &str) -> Option<f64>
pub fn cached_score(&self, stem: &str) -> Option<f64>
Get the pre-computed composite score for a contract stem.
Sourcepub fn cached_pagerank(&self, stem: &str) -> Option<f64>
pub fn cached_pagerank(&self, stem: &str) -> Option<f64>
Get the pre-computed pagerank score for a contract stem.
Sourcepub fn get_by_obligation(&self, ob_type: &str) -> Vec<&ContractEntry>
pub fn get_by_obligation(&self, ob_type: &str) -> Vec<&ContractEntry>
Look up contracts by obligation type.
Sourcepub fn get_by_equation(&self, eq: &str) -> Vec<&ContractEntry>
pub fn get_by_equation(&self, eq: &str) -> Vec<&ContractEntry>
Look up contracts by equation name.
Sourcepub fn bm25_search(&self, query: &str) -> Vec<(usize, f64)>
pub fn bm25_search(&self, query: &str) -> Vec<(usize, f64)>
BM25 search across all entries. Returns (index, score) pairs sorted descending.
Sourcepub fn regex_search(&self, pattern: &str) -> Result<Vec<usize>, Error>
pub fn regex_search(&self, pattern: &str) -> Result<Vec<usize>, Error>
Regex search across all entries. Returns matching indices.
Sourcepub fn literal_search(&self, needle: &str, case_sensitive: bool) -> Vec<usize>
pub fn literal_search(&self, needle: &str, case_sensitive: bool) -> Vec<usize>
Literal substring search. Returns matching indices.
Sourcepub fn depended_by(&self, stem: &str) -> Vec<&str>
pub fn depended_by(&self, stem: &str) -> Vec<&str>
Return reverse dependencies: contracts that depend on stem.