Skip to content

Commit 0bde379

Browse files
authored
Fix LT-22422: record msa in lex entry for variants in XAmple (#683)
1 parent bc18eb3 commit 0bde379

File tree

5 files changed

+52
-43
lines changed

5 files changed

+52
-43
lines changed

Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/IrregularlyInflectedFormsLexicon.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
\eType prefix
5656

5757

58-
\lx 4157
58+
\lx 4157.0.3193
5959
\g believe.pst.pl
6060
\c W
6161
\wc root
@@ -67,7 +67,7 @@
6767
\mp IrregInflForm6652
6868

6969

70-
\lx 4157.0
70+
\lx 4157.0.9872
7171
\g seek.pst.pl
7272
\c W
7373
\wc root
@@ -161,7 +161,7 @@
161161
\a bos {9892}
162162

163163

164-
\lx 8236
164+
\lx 8236.0.3193
165165
\g believe.prs
166166
\c W
167167
\wc root
@@ -226,7 +226,7 @@
226226
\a mot {9698}
227227

228228

229-
\lx 10257
229+
\lx 10257.0.4664
230230
\g second sense.pst
231231
\c W
232232
\wc root

Src/LexText/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles/emi-flexlex.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@
556556
\a maghuighuina {26872}
557557

558558

559-
\lx 4115
559+
\lx 4115.0.81036
560560
\g defecate
561561
\c W
562562
\wc root
@@ -3919,7 +3919,7 @@
39193919
\a angalua {81043}
39203920

39213921

3922-
\lx 23464
3922+
\lx 23464.0.61372
39233923
\g laugh.RDP
39243924
\c W
39253925
\wc root
@@ -3928,7 +3928,7 @@
39283928
\mp IrregInflForm71052
39293929

39303930

3931-
\lx 23464
3931+
\lx 23464.0.120453
39323932
\g laugh.RDP
39333933
\c W
39343934
\wc root
@@ -5990,7 +5990,7 @@
59905990
\a apere {75597}
59915991

59925992

5993-
\lx 33818
5993+
\lx 33818.0.76068
59945994
\g POSS.3SG
59955995
\c W
59965996
\wc root
@@ -7132,7 +7132,7 @@
71327132
\a natuena {72026}
71337133

71347134

7135-
\lx 39937
7135+
\lx 39937.0.57373
71367136
\g body
71377137
\c W
71387138
\wc root
@@ -8150,7 +8150,7 @@
81508150
\eType suffix
81518151

81528152

8153-
\lx 45889
8153+
\lx 45889.0.92329
81548154
\g wife
81558155
\c W
81568156
\wc root
@@ -9443,7 +9443,7 @@
94439443
\a sausaukaa {115103}
94449444

94459445

9446-
\lx 53296
9446+
\lx 53296.0.35188
94479447
\g 1PAU.EXCL
94489448
\c W
94499449
\wc root
@@ -12726,7 +12726,7 @@
1272612726
\a palepale {67250}
1272712727

1272812728

12729-
\lx 70895
12729+
\lx 70895.0.148174
1273012730
\g handle
1273112731
\c W
1273212732
\wc root
@@ -14191,7 +14191,7 @@
1419114191
\a tumtumlana {51181}
1419214192

1419314193

14194-
\lx 78967
14194+
\lx 78967.0.119135
1419514195
\g end
1419614196
\c W
1419714197
\wc root
@@ -14815,7 +14815,7 @@
1481514815
\a parroe {84866}
1481614816

1481714817

14818-
\lx 82227
14818+
\lx 82227.0.106969
1481914819
\g push.aside.RDP
1482014820
\c W
1482114821
\wc root
@@ -15728,7 +15728,7 @@
1572815728
\a kotolungaulu {46644}
1572915729

1573015730

15731-
\lx 87184
15731+
\lx 87184.0.32313
1573215732
\g sleep.RDP
1573315733
\c W
1573415734
\wc root
@@ -15737,7 +15737,7 @@
1573715737
\mp IrregInflForm71052
1573815738

1573915739

15740-
\lx 87184
15740+
\lx 87184.0.90982
1574115741
\g sleep.RDP
1574215742
\c W
1574315743
\wc root
@@ -21412,7 +21412,7 @@
2141221412
\a tuvu {11507}
2141321413

2141421414

21415-
\lx 117012
21415+
\lx 117012.0.49223
2141621416
\g our
2141721417
\c W
2141821418
\wc root
@@ -24079,7 +24079,7 @@
2407924079
\a aippetana {137436}
2408024080

2408124081

24082-
\lx 129944
24082+
\lx 129944.0.78733
2408324083
\g taste
2408424084
\c W
2408524085
\wc root

Src/LexText/ParserCore/ParserXmlWriterExtensions.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015 SIL International
1+
// Copyright (c) 2015 SIL International
22
// This software is licensed under the LGPL, version 2.1 or later
33
// (http://www.gnu.org/licenses/lgpl-2.1.html)
44

@@ -18,16 +18,19 @@ namespace SIL.FieldWorks.WordWorks.Parser
1818
{
1919
internal static class ParserXmlWriterExtensions
2020
{
21-
private static Tuple<int, int> ProcessMsaHvo(string msaHvo)
21+
private static Tuple<int, int, int> ProcessMsaHvo(string msaHvo)
2222
{
2323
string[] msaHvoParts = msaHvo.Split('.');
24-
return Tuple.Create(int.Parse(msaHvoParts[0]), msaHvoParts.Length == 2 ? int.Parse(msaHvoParts[1]) : 0);
24+
// the msa hvo has one part or three parts separated by a period.
25+
// in the latter case, it is the lex entry hvo, the lex ref hvo, and the msa hvo
26+
return Tuple.Create(int.Parse(msaHvoParts[0]), msaHvoParts.Length == 3 ? int.Parse(msaHvoParts[1]) : 0,
27+
msaHvoParts.Length == 3 ? int.Parse(msaHvoParts[2]) : 0);
2528
}
2629

2730
public static void WriteMsaElement(this XmlWriter writer, LcmCache cache, string formID, string msaID, string type, string wordType)
2831
{
2932
// Irregulary inflected forms can have a combination MSA hvo: the LexEntry hvo, a period, and an index to the LexEntryRef
30-
Tuple<int, int> msaTuple = ProcessMsaHvo(msaID);
33+
Tuple<int, int, int> msaTuple = ProcessMsaHvo(msaID);
3134
ICmObject obj = cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(msaTuple.Item1);
3235
switch (obj.GetType().Name)
3336
{
@@ -52,9 +55,9 @@ public static void WriteMsaElement(this XmlWriter writer, LcmCache cache, string
5255
var entry = (ILexEntry) obj;
5356
if (entry.EntryRefsOS.Count > 0)
5457
{
55-
ILexEntryRef lexEntryRef = entry.EntryRefsOS[msaTuple.Item2];
56-
ILexSense sense = MorphServices.GetMainOrFirstSenseOfVariant(lexEntryRef);
57-
WriteStemMsaXmlElement(writer, (IMoStemMsa) sense.MorphoSyntaxAnalysisRA, entry.VariantEntryRefs);
58+
// use the msa itself
59+
IMoStemMsa stemMsa = (IMoStemMsa)cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(msaTuple.Item3);
60+
WriteStemMsaXmlElement(writer, stemMsa, entry.VariantEntryRefs);
5861
}
5962
break;
6063
case "LexEntryInflType":
@@ -328,7 +331,7 @@ public static void WriteMorphInfoElements(this XmlWriter writer, LcmCache cache,
328331
int iFirstSpace = shortName.IndexOf(" (", StringComparison.Ordinal);
329332
int iLastSpace = shortName.LastIndexOf("):", StringComparison.Ordinal) + 2;
330333
alloform = shortName.Substring(0, iFirstSpace);
331-
Tuple<int, int> msaTuple = ProcessMsaHvo(msaID);
334+
Tuple<int, int, int> msaTuple = ProcessMsaHvo(msaID);
332335
ICmObject msaObj = cache.ServiceLocator.GetObject(msaTuple.Item1);
333336
if (msaObj.ClassID == LexEntryTags.kClassId)
334337
{
@@ -344,7 +347,10 @@ public static void WriteMorphInfoElements(this XmlWriter writer, LcmCache cache,
344347
MorphServices.JoinGlossAffixesOfInflVariantTypes(lexEntryRef.VariantEntryTypesRS,
345348
glossWs, out sbGlossPrepend, out sbGlossAppend);
346349
ITsIncStrBldr sbGloss = sbGlossPrepend;
347-
sbGloss.Append(sense.Gloss.BestAnalysisAlternative.Text);
350+
// use the gloss of the first sense of the MSA
351+
IMoStemMsa stemMsa = (IMoStemMsa)cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(msaTuple.Item3);
352+
string msaGloss = (stemMsa != null) ? stemMsa.GetGlossOfFirstSense() : "***";
353+
sbGloss.Append(msaGloss);
348354
sbGloss.Append(sbGlossAppend.Text);
349355
gloss = sbGloss.Text;
350356
}

Src/Transforms/Application/FxtM3ParserCommon.xsl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,16 @@
179179
<xsl:param name="msa"/>
180180
<xsl:value-of select="$lexEntry/@Id"/>
181181
<xsl:variable name="iPos" select="count($lexEntryRef/preceding-sibling::LexEntryRef)"/>
182-
<xsl:if test="$iPos &gt; 0">
183-
<xsl:text>.</xsl:text>
184-
<!-- Subtracting 1 to account for 0-indexing in C# -->
185-
<xsl:value-of select="$iPos - 1"/>
186-
</xsl:if>
182+
<xsl:text>.</xsl:text>
183+
<xsl:choose>
184+
<xsl:when test="$iPos &gt; 0">
185+
<!-- Subtracting 1 to account for 0-indexing in C# -->
186+
<xsl:value-of select="$iPos - 1"/>
187+
</xsl:when>
188+
<xsl:otherwise>
189+
<xsl:text>0</xsl:text>
190+
</xsl:otherwise>
191+
</xsl:choose>
187192
<xsl:call-template name="AppendAnyMsaCountNumber">
188193
<xsl:with-param name="msa" select="$msa"/>
189194
</xsl:call-template>

Src/Transforms/Application/FxtM3ParserToXAmpleLex.xsl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,17 +2166,15 @@ InflClass
21662166
<xsl:param name="lexEntry"/>
21672167
<xsl:param name="sVariantOfGloss"/>
21682168
<xsl:param name="stemMsa"/>
2169-
<xsl:choose>
2170-
<xsl:when test="key('LexEntryInflTypes',$lexEntryRef/LexEntryType/@dst)">
2171-
<xsl:call-template name="IdOfVariantEntry">
2172-
<xsl:with-param name="lexEntry" select="$lexEntry"/>
2173-
<xsl:with-param name="lexEntryRef" select="$lexEntryRef"/>
2174-
</xsl:call-template>
2175-
</xsl:when>
2176-
<xsl:otherwise>
2177-
<xsl:value-of select="$stemMsa/@Id"/>
2178-
</xsl:otherwise>
2179-
</xsl:choose>
2169+
<xsl:if test="key('LexEntryInflTypes',$lexEntryRef/LexEntryType/@dst)">
2170+
<!-- we produce sn id that has three parts separated by a period: the lex entry, the lex ref, and the msa -->
2171+
<xsl:call-template name="IdOfVariantEntry">
2172+
<xsl:with-param name="lexEntry" select="$lexEntry"/>
2173+
<xsl:with-param name="lexEntryRef" select="$lexEntryRef"/>
2174+
</xsl:call-template>
2175+
<xsl:text>.</xsl:text>
2176+
</xsl:if>
2177+
<xsl:value-of select="$stemMsa/@Id"/>
21802178
<xsl:variable name="gloss">
21812179
<xsl:call-template name="GlossOfVariant">
21822180
<xsl:with-param name="lexEntryRef" select="$lexEntryRef"/>

0 commit comments

Comments
 (0)