Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/SIL.Machine/Corpora/UsfmVersificationErrorDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public string ExpectedVerseRef
// an exception with certain invalid verse data; use TryParse instead.
if (!VerseRef.TryParse($"{_bookNum} {_expectedChapter}:{_expectedVerse}", out VerseRef defaultVerseRef))
{
return "";
return DefaultVerse(_expectedChapter, _expectedVerse);
}
if (Type == UsfmVersificationErrorType.ExtraVerse)
return "";
Expand Down Expand Up @@ -144,10 +144,30 @@ out VerseRef correctedVerseRangeRef
return defaultVerseRef.ToString();
}
}
public string ActualVerseRef =>
_verseRef != null
? _verseRef.Value.ToString()
: new VerseRef(_bookNum, _actualChapter, _actualVerse).ToString();
public string ActualVerseRef
{
get
{
if (_verseRef != null)
{
return _verseRef.ToString();
}
else
{
if (VerseRef.TryParse($"{_bookNum} {_actualChapter}:{_actualVerse}", out VerseRef actualVerseRef))
{
return actualVerseRef.ToString();
}
}
return DefaultVerse(_actualChapter, _actualVerse);
}
}

private string DefaultVerse(int chapter, int verse)
{
string verseString = _actualVerse == -1 ? "" : verse.ToString();
return $"{Canon.BookNumberToId(_bookNum)} {chapter}:{verseString}";
}
}

public class UsfmVersificationErrorDetector : UsfmParserHandlerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SIL.Machine.Corpora;
public class ParatextProjectQuoteConventionDetectorTests
{
[Test]
public void GetUsfmVersificationErrors_Noerrors()
public void GetUsfmVersificationErrors_NoErrors()
{
var env = new TestEnvironment(
files: new Dictionary<string, string>()
Expand Down
Loading