Skip to content

Commit

Permalink
Merge branch 'master' into ensure-tests-run-on-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonleenaylor authored Jul 25, 2024
2 parents 6b85c71 + cb03011 commit c83e463
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
13 changes: 7 additions & 6 deletions src/SIL.LCModel.FixData/HomographFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ internal override void InspectElement(XElement rt)
var citationForm = rt.Element("CitationForm");
if (citationForm != null)
{
if (citationForm.Elements("AUni").Any(e => e.Attribute("ws")?.Value == m_homographWs))
{
entriesWithCitationForm.Add(guid, citationForm);
}
entriesWithCitationForm.Add(guid, citationForm);
}
break;
case "LangProject":
Expand All @@ -103,6 +100,10 @@ internal override void FinalFixerInitialization(Dictionary<Guid, Guid> owners, H
{
base.FinalFixerInitialization(owners, guids, parentToOwnedObjsur, rtElementsToDelete); // Sets base class member variables

// Filter the entriesWithCitationForm to only include those that match the homograph writing system.
var relevantCitationEntries = entriesWithCitationForm.Where(kvp =>
kvp.Value.Elements("AUni").Any(e => e.Attribute("ws")?.Value == m_homographWs)).ToDictionary(kv => kv.Key, kv => kv.Value);

// Create a dictionary with the Form and MorphType guid as the key and a list of ownerguid's as the value. This
// will show us which LexEntries should have homograph numbers. If the list of ownerguids has only one entry then
// it's homograph number should be zero. If the list of owerguids has more than one guid then the LexEntries
Expand All @@ -116,10 +117,10 @@ internal override void FinalFixerInitialization(Dictionary<Guid, Guid> owners, H
if (!m_firstAllomorphs.Contains(morphGuid))
continue;
string rtFormText;
if (entriesWithCitationForm.Keys.Contains(owners[morphGuid]))
if (relevantCitationEntries.Keys.Contains(owners[morphGuid]))
{
var entryGuid = owners[morphGuid];
var cfElement = entriesWithCitationForm[entryGuid];
var cfElement = relevantCitationEntries[entryGuid];
rtFormText = GetStringInHomographWritingSystem(cfElement);
if (string.IsNullOrWhiteSpace(rtFormText))
continue;
Expand Down
56 changes: 25 additions & 31 deletions tests/SIL.LCModel.FixData.Tests/TestData/HomographDrops/Test.fwdata
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<languageproject version="7000051">
<rt class="LangProject" guid="5c937611-0e49-491b-ad5e-b61dd01a45d4">
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<AnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</AnalysisWss>
<CurAnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</CurAnalysisWss>
<CurPronunWss>
<Uni>enh</Uni>
</CurPronunWss>
<CurVernWss>
<Uni>enh enh-x-source</Uni>
</CurVernWss>
<DateCreated val="2021-03-16 21:26:31.627" />
<DateModified val="2024-03-14 17:37:44.271" />
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<LexDb>
<objsur guid="af26d792-ea5e-11de-8f7e-0013722f8dec" t="o" />
</LexDb>
<LinkedFilesRootDir>
<Uni>%proj%\LinkedFiles</Uni>
</LinkedFilesRootDir>
<VernWss>
<Uni>enh enh-x-source</Uni>
</VernWss>
</rt>
<rt class="LexEntry" guid="5c7a2684-97dc-4cac-8b31-4e0db5855b27">
<CitationForm>
<AUni ws="enh-x-source">+</AUni>
Expand Down Expand Up @@ -154,4 +123,29 @@
<AUni ws="en">Dictionary</AUni>
</Name>
</rt>
<rt class="LangProject" guid="5c937611-0e49-491b-ad5e-b61dd01a45d4">
<AnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</AnalysisWss>
<CurAnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</CurAnalysisWss>
<CurPronunWss>
<Uni>enh</Uni>
</CurPronunWss>
<CurVernWss>
<Uni>enh enh-x-source</Uni>
</CurVernWss>
<DateCreated val="2021-03-16 21:26:31.627" />
<DateModified val="2024-03-14 17:37:44.271" />
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<LexDb>
<objsur guid="af26d792-ea5e-11de-8f7e-0013722f8dec" t="o" />
</LexDb>
<VernWss>
<Uni>enh enh-x-source</Uni>
</VernWss>
</rt>
</languageproject>

0 comments on commit c83e463

Please sign in to comment.