@@ -373,17 +373,24 @@ public void ResetAnalysisCache()
373373 if ( m_loader != null )
374374 {
375375 CheckDisposed ( ) ;
376- m_loader . ResetGuessCache ( ) ;
376+ m_loader . ResetGuessCache ( IsParsingMode ( ) ) ;
377377 }
378378 }
379379
380+ internal bool IsParsingMode ( )
381+ {
382+ if ( RootSite ? . GetMaster ( ) == null )
383+ return false ;
384+ return RootSite . GetMaster ( ) . IsParsingMode ( ) ;
385+ }
386+
380387 internal AnalysisGuessServices GuessServices
381388 {
382389 get
383390 {
384391 if ( m_loader != null && m_loader . GuessServices != null )
385392 return m_loader . GuessServices ;
386- return new AnalysisGuessServices ( m_cache ) ;
393+ return new AnalysisGuessServices ( m_cache , IsParsingMode ( ) ) ;
387394 }
388395 }
389396
@@ -541,10 +548,32 @@ private void SetGuessing(IVwEnv vwenv, int bgColor)
541548 UsingGuess = true ;
542549 }
543550
544- private void SetGuessing ( IVwEnv vwenv )
551+ private int GetGuessColor ( ICmObject obj )
545552 {
546- SetGuessing ( vwenv , ApprovedGuessColor ) ;
547- UsingGuess = true ;
553+ IWfiAnalysis wa ;
554+ if ( IsParsingMode ( ) )
555+ {
556+ // Parser approval takes precedence over User approval.
557+ wa = ( obj is IWfiGloss ) ? ( ( IWfiGloss ) obj ) . Analysis : obj as IWfiAnalysis ;
558+ if ( wa != null )
559+ {
560+ Opinions opinion = wa . GetAgentOpinion ( wa . Cache . LangProject . DefaultParserAgent ) ;
561+ if ( opinion == Opinions . approves )
562+ return MachineGuessColor ;
563+ }
564+ return ApprovedGuessColor ;
565+ }
566+ // User approval takes precedence over Parser approval.
567+ if ( obj is IWfiGloss )
568+ return ApprovedGuessColor ;
569+ wa = obj as IWfiAnalysis ;
570+ if ( wa != null )
571+ {
572+ Opinions opinion = wa . GetAgentOpinion ( wa . Cache . LangProject . DefaultUserAgent ) ;
573+ if ( opinion == Opinions . approves )
574+ return ApprovedGuessColor ;
575+ }
576+ return MachineGuessColor ;
548577 }
549578
550579 public bool UsingGuess { get ; set ; }
@@ -1822,11 +1851,7 @@ private void DisplayMorphemes()
18221851 // Display the morpheme bundles.
18231852 if ( m_hvoDefault != m_hvoWordBundleAnalysis )
18241853 {
1825- // Real analysis isn't what we're displaying, so morph breakdown
1826- // is a guess. Is it a human-approved guess?
1827- bool isHumanGuess = m_this . GuessCache . get_IntProp ( m_hvoDefault , InterlinViewDataCache . OpinionAgentFlid ) !=
1828- ( int ) AnalysisGuessServices . OpinionAgent . Parser ;
1829- m_this . SetGuessing ( m_vwenv , isHumanGuess ? ApprovedGuessColor : MachineGuessColor ) ;
1854+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
18301855 // Let the exporter know that this is a guessed analysis.
18311856 m_vwenv . set_StringProperty ( ktagAnalysisStatus , "guess" ) ;
18321857 }
@@ -1842,7 +1867,7 @@ private void DisplayMorphemes()
18421867 if ( m_hvoWordBundleAnalysis == m_hvoWordform )
18431868 {
18441869 // Real analysis is just word, one we're displaying is a default
1845- m_this . SetGuessing ( m_vwenv ) ;
1870+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
18461871 // Let the exporter know that this is a guessed analysis.
18471872 m_vwenv . set_StringProperty ( ktagAnalysisStatus , "guess" ) ;
18481873 }
@@ -1866,11 +1891,7 @@ private void DisplayWordGloss(InterlinLineSpec spec, int choiceIndex)
18661891 case WfiAnalysisTags . kClassId :
18671892 if ( m_hvoDefault != m_hvoWordBundleAnalysis )
18681893 {
1869- // Real analysis isn't what we're displaying, so morph breakdown
1870- // is a guess. Is it a human-approved guess?
1871- bool isHumanGuess = m_this . GuessCache . get_IntProp ( m_hvoDefault , InterlinViewDataCache . OpinionAgentFlid ) !=
1872- ( int ) AnalysisGuessServices . OpinionAgent . Parser ;
1873- m_this . SetGuessing ( m_vwenv , isHumanGuess ? ApprovedGuessColor : MachineGuessColor ) ;
1894+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
18741895 }
18751896 var wa = ( IWfiAnalysis ) m_defaultObj ;
18761897 if ( wa . MeaningsOC . Count == 0 )
@@ -1899,7 +1920,7 @@ private void DisplayWordGloss(InterlinLineSpec spec, int choiceIndex)
18991920 }
19001921 else
19011922 {
1902- m_this . SetGuessing ( m_vwenv ) ;
1923+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
19031924 m_vwenv . AddObj ( m_hvoDefault , m_this , kfragLineChoices + choiceIndex ) ;
19041925 }
19051926 break ;
@@ -1919,18 +1940,14 @@ private void DisplayWordPOS(int choiceIndex)
19191940 case WfiAnalysisTags . kClassId :
19201941 if ( m_hvoDefault != m_hvoWordBundleAnalysis )
19211942 {
1922- // Real analysis isn't what we're displaying, so POS is a guess.
1923- bool isHumanApproved = m_this . GuessCache . get_IntProp ( m_hvoDefault , InterlinViewDataCache . OpinionAgentFlid )
1924- != ( int ) AnalysisGuessServices . OpinionAgent . Parser ;
1925-
1926- m_this . SetGuessing ( m_vwenv , isHumanApproved ? ApprovedGuessColor : MachineGuessColor ) ;
1943+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
19271944 }
19281945 m_this . AddAnalysisPos ( m_vwenv , m_hvoDefault , m_hvoWordBundleAnalysis , choiceIndex ) ;
19291946 break ;
19301947 case WfiGlossTags . kClassId :
19311948 m_hvoWfiAnalysis = m_defaultObj . Owner . Hvo ;
19321949 if ( m_hvoWordBundleAnalysis == m_hvoWordform ) // then our analysis is a guess
1933- m_this . SetGuessing ( m_vwenv ) ;
1950+ m_this . SetGuessing ( m_vwenv , m_this . GetGuessColor ( m_defaultObj ) ) ;
19341951 m_vwenv . AddObj ( m_hvoWfiAnalysis , m_this , kfragAnalysisCategoryChoices + choiceIndex ) ;
19351952 break ;
19361953 default :
@@ -2288,7 +2305,7 @@ private void EnsureLoader()
22882305
22892306 internal virtual IParaDataLoader CreateParaLoader ( )
22902307 {
2291- return new InterlinViewCacheLoader ( new AnalysisGuessServices ( m_cache ) , GuessCache ) ;
2308+ return new InterlinViewCacheLoader ( new AnalysisGuessServices ( m_cache , IsParsingMode ( ) ) , GuessCache ) ;
22922309 }
22932310
22942311 internal void RecordGuessIfNotKnown ( AnalysisOccurrence selected )
@@ -2409,7 +2426,7 @@ public interface IParaDataLoader
24092426 {
24102427 void LoadParaData ( IStTxtPara para ) ;
24112428 void LoadSegmentData ( ISegment seg ) ;
2412- void ResetGuessCache ( ) ;
2429+ void ResetGuessCache ( bool parsingMode ) ;
24132430 bool UpdatingOccurrence ( IAnalysis oldAnalysis , IAnalysis newAnalysis ) ;
24142431 void RecordGuessIfNotKnown ( AnalysisOccurrence occurrence ) ;
24152432 IAnalysis GetGuessForWordform ( IWfiWordform wf , int ws ) ;
@@ -2533,10 +2550,11 @@ protected virtual void SetInt(int hvo, int flid, int n)
25332550 #region IParaDataLoader Members
25342551
25352552
2536- public void ResetGuessCache ( )
2553+ public void ResetGuessCache ( bool parsingMode )
25372554 {
25382555 // recreate the guess services, so they will use the latest FDO data.
25392556 GuessServices . ClearGuessData ( ) ;
2557+ GuessServices . PrioritizeParser = parsingMode ;
25402558 // clear the cache for the guesses, so it won't have any stale data.
25412559 m_guessCache . ClearPropFromCache ( InterlinViewDataCache . AnalysisMostApprovedFlid ) ;
25422560 }
0 commit comments