use super::schemas::{NoulCriteria, Question};
use std::collections::BTreeMap;
pub fn window_membership(window_index: usize) -> Question {
Question::Noul {
instructions: format!(
"Is the code in `windows[{window_index}].code` from the file at `file` part of \
the subsystem responsible for `concept`, either implementing it directly or \
serving as its dedicated supporting code (features, buffers, configuration, \
data access)?"
),
criteria: Some(membership_criteria()),
}
}
pub fn file_membership() -> Question {
Question::Noul {
instructions: "Considering all windows shown, is the file at `file` part of the \
subsystem responsible for `concept`, including its dedicated \
supporting code?"
.into(),
criteria: Some(membership_criteria()),
}
}
fn membership_criteria() -> NoulCriteria {
NoulCriteria {
true_means: "Implements the concept, or is configuration/data/feature code that \
exists specifically to support it"
.into(),
false_means: "Merely imports, logs, mentions it in a comment, or touches the \
concept incidentally while doing something else"
.into(),
}
}
pub fn doc_window_membership(window_index: usize) -> Question {
Question::Noul {
instructions: format!(
"Is the text in `windows[{window_index}].text` from the document at `file` part \
of the material that covers `concept`, either addressing it directly or serving \
as its dedicated supporting content (definitions, examples, configuration, \
references)?"
),
criteria: Some(doc_membership_criteria()),
}
}
pub fn doc_file_membership() -> Question {
Question::Noul {
instructions: "Considering all windows shown, is the document at `file` part of the \
material that covers `concept`, including its dedicated supporting \
content?"
.into(),
criteria: Some(doc_membership_criteria()),
}
}
fn doc_membership_criteria() -> NoulCriteria {
NoulCriteria {
true_means: "Covers the concept, or is a definition/example/configuration/reference \
that exists specifically to support it"
.into(),
false_means: "Merely mentions it in passing, or touches the concept incidentally \
while covering something else"
.into(),
}
}
pub fn listwise_rank(file_ids: impl Iterator<Item = String>, any_doc: bool) -> Question {
let instructions = if any_doc {
"Which file in `files` most likely contains what `concept` describes?"
} else {
"Which file in `files` most likely implements what `concept` describes?"
};
Question::Choice {
instructions: instructions.into(),
criteria: file_ids.map(|id| (id, None)).collect::<BTreeMap<_, _>>(),
}
}