@@ -729,18 +729,9 @@ public IAnalysis GetBestGuess(AnalysisOccurrence occurrence, bool onlyIndexZeroL
729729 private IWfiWordform GetLowercaseWordform ( AnalysisOccurrence occurrence , int ws ,
730730 bool onlyIndexZeroLowercaseMatching , IWfiWordform wordform )
731731 {
732- // TODO: make it look for the first word in the sentence...may not be at Index 0!
733- if ( occurrence == null )
734- return null ;
735- if ( onlyIndexZeroLowercaseMatching && occurrence . Index != 0 )
736- return null ;
737- if ( occurrence . Segment == null || ! occurrence . Segment . IsValidObject )
738- return null ;
739- ITsString tssWfBaseline = occurrence . BaselineText ;
740- var cf = new CaseFunctions ( Cache . ServiceLocator . WritingSystemManager . Get ( ws ) ) ;
741- string sLower = cf . ToLower ( tssWfBaseline . Text ) ;
732+ string sLower = GetLowercaseOfTitleCase ( occurrence , ws , onlyIndexZeroLowercaseMatching ) ;
742733 // don't bother looking up the lowercased wordform if the instanceOf is already in lowercase form.
743- if ( sLower != wordform . ShortName )
734+ if ( sLower != null && sLower != wordform . ShortName )
744735 {
745736 return GetWordformIfNeeded ( sLower , ws ) ;
746737 }
@@ -752,18 +743,37 @@ private IWfiWordform GetLowercaseWordform(AnalysisOccurrence occurrence, int ws,
752743 // if it lowercases to the given wordform.
753744 // Otherwise, return null.
754745 // </summary>
755- private IWfiWordform GetOriginalCaseWordform ( AnalysisOccurrence occurrence , IWfiWordform wordform , int ws )
746+ private IWfiWordform GetOriginalCaseWordform ( AnalysisOccurrence occurrence , IWfiWordform wordform ,
747+ int ws , bool onlyIndexZeroLowercaseMatching )
756748 {
757- ITsString tssWfBaseline = occurrence . BaselineText ;
758- var cf = new CaseFunctions ( Cache . ServiceLocator . WritingSystemManager . Get ( ws ) ) ;
759- string sLower = cf . ToLower ( tssWfBaseline . Text ) ;
749+ string sLower = GetLowercaseOfTitleCase ( occurrence , ws , onlyIndexZeroLowercaseMatching ) ;
760750 if ( sLower == wordform . GetForm ( ws ) . Text )
761751 {
752+ ITsString tssWfBaseline = occurrence . BaselineText ;
762753 return GetWordformIfNeeded ( tssWfBaseline . Text , ws ) ;
763754 }
764755 return null ;
765756 }
766757
758+ // <summary>
759+ // Get the lowercase form of occurrence if it is Title case.
760+ // </summary>
761+ private string GetLowercaseOfTitleCase ( AnalysisOccurrence occurrence , int ws , bool onlyIndexZeroLowercaseMatching )
762+ {
763+ // TODO: make it look for the first word in the sentence...may not be at Index 0!
764+ if ( occurrence == null )
765+ return null ;
766+ if ( onlyIndexZeroLowercaseMatching && occurrence . Index != 0 )
767+ return null ;
768+ if ( occurrence . Segment == null || ! occurrence . Segment . IsValidObject )
769+ return null ;
770+ ITsString tssWfBaseline = occurrence . BaselineText ;
771+ var cf = new CaseFunctions ( Cache . ServiceLocator . WritingSystemManager . Get ( ws ) ) ;
772+ if ( cf . StringCase ( tssWfBaseline . Text ) == StringCaseStatus . title )
773+ return cf . ToLower ( tssWfBaseline . Text ) ;
774+ return null ;
775+ }
776+
767777 /// <summary>
768778 /// Get a wordform for word if it already exists or
769779 /// if it has an entry in the lexicon.
@@ -862,7 +872,7 @@ private List<IWfiAnalysis> GetSortedAnalysisGuesses(IWfiWordform wordform, int w
862872 {
863873 // Sometimes the user selects a lowercase wordform for an uppercase word.
864874 // Get the original case so that we can include uppercase analyses.
865- var originalCaseWf = GetOriginalCaseWordform ( occurrence , wordform , ws ) ;
875+ var originalCaseWf = GetOriginalCaseWordform ( occurrence , wordform , ws , onlyIndexZeroLowercaseMatching ) ;
866876 if ( originalCaseWf != null )
867877 wordform = originalCaseWf ;
868878 }
0 commit comments