From 96ee2145ac3d5a27f330a6a588d605dc2e13f6e4 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Wed, 27 Nov 2024 11:42:20 -0500 Subject: [PATCH] Move sort to corpus class --- src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs | 5 ++++- src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs | 3 +-- .../Corpora/ParatextProjectTermsParserTests.cs | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs b/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs index 46fbdaf7..2faa5335 100644 --- a/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs +++ b/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs @@ -19,7 +19,10 @@ public ParatextBackupTermsCorpus( IEnumerable<(string, IReadOnlyList)> glosses = new ZipParatextProjectTermsParser( archive, settings - ).Parse(termCategories, useTermGlosses, chapters); + ) + .Parse(termCategories, useTermGlosses, chapters) + .OrderBy(g => g.TermId); + string textId = $"{settings.BiblicalTermsListType}:{settings.BiblicalTermsProjectName}:{settings.BiblicalTermsFileName}"; diff --git a/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs b/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs index 0ae235a2..b58ce3c6 100644 --- a/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs +++ b/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs @@ -168,8 +168,7 @@ protected ParatextProjectTermsParserBase(ParatextProjectSettingsParserBase setti { return termsRenderings .Concat(termsGlosses.Where(kvp => !termsRenderings.ContainsKey(kvp.Key))) - .Select(kvp => (kvp.Key, (IReadOnlyList)kvp.Value.ToList())) - .OrderBy(glosses => glosses.Key); + .Select(kvp => (kvp.Key, (IReadOnlyList)kvp.Value.ToList())); } return new List<(string, IReadOnlyList)>(); } diff --git a/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs b/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs index 41da90b1..54034b9e 100644 --- a/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs @@ -55,7 +55,7 @@ public void TestGetKeyTermsFromTermsLocalizations_NoTermRenderings() ); IEnumerable<(string TermId, IReadOnlyList Glosses)> terms = env.GetGlosses(); Assert.That(terms.Count, Is.EqualTo(5726)); - Assert.That(string.Join(" ", terms.First().Glosses), Is.EqualTo("Aaron")); + Assert.That(string.Join(" ", terms.First().Glosses), Is.EqualTo("Abagtha")); } [Test] @@ -139,7 +139,8 @@ public void TestGetKeyTermsFromTermsLocalizations_TermRenderingsExists_PreferLoc ); IReadOnlyList<(string TermId, IReadOnlyList Glosses)> terms = env.GetGlosses().ToList(); Assert.That(terms.Count, Is.EqualTo(5726)); - Assert.That(string.Join(" ", terms[1].Glosses), Is.EqualTo("Aaron")); + Assert.That(string.Join(" ", terms[1].Glosses), Is.EqualTo("Abagtha")); + Assert.That(string.Join(" ", terms[2].Glosses), Is.EqualTo("Abi")); } [Test]