diff --git a/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs b/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs index 6fffba39..63d9d0c8 100644 --- a/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs +++ b/src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs @@ -631,7 +631,11 @@ public IAnalysis GetBestGuess(IWfiAnalysis wa) /// True: Do lowercase matching only if the occurrence index is zero. /// False: Do lowercase matching regardless of the occurrence index. /// - public IAnalysis GetBestGuess(AnalysisOccurrence occurrence, bool onlyIndexZeroLowercaseMatching = true) + /// + /// True: Consider previous word when getting best guess. + /// False: Ignore previous word when getting best guess. + /// + public IAnalysis GetBestGuess(AnalysisOccurrence occurrence, bool onlyIndexZeroLowercaseMatching = true, bool includeContext = true) { // first see if there is a relevant lowercase form of a sentence initial (non-lowercase) wordform // TODO: make it look for the first word in the sentence...may not be at Index 0! @@ -654,7 +658,7 @@ public IAnalysis GetBestGuess(AnalysisOccurrence occurrence, bool onlyIndexZeroL if (ws == -1) return new NullWAG(); // happens with empty translation lines IAnalysis bestGuess; - IAnalysis previous = GetPreviousWordform(occurrence.Segment, occurrence.Index); + IAnalysis previous = includeContext ? GetPreviousWordform(occurrence.Segment, occurrence.Index) : m_nullWAG; if (TryGetContextAwareGuess(occurrence.Analysis, lowercaseWf, previous, out bestGuess)) return bestGuess; return new NullWAG(); diff --git a/tests/SIL.LCModel.Tests/DomainServices/AnalysisGuessServicesTests.cs b/tests/SIL.LCModel.Tests/DomainServices/AnalysisGuessServicesTests.cs index 8757bd8e..c8a5d460 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/AnalysisGuessServicesTests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/AnalysisGuessServicesTests.cs @@ -1388,6 +1388,8 @@ public void ExpectedContextAwareGloss_PreferContextedOverUncontexted() // Make sure we get a contexted guess for occurrence instead of an uncontexted guess. guessActual = setup.GuessServices.GetBestGuess(occurrence); Assert.AreEqual(contextedApprovedGloss, guessActual); + guessActual = setup.GuessServices.GetBestGuess(occurrence, includeContext: false); + Assert.AreEqual(uncontextedApprovedGloss, guessActual); // Verify uncontexted guess for sort. var sorted_glosses = setup.GuessServices.GetSortedGlossGuesses(analysis); Assert.AreEqual(2, sorted_glosses.Count);