Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore freestanding ellipses #235

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions src/SIL.Machine/Corpora/UsfmTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ protected override void StartVerseText(UsfmParserState state, IReadOnlyList<Scri
protected override void EndVerseText(UsfmParserState state, IReadOnlyList<ScriptureRef> scriptureRefs)
{
string text = _rowTexts.Pop().ToString();
if (text.Trim() == "...")
{
text = "";
}
_rows.AddRange(_text.CreateRows(scriptureRefs, text, _sentenceStart));
_sentenceStart = state.Token.Marker == "c" || text.HasSentenceEnding();
}
Expand Down
41 changes: 41 additions & 0 deletions tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,47 @@ public void GetRows_OptBreak_BeginningIncludeMarkers()
});
}

[Test]
public void GetRows_IgnoreLoneEllipsis()
{
TextRow[] rows = GetRows(
@"\id MAT - Test
\c 1
\q1
\f \fr 119 \ft World \f*
\v 1 ...
\v 2 Text
\c 2
\d
description
\b
",
includeAllText: true
);
Assert.Multiple(() =>
{
Assert.That(rows, Has.Length.EqualTo(5), string.Join(",", rows.Select(tr => tr.Text)));
Assert.That(rows[1].Text, Is.EqualTo(""));
});
}

[Test]
public void GetRows_Ellipsis()
{
TextRow[] rows = GetRows(
@"\id MAT - Test
\c 1
\v 1 Verse text ... More text
",
includeAllText: true
);
Assert.Multiple(() =>
{
Assert.That(rows, Has.Length.EqualTo(1), string.Join(",", rows.Select(tr => tr.Text)));
Assert.That(rows[0].Text, Is.EqualTo("Verse text ... More text"));
});
}

private static TextRow[] GetRows(string usfm, bool includeMarkers = false, bool includeAllText = false)
{
UsfmMemoryText text =
Expand Down
Loading