From 6e9b8a07d5599019480f6dd90dcaea26f243c4a7 Mon Sep 17 00:00:00 2001 From: Andy Black Date: Wed, 18 Feb 2026 11:45:51 -0700 Subject: [PATCH] Fix LT-22422: record msa in lex entry for variants in XAmple Change-Id: Ice265ae442005a955be3bd0e1a9a0c1734affc31 --- .../IrregularlyInflectedFormsLexicon.txt | 8 +++--- .../emi-flexlex.txt | 28 +++++++++---------- .../ParserCore/ParserXmlWriterExtensions.cs | 24 ++++++++++------ .../Application/FxtM3ParserCommon.xsl | 15 ++++++---- .../Application/FxtM3ParserToXAmpleLex.xsl | 20 ++++++------- 5 files changed, 52 insertions(+), 43 deletions(-) diff --git a/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/IrregularlyInflectedFormsLexicon.txt b/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/IrregularlyInflectedFormsLexicon.txt index d673b29866..778364692c 100644 --- a/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/IrregularlyInflectedFormsLexicon.txt +++ b/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/IrregularlyInflectedFormsLexicon.txt @@ -55,7 +55,7 @@ \eType prefix -\lx 4157 +\lx 4157.0.3193 \g believe.pst.pl \c W \wc root @@ -67,7 +67,7 @@ \mp IrregInflForm6652 -\lx 4157.0 +\lx 4157.0.9872 \g seek.pst.pl \c W \wc root @@ -161,7 +161,7 @@ \a bos {9892} -\lx 8236 +\lx 8236.0.3193 \g believe.prs \c W \wc root @@ -226,7 +226,7 @@ \a mot {9698} -\lx 10257 +\lx 10257.0.4664 \g second sense.pst \c W \wc root diff --git a/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/emi-flexlex.txt b/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/emi-flexlex.txt index 428514cf72..95d38d8515 100644 --- a/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/emi-flexlex.txt +++ b/Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/emi-flexlex.txt @@ -556,7 +556,7 @@ \a maghuighuina {26872} -\lx 4115 +\lx 4115.0.81036 \g defecate \c W \wc root @@ -3919,7 +3919,7 @@ \a angalua {81043} -\lx 23464 +\lx 23464.0.61372 \g laugh.RDP \c W \wc root @@ -3928,7 +3928,7 @@ \mp IrregInflForm71052 -\lx 23464 +\lx 23464.0.120453 \g laugh.RDP \c W \wc root @@ -5990,7 +5990,7 @@ \a apere {75597} -\lx 33818 +\lx 33818.0.76068 \g POSS.3SG \c W \wc root @@ -7132,7 +7132,7 @@ \a natuena {72026} -\lx 39937 +\lx 39937.0.57373 \g body \c W \wc root @@ -8150,7 +8150,7 @@ \eType suffix -\lx 45889 +\lx 45889.0.92329 \g wife \c W \wc root @@ -9443,7 +9443,7 @@ \a sausaukaa {115103} -\lx 53296 +\lx 53296.0.35188 \g 1PAU.EXCL \c W \wc root @@ -12726,7 +12726,7 @@ \a palepale {67250} -\lx 70895 +\lx 70895.0.148174 \g handle \c W \wc root @@ -14191,7 +14191,7 @@ \a tumtumlana {51181} -\lx 78967 +\lx 78967.0.119135 \g end \c W \wc root @@ -14815,7 +14815,7 @@ \a parroe {84866} -\lx 82227 +\lx 82227.0.106969 \g push.aside.RDP \c W \wc root @@ -15728,7 +15728,7 @@ \a kotolungaulu {46644} -\lx 87184 +\lx 87184.0.32313 \g sleep.RDP \c W \wc root @@ -15737,7 +15737,7 @@ \mp IrregInflForm71052 -\lx 87184 +\lx 87184.0.90982 \g sleep.RDP \c W \wc root @@ -21412,7 +21412,7 @@ \a tuvu {11507} -\lx 117012 +\lx 117012.0.49223 \g our \c W \wc root @@ -24079,7 +24079,7 @@ \a aippetana {137436} -\lx 129944 +\lx 129944.0.78733 \g taste \c W \wc root diff --git a/Src/LexText/ParserCore/ParserXmlWriterExtensions.cs b/Src/LexText/ParserCore/ParserXmlWriterExtensions.cs index b9e915404d..90113d3694 100644 --- a/Src/LexText/ParserCore/ParserXmlWriterExtensions.cs +++ b/Src/LexText/ParserCore/ParserXmlWriterExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2015 SIL International +// Copyright (c) 2015 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -18,16 +18,19 @@ namespace SIL.FieldWorks.WordWorks.Parser { internal static class ParserXmlWriterExtensions { - private static Tuple ProcessMsaHvo(string msaHvo) + private static Tuple ProcessMsaHvo(string msaHvo) { string[] msaHvoParts = msaHvo.Split('.'); - return Tuple.Create(int.Parse(msaHvoParts[0]), msaHvoParts.Length == 2 ? int.Parse(msaHvoParts[1]) : 0); + // the msa hvo has one part or three parts separated by a period. + // in the latter case, it is the lex entry hvo, the lex ref hvo, and the msa hvo + return Tuple.Create(int.Parse(msaHvoParts[0]), msaHvoParts.Length == 3 ? int.Parse(msaHvoParts[1]) : 0, + msaHvoParts.Length == 3 ? int.Parse(msaHvoParts[2]) : 0); } public static void WriteMsaElement(this XmlWriter writer, LcmCache cache, string formID, string msaID, string type, string wordType) { // Irregulary inflected forms can have a combination MSA hvo: the LexEntry hvo, a period, and an index to the LexEntryRef - Tuple msaTuple = ProcessMsaHvo(msaID); + Tuple msaTuple = ProcessMsaHvo(msaID); ICmObject obj = cache.ServiceLocator.GetInstance().GetObject(msaTuple.Item1); switch (obj.GetType().Name) { @@ -52,9 +55,9 @@ public static void WriteMsaElement(this XmlWriter writer, LcmCache cache, string var entry = (ILexEntry) obj; if (entry.EntryRefsOS.Count > 0) { - ILexEntryRef lexEntryRef = entry.EntryRefsOS[msaTuple.Item2]; - ILexSense sense = MorphServices.GetMainOrFirstSenseOfVariant(lexEntryRef); - WriteStemMsaXmlElement(writer, (IMoStemMsa) sense.MorphoSyntaxAnalysisRA, entry.VariantEntryRefs); + // use the msa itself + IMoStemMsa stemMsa = (IMoStemMsa)cache.ServiceLocator.GetInstance().GetObject(msaTuple.Item3); + WriteStemMsaXmlElement(writer, stemMsa, entry.VariantEntryRefs); } break; case "LexEntryInflType": @@ -328,7 +331,7 @@ public static void WriteMorphInfoElements(this XmlWriter writer, LcmCache cache, int iFirstSpace = shortName.IndexOf(" (", StringComparison.Ordinal); int iLastSpace = shortName.LastIndexOf("):", StringComparison.Ordinal) + 2; alloform = shortName.Substring(0, iFirstSpace); - Tuple msaTuple = ProcessMsaHvo(msaID); + Tuple msaTuple = ProcessMsaHvo(msaID); ICmObject msaObj = cache.ServiceLocator.GetObject(msaTuple.Item1); if (msaObj.ClassID == LexEntryTags.kClassId) { @@ -344,7 +347,10 @@ public static void WriteMorphInfoElements(this XmlWriter writer, LcmCache cache, MorphServices.JoinGlossAffixesOfInflVariantTypes(lexEntryRef.VariantEntryTypesRS, glossWs, out sbGlossPrepend, out sbGlossAppend); ITsIncStrBldr sbGloss = sbGlossPrepend; - sbGloss.Append(sense.Gloss.BestAnalysisAlternative.Text); + // use the gloss of the first sense of the MSA + IMoStemMsa stemMsa = (IMoStemMsa)cache.ServiceLocator.GetInstance().GetObject(msaTuple.Item3); + string msaGloss = (stemMsa != null) ? stemMsa.GetGlossOfFirstSense() : "***"; + sbGloss.Append(msaGloss); sbGloss.Append(sbGlossAppend.Text); gloss = sbGloss.Text; } diff --git a/Src/Transforms/Application/FxtM3ParserCommon.xsl b/Src/Transforms/Application/FxtM3ParserCommon.xsl index ed2db5adf7..a4c910dfeb 100644 --- a/Src/Transforms/Application/FxtM3ParserCommon.xsl +++ b/Src/Transforms/Application/FxtM3ParserCommon.xsl @@ -179,11 +179,16 @@ - - . - - - + . + + + + + + + 0 + + diff --git a/Src/Transforms/Application/FxtM3ParserToXAmpleLex.xsl b/Src/Transforms/Application/FxtM3ParserToXAmpleLex.xsl index f60944a9f5..5c97b9d8d7 100644 --- a/Src/Transforms/Application/FxtM3ParserToXAmpleLex.xsl +++ b/Src/Transforms/Application/FxtM3ParserToXAmpleLex.xsl @@ -2166,17 +2166,15 @@ InflClass - - - - - - - - - - - + + + + + + + . + +