From 1fbecf87600fff022dfca82bdbf103c3fce44738 Mon Sep 17 00:00:00 2001 From: John T Maxwell III Date: Mon, 1 Jul 2024 15:15:14 -0700 Subject: [PATCH] Fix LT-21815: Eliminate empty glosses (#300) * 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 --- .../DomainServices/AnalysisGuessServices.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs b/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs index 63d9d0c8..d74f3b1e 100644 --- a/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs +++ b/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs @@ -1032,12 +1032,17 @@ private void GenerateEntryGuesses(IDictionary 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) @@ -1058,6 +1063,16 @@ private void GenerateEntryGuesses(IDictionary map) } } } + + bool IsEmptyMultiUnicode(IMultiUnicode multiUnicode) + { + foreach (var ws in multiUnicode.AvailableWritingSystemIds) + { + if (multiUnicode.get_String(ws).Length > 0) + return false; + } + return true; + } #endregion GenerateEntryGuesses } }