@@ -812,129 +812,21 @@ internal ITsString NewAnalysisString(string str)
812812
813813 return TsStringUtils . MakeString ( str , m_caches . MainCache . DefaultAnalWs ) ;
814814 }
815- /// <summary>
816- /// Synchronize the word gloss and POS with the morpheme gloss and MSA info, to the extent possible.
817- /// Currently works FROM the morpheme TO the Word, but going the other way may be useful, too.
818- ///
819- /// for the word gloss:
820- /// - if only one morpheme, copy sense gloss to word gloss
821- /// - if multiple morphemes, copy first stem gloss to word gloss, but only if word gloss is empty.
822- /// for the POS:
823- /// - if there is more than one stem and they have different parts of speech, do nothing.
824- /// - if there is more than one derivational affix (DA), do nothing.
825- /// - otherwise, if there is no DA, use the POS of the stem.
826- /// - if there is no stem, do nothing.
827- /// - if there is a DA, use its 'to' POS.
828- /// (currently we don't insist that the 'from' POS matches the stem)
829- /// </summary>
815+
830816 internal void SyncMonomorphemicGlossAndPos ( bool fCopyToWordGloss , bool fCopyToWordPos )
831817 {
832818 CheckDisposed ( ) ;
833- if ( ! fCopyToWordGloss && ! fCopyToWordPos )
834- return ;
835-
836- ISilDataAccess sda = m_caches . DataAccess ;
837- int cmorphs = sda . get_VecSize ( m_hvoSbWord , ktagSbWordMorphs ) ;
838- int hvoSbRootSense = 0 ;
839- int hvoStemPos = 0 ; // ID in real database of part-of-speech of stem.
840- bool fGiveUpOnPOS = false ;
841- int hvoDerivedPos = 0 ; // real ID of POS output of derivational MSA.
842- for ( int imorph = 0 ; imorph < cmorphs ; imorph ++ )
843- {
844- int hvoMorph = sda . get_VecItem ( m_hvoSbWord , ktagSbWordMorphs , imorph ) ;
845- int hvoSbSense = sda . get_ObjectProp ( hvoMorph , ktagSbMorphGloss ) ;
846- if ( hvoSbSense == 0 )
847- continue ; // Can't sync from morph sense to word if we don't have morph sense.
848- var sense = m_caches . RealObject ( hvoSbSense ) as ILexSense ;
849- IMoMorphSynAnalysis msa = sense . MorphoSyntaxAnalysisRA ;
850-
851- // ITsString prefix = sda.get_StringProp(hvoMorph, ktagSbMorphPrefix);
852- // ITsString suffix = sda.get_StringProp(hvoMorph, ktagSbMorphPostfix);
853- // bool fStem = prefix.Length == 0 && suffix.Length == 0;
854-
855- bool fStem = msa is IMoStemMsa ;
856-
857- // If we have only one morpheme, treat it as the stem from which we will copy the gloss.
858- // otherwise, use the first stem we find, if any.
859- if ( ( fStem && hvoSbRootSense == 0 ) || cmorphs == 1 )
860- hvoSbRootSense = hvoSbSense ;
861-
862- if ( fStem )
863- {
864- int hvoPOS = ( msa as IMoStemMsa ) . PartOfSpeechRA != null ? ( msa as IMoStemMsa ) . PartOfSpeechRA . Hvo : 0 ;
865- if ( hvoPOS != hvoStemPos && hvoStemPos != 0 )
866- {
867- // found conflicting stems
868- fGiveUpOnPOS = true ;
869- }
870- else
871- hvoStemPos = hvoPOS ;
872- }
873- else if ( msa is IMoDerivAffMsa )
874- {
875- if ( hvoDerivedPos != 0 )
876- fGiveUpOnPOS = true ; // more than one DA
877- else
878- hvoDerivedPos = ( msa as IMoDerivAffMsa ) . ToPartOfSpeechRA != null ? ( msa as IMoDerivAffMsa ) . ToPartOfSpeechRA . Hvo : 0 ;
879- }
880- }
881-
882- // If we found a sense to copy from, do it. Replace the word gloss even there already is
883- // one, since users get confused/frustrated if we don't. (See LT-6141.) It's marked as a
884- // guess after all!
885- CopySenseToWordGloss ( fCopyToWordGloss , hvoSbRootSense ) ;
886-
887- // If we didn't find a stem, we don't have enough information to find a POS.
888- if ( hvoStemPos == 0 )
889- fGiveUpOnPOS = true ;
890-
891- int hvoLexPos = 0 ;
892- if ( ! fGiveUpOnPOS )
893- {
894- if ( hvoDerivedPos != 0 )
895- hvoLexPos = hvoDerivedPos ;
896- else
897- hvoLexPos = hvoStemPos ;
898- }
899- CopyLexPosToWordPos ( fCopyToWordPos , hvoLexPos ) ;
819+ m_sandbox . SyncMonomorphemicGlossAndPos ( fCopyToWordGloss , fCopyToWordPos ) ;
900820 }
901821
902822 protected virtual void CopySenseToWordGloss ( bool fCopyWordGloss , int hvoSbRootSense )
903823 {
904- if ( hvoSbRootSense != 0 && fCopyWordGloss )
905- {
906- ISilDataAccess sda = m_caches . DataAccess ;
907- m_caches . DataAccess . SetInt ( m_hvoSbWord , ktagSbWordGlossGuess , 1 ) ;
908- int hvoRealSense = m_caches . RealHvo ( hvoSbRootSense ) ;
909- foreach ( int wsId in m_sandbox . m_choices . EnabledWritingSystemsForFlid ( InterlinLineChoices . kflidWordGloss ) )
910- {
911- // Update the guess, by copying the glosses of the SbNamedObj representing the sense
912- // to the word gloss property.
913- //ITsString tssGloss = sda.get_MultiStringAlt(hvoSbRootSense, ktagSbNamedObjName, wsId);
914- // No, it is safer to copy from the real sense. We may be displaying more WSS for the word than the sense.
915- ITsString tssGloss = m_caches . MainCache . MainCacheAccessor . get_MultiStringAlt ( hvoRealSense , LexSenseTags . kflidGloss , wsId ) ;
916- sda . SetMultiStringAlt ( m_hvoSbWord , ktagSbWordGloss , wsId , tssGloss ) ;
917- sda . PropChanged ( null , ( int ) PropChangeType . kpctNotifyAll , m_hvoSbWord , ktagSbWordGloss ,
918- wsId , 0 , 0 ) ;
919- }
920- }
824+ m_sandbox . CopySenseToWordGloss ( fCopyWordGloss , hvoSbRootSense ) ;
921825 }
826+
922827 protected virtual int CopyLexPosToWordPos ( bool fCopyToWordCat , int hvoMsaPos )
923828 {
924- int hvoPos = 0 ;
925- if ( fCopyToWordCat && hvoMsaPos != 0 )
926- {
927- // got the one we want, in the real database. Make a corresponding sandbox one
928- // and install it as a guess
929- hvoPos = m_sandbox . CreateSecondaryAndCopyStrings ( InterlinLineChoices . kflidWordPos , hvoMsaPos ,
930- CmPossibilityTags . kflidAbbreviation ) ;
931- int hvoSbWordPos = m_caches . DataAccess . get_ObjectProp ( m_hvoSbWord , ktagSbWordPos ) ;
932- m_caches . DataAccess . SetObjProp ( m_hvoSbWord , ktagSbWordPos , hvoPos ) ;
933- m_caches . DataAccess . SetInt ( hvoPos , ktagSbNamedObjGuess , 1 ) ;
934- m_caches . DataAccess . PropChanged ( m_rootb , ( int ) PropChangeType . kpctNotifyAll , m_hvoSbWord ,
935- ktagSbWordPos , 0 , 1 , ( hvoSbWordPos == 0 ? 0 : 1 ) ) ;
936- }
937- return hvoPos ;
829+ return m_sandbox . CopyLexPosToWordPos ( fCopyToWordCat , hvoMsaPos ) ;
938830 }
939831 }
940832
@@ -1324,6 +1216,7 @@ internal void UpdateMorphBreaks(string sMorphs)
13241216 MorphemeBreaker mb = new MorphemeBreaker ( m_caches , sMorphs , m_hvoSbWord ,
13251217 m_wsVern , m_sandbox ) ;
13261218 mb . Run ( ) ;
1219+ m_sandbox . CopyLexEntryInfoToMonomorphemicWordGlossAndPos ( ) ;
13271220 m_rootb . Reconstruct ( ) ; // Everything changed, more or less.
13281221 // We've changed properties that the morph manager cares about, but we don't want it
13291222 // to fire when we fix the selection.
0 commit comments