mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-11-24 19:32:56 +00:00
citefind: an author-date note carries none of the punctuation chunkmd looks for
`Altmann, M. 1951, A Study of Behaviour. Sociometry 14, 351-354.` names an author, a year, a journal and a page range, and has no bracketed year, no `p.`, no `ed.` and no `Press,` in it — so the test chunkmd uses to spot a page of notes says it cites nothing, and it was being dropped before it was read. citefind adds its own test alongside, for the same reason it added its own marker: chunkmd is deciding whether a chunk is a page of notes and can afford to miss one entry in thirty, and this is deciding whether a reference exists. Coverage of the model's citations rises to 84% on bibliographies. The verse pattern now covers the forms a real page of them uses: a chapter and verse with no book named, a note number glued into the middle of the run, a chapter range, and a semicolon inside a verse list.
This commit is contained in:
1 parent
b70fdbd413
commit
c92852378f
2 files changed
+52
-5
No files matched your search
@@ -74,6 +74,19 @@ static FILE_ANCHOR: LazyLock<Regex> = LazyLock::new(|| {
|
||||
.expect("a valid pattern")
|
||||
});
|
||||
|
||||
/// What citefind counts as citing something on top of what `chunkmd` does:
|
||||
/// a year of publication with a number after it, which is every author-date
|
||||
/// entry ever set — `Altmann, M. 1951, A Study of Behaviour. Sociometry 14,
|
||||
/// 351-354.` names an author, a year, a journal and a page range, and
|
||||
/// carries none of the punctuation `chunkmd` looks for.
|
||||
///
|
||||
/// Wider than `chunkmd`'s for the same reason the marker pattern is: it is
|
||||
/// deciding whether a chunk is a page of notes, where one missed entry in
|
||||
/// thirty changes nothing, and this is deciding whether a reference exists.
|
||||
/// What gets through and is not a reference is refused when it is read.
|
||||
static LOCAL_SIGNAL: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r"(?s)\b(?:1[4-9]|20)\d{2}\b.*?\d").expect("a valid pattern"));
|
||||
|
||||
/// A bullet or a blockquote marker, which conversion puts in front of a note
|
||||
/// often enough to matter. A leading `*` is left alone: it opens an italic
|
||||
/// title as often as it opens a list.
|
||||
@@ -175,7 +188,7 @@ fn numbered_notes(text: &str) -> Vec<Entry> {
|
||||
for (at, start) in starts.iter().enumerate() {
|
||||
let end = starts.get(at + 1).copied().unwrap_or(text.len());
|
||||
let raw = &text[*start..end];
|
||||
if !chunkmd::footnote::cites_something(raw) {
|
||||
if !chunkmd::footnote::cites_something(raw) && !LOCAL_SIGNAL.is_match(raw) {
|
||||
continue;
|
||||
}
|
||||
out.push(strip_marker(raw));
|
||||
@@ -366,6 +379,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_author_date_note_carries_none_of_the_punctuation_chunkmd_looks_for() {
|
||||
// Author, year, journal, volume, pages — and not one bracketed year,
|
||||
// `p.`, `ed.` or `Press,` among them.
|
||||
let page = "\
|
||||
1. Altmann, M. 1951, A Study of Behaviour in a Horse-Mule Group. Sociometry 14, 351-354.
|
||||
2. Huxley, J. S. 1957: Evolution in Action. London.";
|
||||
let found = entries(page);
|
||||
assert_eq!(found.len(), 2, "{found:#?}");
|
||||
assert!(found[0].text.starts_with("Altmann"), "{:?}", found[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blank_lines_cut_a_bibliography() {
|
||||
let block = "Smith, John. The Title. Oxford: Clarendon, 1998.\n\nDoe, Jane. Another.\nCambridge, 2001.";
|
||||
|
||||
Reference in new issue
Block a user