diff options
| author | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 07:30:24 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 07:30:24 +0300 |
| commit | d563910a0fc7f61e2a77cd7cc43643e2fe493939 (patch) | |
| tree | 4ab046a9c4169540d57da6f0781b81919fb2e86d /src | |
| parent | 95e9e7e920be5ccd4bf037b51bef6ab077b59c9a (diff) | |
| download | genenetwork4-d563910a0fc7f61e2a77cd7cc43643e2fe493939.tar.gz | |
src/search/native.rs (native engine): register the probabilistic prefixes and aliases (C3.3).
Port search.py:229-233: description=XD, rif=XRF, wiki=XWK, plus the uppercase aliases RIF=XRF and WIKI=XWK. With STEM_ALL_Z the parsed field term is Z+<prefix>+stem (e.g. wiki:diabetes -> ZXWKdiabet, matching the TermGenerator emission the production indexer writes), pinned hermetically by prefix in native.rs tests. tests/search_native_shapes.rs gains the C3.3 list (Q21-Q25, Q45 with per-shape parity.rs citations). Dev-index reference counts recorded, never compared to production: description:insulin=0, rif:insulin=0, RIF:insulin=0, wiki:diabetes=0 (phenotype type filter: XWK text lives only on gene documents, d.v. index-genenetwork:432-443), WIKI:diabetes=0, symbol:insr OR rif:insulin=1. The 0s are faithful, not registration failures: xapian-delve confirms the fields are populated on the dev index (term ZXWKdiabet: 24 gene docs; ZXRFdiabet exists) while ZXRFinsulin simply does not occur in the crawled RIF text and the phenotype-typed wiki shapes are filtered to an empty set exactly as gn3 would do on this index. Evidence: logs/c3-3.log — build EXIT=0, lib tests green (incl. the probabilistic-prefix assertions), FULL suite EXIT=0, SHAPE-CLASS GATE 33/33 PASS vs the dev index (cumulative C3.1+C3.2+C3.3); delve probe: /home/kabui/zxrf-all.txt, delve-result.txt.
Diffstat (limited to 'src')
| -rw-r--r-- | src/search/native.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/search/native.rs b/src/search/native.rs index 14db735..a7b2fb5 100644 --- a/src/search/native.rs +++ b/src/search/native.rs @@ -91,6 +91,14 @@ fn build_query_parser() -> QueryParser { qp.add_boolean_prefix::<&str, &str>("symbol", Some("XY"), None); qp.add_boolean_prefix::<&str, &str>("chr", Some("XC"), None); qp.add_boolean_prefix::<&str, &str>("peakchr", Some("XPC"), None); + // Probabilistic prefixes (search.py:229-233): weighted (BM25-scored) + // text fields, freely mixable with free text and operators; rif and + // wiki also answer to their uppercase aliases (search.py:232-233). + qp.add_prefix::<&str>("description", Some("XD")); + qp.add_prefix::<&str>("rif", Some("XRF")); + qp.add_prefix::<&str>("wiki", Some("XWK")); + qp.add_prefix::<&str>("RIF", Some("XRF")); + qp.add_prefix::<&str>("WIKI", Some("XWK")); qp } @@ -286,6 +294,30 @@ mod tests { assert!(!b6.contains("XGBXD"), "group must not emit the raw-case term"); } + /// The probabilistic-prefix registrations (C3.3): description, rif, + /// wiki and the uppercase aliases must parse as weighted field + /// terms, not free text (search.py:229-233). With STEM_ALL_Z the + /// field term is the prefix + Z-stemmed value (e.g. XDZinsulin), + /// so assert on the prefix, the invariant the registration owns. + #[test] + fn probabilistic_prefixes_and_aliases_parse_as_field_terms() { + let mut qp = build_query_parser(); + let prefixed = |query: &str, prefix: &str| { + let set = qp + .parse_query_checked::<&str>(query, None, None) + .unwrap_or_else(|e| panic!("{query} must parse: {e:?}")) + .unique_terms() + .map(|t| t.to_string()) + .collect::<std::collections::BTreeSet<_>>(); + set.iter().any(|t| t.starts_with(prefix)) + }; + assert!(prefixed("description:insulin", "XD")); + assert!(prefixed("rif:insulin", "XRF")); + assert!(prefixed("RIF:insulin", "XRF")); + assert!(prefixed("wiki:diabetes", "XWK")); + assert!(prefixed("WIKI:diabetes", "XWK")); + } + /// The index-open guards, without touching a real index. #[test] fn open_database_maps_failures_onto_the_seam_vocabulary() { |
