Skip to content

Commit

Permalink
The untranslatable fix was moved to a Serval implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Feb 4, 2025
1 parent 05e8b51 commit a752a80
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public enum UpdateUsfmIntraVerseMarkerBehavior
*/
public class UpdateUsfmParserHandler : ScriptureRefUsfmParserHandlerBase
{
private static readonly HashSet<string> UntranslatedParagraphTag = new HashSet<string> { "r", "rem", };
private readonly IReadOnlyList<(IReadOnlyList<ScriptureRef>, string)> _rows;
private readonly List<UsfmToken> _tokens;
private readonly List<UsfmToken> _newTokens;
Expand Down Expand Up @@ -368,14 +367,9 @@ private void SkipTokens(UsfmParserState state)

private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true)
{
bool untranslatableParagraph =
state.ParaTag?.Marker != null && IsUntranslatedParagraph(state.ParaTag.Marker);
if (_textBehavior == UpdateUsfmTextBehavior.StripExisting)
{
if (untranslatableParagraph)
ClearNewTokens();
else
AddNewTokens();
AddNewTokens();
return true;
}

Expand All @@ -389,15 +383,14 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true)
.Any(t => t.Type == UsfmTokenType.Text && t.Text.Length > 0);

bool useNewTokens =
!untranslatableParagraph
&& newText
newText
&& (!existingText || _textBehavior == UpdateUsfmTextBehavior.PreferNew)
&& (!inEmbed || InNoteText);

if (useNewTokens)
AddNewTokens();

if (untranslatableParagraph || (existingText && _textBehavior == UpdateUsfmTextBehavior.PreferExisting))
if (existingText && _textBehavior == UpdateUsfmTextBehavior.PreferExisting)
ClearNewTokens();

// figure out when to skip the existing text
Expand Down Expand Up @@ -442,10 +435,5 @@ private void PopNewTokens()
{
_replace.Pop();
}

public static bool IsUntranslatedParagraph(string tag)
{
return !(tag is null) && UntranslatedParagraphTag.Contains(tag);
}
}
}

0 comments on commit a752a80

Please sign in to comment.