Skip to content

Commit 85fc19d

Browse files
jtmaxwell3jasonleenaylor
authored andcommitted
Allow for the case where a sense appears in more than one morpheme
1 parent 3bb0662 commit 85fc19d

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

Src/LexText/Interlinear/SandboxBase.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,26 +1659,27 @@ private int CreateSecondaryAndCopyStrings(int flidChoices, int hvoMain, int flid
16591659
public void UpdateField(int hvo, int flid)
16601660
{
16611661
ICmObject hvoObject = Caches.MainCache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo);
1662-
if (hvoObject is ILexSense lexSense)
1662+
if (hvoObject is ILexSense lexSense && lexSense.Owner is ILexEntry lexEntry)
16631663
{
1664-
int hvoMorph = GetHvoMorphForLexSense(hvo);
1665-
if (hvoMorph != 0 && lexSense.Owner is ILexEntry lexEntry)
1664+
foreach (int hvoMorph in GetHvoMorphsForLexSense(hvo))
16661665
{
16671666
// This fixes LT-22534.
16681667
EstablishDefaultSense(hvoMorph, lexEntry, lexSense, null);
16691668
}
16701669
}
16711670
if (hvoObject != null && hvoObject.Owner is IMoMorphSynAnalysis msa)
16721671
{
1673-
if (msa.Owner is ILexEntry lexEntry)
1672+
if (msa.Owner is ILexEntry entry)
16741673
{
1675-
foreach (var sense in lexEntry.SensesOS)
1674+
foreach (var sense in entry.SensesOS)
16761675
{
1677-
int hvoMorph = GetHvoMorphForLexSense(sense.Hvo);
1678-
if (hvoMorph != 0 && sense.MorphoSyntaxAnalysisRA == msa)
1676+
if (sense.MorphoSyntaxAnalysisRA == msa)
16791677
{
1680-
// This fixes LT-22541.
1681-
EstablishDefaultSense(hvoMorph, lexEntry, sense, null);
1678+
foreach (int hvoMorph in GetHvoMorphsForLexSense(sense.Hvo))
1679+
{
1680+
// This fixes LT-22541.
1681+
EstablishDefaultSense(hvoMorph, entry, sense, null);
1682+
}
16821683
}
16831684
}
16841685
}
@@ -3985,19 +3986,20 @@ protected List<int> LexSensesForCurrentMorphs()
39853986
return lexSensesForMorphs;
39863987
}
39873988

3988-
private int GetHvoMorphForLexSense(int lexSense)
3989+
private IList<int> GetHvoMorphsForLexSense(int lexSense)
39893990
{
3991+
IList<int> hvoMorphs = new List<int>();
39903992
int cmorphs = m_caches.DataAccess.get_VecSize(kSbWord, ktagSbWordMorphs);
39913993
for (int i = 0; i < cmorphs; i++)
39923994
{
39933995
int hvoMorph = m_caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, i);
39943996
int hvoMorphSense = m_caches.DataAccess.get_ObjectProp(hvoMorph, ktagSbMorphGloss);
39953997
if (m_caches.RealHvo(hvoMorphSense) == lexSense)
39963998
{
3997-
return hvoMorph;
3999+
hvoMorphs.Add(hvoMorph);
39984000
}
39994001
}
4000-
return 0;
4002+
return hvoMorphs;
40014003
}
40024004

40034005
/// <summary>

0 commit comments

Comments
 (0)