The general scenario is that an StText is being edited and we wish to preserve as much as possible of the analysis: that is its segments, their translations and notes, and the analyses that have been assigned to the words of the paragraph. For example if the user makes a small change to one word we do not want to lose all the analysis that the user has already done on the rest of the paragraph. 1) Any segment whose text is unaffected by edits should be unmodified in every other way, except that its begin offset should be adjusted if text has been inserted or deleted before it. 2) If two segments are combined (eg. period removed): we want to concatenate their free translations, and keep all their notes as separate notes. 3) If a segment is split into two segments: We will keep the free translations, literal translations and notes on the first new segment. Enhance JohnT: Would it be better to put them on both segments or on the longer one? 4) If the text of a particular wordform has not changed then it should still have the same analysis. 5) It is particularly important that if the paragraph has a valid analysis beforehand, then it still should after edits. More specific notes on how translations and notes are handled: a. translations and notes are discarded for any original segment that is completely destroyed, that is, it is entirely within the range of characters deleted. b. translations and notes are preserved somewhere for any segment (there can be at most two) which overlaps the range deleted, that is, any segment which at least partly survives. c. material from the first of the partly preserved segments goes to the first of the resulting new segments, and from the second (last) partly preserved segment goes to the last of the resulting new segments. e.g. if we delete the material between the slashes in the following five segments, and insert two complete sentences A and B, we get the following segments and free translations ----0---- ---1a---/---1b--- ----2---- --3a--/--3b-- ---4---- TN0 TN1 TN2 TN3 TN4 ----0---- ---1a---/---A--- ----B---- --3b-- ---4---- TN0 TN1 TN3 TN4 d. If there is only one new segment and more than one partly surviving segment, we concatenate translations, and concatenate lists of notes (not the contents of the notes). e. If all the characters in the paragraph 'changed' but actually remained identical then the users would prefer that the analysis stick around (LT-12403) so we'll pretend it didn't change for adjustment purposes.
示例#1
0
		/// <summary>
		/// This is a primary entry point for IStTxtPara.SetContentsForMoveDest. It is similar to the
		/// top-level AdjustAnalysis, except that we know exactly what was inserted where, AND,
		/// we know it came from another paragraph. If the source paragraph is analysed, we can transfer any relevant
		/// analysis.
		/// Enhance JohnT: Currently this only supports moving from the end of one paragraph to the end of another.
		/// This is sufficient for all current usages of the MoveString method which this supports.
		/// </summary>
		public static void HandleMoveDest(IStTxtPara destPara, ITsString oldContents, int ichInsert,
			int cchInsert, IStTxtPara sourcePara, int ichSource, bool fDestParaIsNew)
		{
			if (ichInsert != destPara.Contents.Length - cchInsert)
				throw new NotImplementedException("We do not yet support moving strings to destinations other than paragraph end.");
			if (ichSource + cchInsert != sourcePara.Contents.Length)
				throw new NotImplementedException("We do not yet support moving strings from sources other than paragraph end.");

			AnalysisAdjuster adjuster = new AnalysisAdjuster(destPara, oldContents, new TsStringDiffInfo(ichInsert));
			BackTranslationAndFreeTranslationUpdateHelper.Do(destPara, () =>
				adjuster.HandleMoveDest(cchInsert, sourcePara, ichSource, fDestParaIsNew));
		}
示例#2
0
		/// <summary>
		/// This is the main entry point called by the setter on the StTxtPara.Contents used when the
		/// GetDiffsInTsStrings is also needed by another method that is called.
		/// </summary>
		public static void AdjustAnalysis(IStTxtPara para, ITsString oldContents, TsStringDiffInfo diffInfo)
		{
			AnalysisAdjuster adjuster = new AnalysisAdjuster(para, oldContents, diffInfo);
			BackTranslationAndFreeTranslationUpdateHelper.Do(para, adjuster.AdjustAnalysisInternal);
		}