Skip to content

Commit c7509d3

Browse files
authored
Fix LT-22237: Duplicate analyses are getting created (#428)
1 parent 0bc8560 commit c7509d3

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

Src/LexText/Interlinear/SandboxBase.GetRealyAnalysisMethod.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,15 +937,15 @@ public IWfiAnalysis FindMatchingAnalysis(bool fExactMatch)
937937
{
938938
if (fExactMatch)
939939
{
940-
if (CheckAnalysis(possibleAnalysis.Hvo, true))
940+
if (CheckAnalysis(possibleAnalysis, true))
941941
return possibleAnalysis;
942942
}
943943
else
944944
{
945945
// If this possibility is Human evaluated, it must match exactly regardless
946946
// of the input parameter to count as a match on the analysis.
947947
bool fIsHumanApproved = SandboxBase.IsAnalysisHumanApproved(m_caches.MainCache, possibleAnalysis);
948-
if (CheckAnalysis(possibleAnalysis.Hvo, fIsHumanApproved))
948+
if (CheckAnalysis(possibleAnalysis, fIsHumanApproved))
949949
return possibleAnalysis;
950950
}
951951
}
@@ -1012,15 +1012,16 @@ private bool IsTrivialAnalysis(IWfiAnalysis possibleAnalysis)
10121012
/// Evaluate the given possible analysis to see whether it matches the current Sandbox data.
10131013
/// Review: This is not testing word gloss at all. Is this right?
10141014
/// </summary>
1015-
/// <param name="hvoPossibleAnalysis"></param>
1015+
/// <param name="possibleAnalysis"></param>
10161016
/// <param name="fExactMatch"></param>
10171017
/// <returns></returns>
1018-
private bool CheckAnalysis(int hvoPossibleAnalysis, bool fExactMatch)
1018+
private bool CheckAnalysis(IWfiAnalysis possibleAnalysis, bool fExactMatch)
10191019
{
10201020
// First, check that the analysis has the right word category.
1021+
int hvoPossibleAnalysis = possibleAnalysis.Hvo;
10211022
int hvoWordCat = m_sdaMain.get_ObjectProp(hvoPossibleAnalysis,
10221023
WfiAnalysisTags.kflidCategory);
1023-
bool fCheck = fExactMatch || hvoWordCat != 0;
1024+
bool fCheck = hvoWordCat != 0;
10241025
if (fCheck && m_hvoCategoryReal != hvoWordCat)
10251026
{
10261027
return false;
@@ -1083,6 +1084,14 @@ private bool CheckAnalysis(int hvoPossibleAnalysis, bool fExactMatch)
10831084
return false;
10841085
}
10851086
}
1087+
if (fExactMatch && hvoWordCat == 0 && m_hvoCategoryReal != 0)
1088+
{
1089+
// possibleAnalysis matches except that its category is empty.
1090+
// Make the match exact by setting the category.
1091+
// This fixes LT-22237.
1092+
IPartOfSpeechRepository posRepository = m_caches.MainCache.ServiceLocator.GetInstance<IPartOfSpeechRepository>();
1093+
possibleAnalysis.CategoryRA = posRepository.GetObject(m_hvoCategoryReal);
1094+
}
10861095
return true;
10871096
}
10881097

0 commit comments

Comments
 (0)