score_set/lib.rs
1//! # score-set
2//!
3//! A Rust library for building **static weighted scoring operator sets**.
4//!
5//! It does not prescribe a unified input or context type. Instead it declares,
6//! stores, normalizes, and combines a set of weighted operators — scoring is
7//! done via a user-provided closure that can inject arbitrary runtime data.
8//!
9//! # Quick example
10//!
11//! ```ignore
12//! use score_set::*;
13//!
14//! let gc = metric("gc")
15//! .measure().by(|dna: &&str| gc_ratio(dna))
16//! .map01().by(|raw: &f64, _: &&str| Value01::witness(*raw).unwrap());
17//!
18//! let len = metric("len")
19//! .measure().by(|len: &usize| *len)
20//! .map01().by(|raw: &usize, _: &usize| {
21//! Value01::witness((*raw as f64 / 100.0).min(1.0)).unwrap()
22//! });
23//!
24//! let ms = score_set! {
25//! 2.0 => gc,
26//! 3.0 => len,
27//! }?;
28//!
29//! let dna = "ACGTACGT";
30//! let score = ms.score().by(|(gc, len)| {
31//! gc.contribute(gc.metric().eval(&dna))
32//! + len.contribute(len.metric().eval(&dna.len()))
33//! });
34//! # Ok::<(), &'static str>(())
35//! ```
36
37mod float;
38mod gen_tuple;
39mod macros;
40mod member;
41mod metric;
42mod set;
43mod value;
44
45// Public API
46pub use float::Float;
47// score_set! is exported at crate root via #[macro_export]
48pub use member::{Member, Members, RawMember, raw_member};
49pub use metric::{Metric, metric};
50pub use set::{ScoreSet, ScoreStage};
51pub use value::{GtZero, NormalizedContainer, NormalizedWeight, Value01};
52pub use witnessed::{WitnessExt, Witnessed};
53
54#[cfg(test)]
55mod lab;