Skip to content

Commit 50685f3

Browse files
david-allisonclaude
andcommitted
feat: read fragments collections' Source column
Each row of a fragments collection now names the publication or work it came from, with acronyms expanded (M.H. -> Mona's Herald); the data lands in manx-search-data alongside the Date column. The cell is mapped into DocumentLine.Source and serialized so clients can show per-line provenance. No indexing or UI changes yet. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f65ebe1 commit 50685f3

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

CorpusSearch.Test/DocumentLinePreparerTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,31 @@ public void LanguageIsReadFromTheManxColumnLanguageCsvColumn()
172172
}
173173
}
174174

175+
/// <summary>The CSV contract of a fragments collection: each row carries its
176+
/// Date cell (read into the line date) and its Source cell (the publication,
177+
/// acronyms expanded)</summary>
178+
[Test]
179+
public void DateAndSourceAreReadFromTheirCsvColumns()
180+
{
181+
var path = Path.GetTempFileName();
182+
try
183+
{
184+
File.WriteAllText(path,
185+
"English,Manx,Notes,Date,Source\n" +
186+
"parson,saggyrt,\"[1] IoME, Sat, Sep 21, 1901; Page: 3\",21/09/1901,Isle of Man Examiner\n" +
187+
"honey,mill,,21/09/1901,Isle of Man Examiner\n");
188+
189+
var lines = CsvHelperUtils.LoadCsv(path);
190+
191+
Assert.That(lines.Select(x => x.DateCell), Is.All.EqualTo("21/09/1901"));
192+
Assert.That(lines.Select(x => x.Source), Is.All.EqualTo("Isle of Man Examiner"));
193+
}
194+
finally
195+
{
196+
File.Delete(path);
197+
}
198+
}
199+
175200
/// <summary>[MS 1 Thessalonians 2.16] Text... - the citation becomes line
176201
/// metadata and leaves the Manx token stream</summary>
177202
[Test]

CorpusSearch/Dependencies/CsvHelper/DocumentLineMap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public DocumentLineMap()
1919
// "Language" header would not say which column it describes
2020
Map(m => m.Language).Name("ManxColumnLanguage").Optional();
2121
Map(m => m.DateCell).Name("Date").Optional();
22+
Map(m => m.Source).Optional();
2223
Map(m => m.CsvLineNumber).Convert(args => args.Row.Parser.RawRow);
2324
Map(m => m.ManxOriginal).Convert(args =>
2425
{

CorpusSearch/Model/DocumentLine.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public class DocumentLine
6868
[JsonIgnore]
6969
public string? DateCell { get; set; }
7070

71+
/// <summary>The publication or work the row's fragment came from ("Mona's
72+
/// Herald"), acronyms expanded: the `Source` cell of a fragments collection.
73+
/// Serialized, so a client can show per-line provenance. Nullable.</summary>
74+
public string? Source { get; set; }
75+
7176
/// <summary>The line's own date, where it has one apart from its document's: in
7277
/// a fragments collection (<see cref="NotesCitationDates"/>) each line dates
7378
/// from its Date cell, or - in data predating the column - from its note's

0 commit comments

Comments
 (0)