Skip to content

Commit

Permalink
Fix LT-21815: Eliminate empty glosses (#300)
Browse files Browse the repository at this point in the history
* Add IsEmptyMultiUnicode and add it to the check before merging sense glosses into the word gloss
* Remove the default word gloss content if no sense gloss content was merged

---------

Co-authored-by: Jason Naylor <jasonleenaylor@users.noreply.github.com>
  • Loading branch information
jtmaxwell3 and jasonleenaylor authored Jul 1, 2024
1 parent 3e4d2c6 commit 1fbecf8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,17 @@ private void GenerateEntryGuesses(IDictionary<IWfiWordform, EmptyWwfInfo> map)
var newAnalysis = waFactory.Create(ww, wgFactory);
newAnalysis.CategoryRA = info.Pos;
// Not all entries have senses.
if (info.Sense != null)
if (info.Sense != null && !IsEmptyMultiUnicode(info.Sense.Gloss))
{
// copy all the gloss alternatives from the sense into the word gloss.
IWfiGloss wg = newAnalysis.MeaningsOC.First();
wg.Form.MergeAlternatives(info.Sense.Gloss);
}
else
{
// Eliminate the dummy gloss (LT-21815).
newAnalysis.MeaningsOC.Clear();
}
var wmb = wmbFactory.Create();
newAnalysis.MorphBundlesOS.Add(wmb);
if (info.Form != null)
Expand All @@ -1058,6 +1063,16 @@ private void GenerateEntryGuesses(IDictionary<IWfiWordform, EmptyWwfInfo> map)
}
}
}

bool IsEmptyMultiUnicode(IMultiUnicode multiUnicode)
{
foreach (var ws in multiUnicode.AvailableWritingSystemIds)
{
if (multiUnicode.get_String(ws).Length > 0)
return false;
}
return true;
}
#endregion GenerateEntryGuesses
}
}

0 comments on commit 1fbecf8

Please sign in to comment.