pub fn unsupported_quantity(line: &str) -> Option<String>Expand description
The quantity in line that states something about token economics, if there is one: a
number followed by %, %, percent, per cent, percentage points or pp, or a
multiplier (3x, 3 × cheaper, 2 times fewer), in a sentence that also uses a plain
word of the economics vocabulary; or a multiplier or fraction word (half, twice,
a third) in a sentence that also says something went down. This reads one line as it
stands; prose_quantities reads a whole file, with wrapped sentences joined.
use majordomus_cli::economics::claims::unsupported_quantity;
assert_eq!(unsupported_quantity("Uses 3x fewer tokens.").as_deref(), Some("3x"));
assert_eq!(unsupported_quantity("Cuts context by 60 percent.").as_deref(), Some("60 percent"));
assert_eq!(unsupported_quantity("Cuts total-token use by **50%**.").as_deref(), Some("50%"));
assert_eq!(unsupported_quantity("It halves the token bill.").as_deref(), Some("halves"));
// a fraction with nothing going down is not a claim
assert_eq!(unsupported_quantity("The other half of the context is rules."), None);
// the number and the vocabulary have to meet in one sentence
assert_eq!(unsupported_quantity("Coverage is 80%. Tokens are counted."), None);
// an identifier is not a word of the vocabulary
assert_eq!(unsupported_quantity("validate:context took 50% longer"), None);