Default to MiniMax M3 and fix Hungarian quotes in analyses
MiniMax M3 rated top in a blind comparison at a sixth of the cost of the other top models. Straight double-quote pairs in Hungarian answers become „…”. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -199,6 +199,39 @@ pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
|
||||
walk(schema, value, "$")
|
||||
}
|
||||
|
||||
/// Fixes typography the models often get wrong. In Hungarian, pairs of
|
||||
/// straight double quotes become „…” (only when they pair up evenly).
|
||||
pub fn polish(language: &str, content: &mut Value) {
|
||||
fn hungarian_quotes(text: &str) -> Option<String> {
|
||||
if !text.contains('"') || !text.matches('"').count().is_multiple_of(2) {
|
||||
return None;
|
||||
}
|
||||
let mut open = true;
|
||||
Some(
|
||||
text.chars()
|
||||
.map(|c| match c {
|
||||
'"' => {
|
||||
let q = if open { '„' } else { '”' };
|
||||
open = !open;
|
||||
q
|
||||
}
|
||||
c => c,
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
match content {
|
||||
Value::String(s) if language == "hu" => {
|
||||
if let Some(fixed) = hungarian_quotes(s) {
|
||||
*s = fixed;
|
||||
}
|
||||
}
|
||||
Value::Array(items) => items.iter_mut().for_each(|v| polish(language, v)),
|
||||
Value::Object(map) => map.values_mut().for_each(|v| polish(language, v)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// The analysis as Markdown (for reading and comparing outputs).
|
||||
pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String {
|
||||
let (strengths, challenges, advice) = if language == "hu" {
|
||||
@@ -222,3 +255,20 @@ pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String {
|
||||
md.push_str(&format!("## {advice}\n\n{}\n", content["advice"].as_str().unwrap_or("")));
|
||||
md
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn polish_turns_straight_quotes_hungarian() {
|
||||
let mut v = json!({"a": "a \"hazai pálya\" és a \"sorok\"", "b": ["egy \" pár nélkül"], "c": {"d": "nincs"}});
|
||||
polish("hu", &mut v);
|
||||
assert_eq!(v["a"], "a „hazai pálya” és a „sorok”");
|
||||
assert_eq!(v["b"][0], "egy \" pár nélkül");
|
||||
assert_eq!(v["c"]["d"], "nincs");
|
||||
let mut en = json!({"a": "the \"home\" ground"});
|
||||
polish("en", &mut en);
|
||||
assert_eq!(en["a"], "the \"home\" ground");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user