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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public override void EndNote(UsfmParserState state, string marker, bool closed)
public override void Text(UsfmParserState state, string text)
{
// if we hit text in a verse paragraph and we aren't in a verse, then start a non-verse segment
if (text.Trim().Length > 0)
if (text.Trim().Length > 0 && text.Trim() != "...")
CheckConvertVerseParaToNonVerse(state);
}

Expand Down
5 changes: 5 additions & 0 deletions src/SIL.Machine/Corpora/UsfmTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public override void Text(UsfmParserState state, string text)
if (_rowTexts.Count == 0)
return;

if (text.Trim() == "...")
{
text = "";
}

StringBuilder rowText = _rowTexts.Peek();
if (_text._includeMarkers)
{
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