Skip to content

Fix bug with marker location prediction - #495

Open
pmachapman wants to merge 1 commit into
masterfrom
fix-predict-marker-location
Open

Fix bug with marker location prediction#495
pmachapman wants to merge 1 commit into
masterfrom
fix-predict-marker-location

Conversation

@pmachapman

@pmachapman pmachapman commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes a minor bug noticed in PredictMarkerLocation() when investigating token alignment issues on the current build of Serval QA.

int bestNumCrossings = 40000;

The previous logic of 200 ^ 2 meant 200 XOR 2, i.e. 202.

targetHypothesis = alignedTargetTokens[hypothesis < 0 ? alignedTargetTokens.Count - 1 : 0];

There is no -1 element in a list - I assume the last item was intended (see the Python implementation). That said this code isn't even called, as there is no hypothesis -1.


This change is Reviewable

@pmachapman
pmachapman requested a review from Enkidu93 September 7, 2026 03:12
@pmachapman
pmachapman force-pushed the fix-predict-marker-location branch from f937fc4 to f92f870 Compare September 7, 2026 03:35
@pmachapman pmachapman changed the title Fix bugs with marker location prediction Fix bug with marker location prediction Sep 7, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.51%. Comparing base (d734722) to head (f92f870).

Files with missing lines Patch % Lines
...hine/Corpora/PlaceMarkersUsfmUpdateBlockHandler.cs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #495   +/-   ##
=======================================
  Coverage   73.51%   73.51%           
=======================================
  Files         451      451           
  Lines       37692    37692           
  Branches     5183     5183           
=======================================
  Hits        27708    27708           
  Misses       8845     8845           
  Partials     1139     1139           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Enkidu93

Enkidu93 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks for catching these, Peter. This is why I much prefer porting C# to python than python to C# - sorry about that! Regarding the negative hypotheses, I found Isaac's notes and he did experiment with hypotheses like [-2,-1,0,1,2] but found that [0,1,2] gave him the best results. I assume these fixes didn't improve the marker placement in your problem project, right?

@Enkidu93 Enkidu93 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@Enkidu93 reviewed all commit messages and made 2 comments.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on pmachapman).


src/SIL.Machine/Corpora/PlaceMarkersUsfmUpdateBlockHandler.cs line 368 at r1 (raw file):

            int[] hypotheses = { 0, 1, 2 };
            int bestHypothesis = -1;
            int bestNumCrossings = 40000; // A large number

Maybe 40_000 just for slightly better readability?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants