From 5f9f86a8c556c082e956c38159009a28cf3516a1 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Wed, 29 Oct 2025 17:34:39 +0100 Subject: [PATCH 1/4] Only use 'main' Parts of speech. Like FLEx. This excludes e.g. Reversel index parts of speech. --- backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs index bcaeb438f5..7212e3ce29 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs +++ b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs @@ -271,8 +271,9 @@ void MoveWs(CoreWritingSystemDefinition ws, public IAsyncEnumerable GetPartsOfSpeech() { - return PartOfSpeechRepository - .AllInstances() + return Cache.LangProject.PartsOfSpeechOA + .ReallyReallyAllPossibilities + .Cast() .OrderBy(p => p.Name.BestAnalysisAlternative.Text) .ToAsyncEnumerable() .Select(FromLcmPartOfSpeech); From ab502bcd17b96780dc8250e077f1d491516fcf49 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Mon, 3 Nov 2025 15:03:01 +0100 Subject: [PATCH 2/4] Fix tests that create duplicate parts-of-speech --- backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs b/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs index b7e5cc734f..ed027c1d34 100644 --- a/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs +++ b/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs @@ -64,6 +64,14 @@ public async Task DisposeAsync() { await _fixture.CrdtApi.DeleteEntry(entry.Id); } + await foreach (var pos in _fixture.FwDataApi.GetPartsOfSpeech()) + { + await _fixture.FwDataApi.DeletePartOfSpeech(pos.Id); + } + foreach (var pos in await _fixture.CrdtApi.GetPartsOfSpeech().ToArrayAsync()) + { + await _fixture.CrdtApi.DeletePartOfSpeech(pos.Id); + } } public SyncTests(SyncFixture fixture) From 48b8cf3f4ecbcb6ab7b866911d0607436dd20920 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Tue, 11 Nov 2025 11:56:56 +0100 Subject: [PATCH 3/4] fixup! Only use 'main' Parts of speech. Like FLEx. This excludes e.g. Reversel index parts of speech. --- backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs index 7212e3ce29..c52fba6a0f 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs +++ b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs @@ -271,9 +271,7 @@ void MoveWs(CoreWritingSystemDefinition ws, public IAsyncEnumerable GetPartsOfSpeech() { - return Cache.LangProject.PartsOfSpeechOA - .ReallyReallyAllPossibilities - .Cast() + return Cache.LangProject.AllPartsOfSpeech .OrderBy(p => p.Name.BestAnalysisAlternative.Text) .ToAsyncEnumerable() .Select(FromLcmPartOfSpeech); From c552964285a27ab356606bc262cf3cbe5c2e956f Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Tue, 11 Nov 2025 12:20:43 +0100 Subject: [PATCH 4/4] Add test that reversal index Parts of speech are excluded --- .../MiniLcmTests/PartOfSpeechTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs b/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs index 3943623a06..5533cbb2b4 100644 --- a/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs +++ b/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs @@ -1,6 +1,7 @@ using FwDataMiniLcmBridge.Api; using FwDataMiniLcmBridge.Tests.Fixtures; using MiniLcm.Models; +using SIL.LCModel; using SIL.LCModel.Infrastructure; namespace FwDataMiniLcmBridge.Tests.MiniLcmTests; @@ -81,4 +82,31 @@ public async Task SetPartOfSpeech_WithNullMorphoSyntaxAnalysisRA_ToNull() retrievedEntry.Should().NotBeNull(); retrievedEntry!.PartOfSpeechId.Should().BeNull(); } + + [Fact] + public async Task GetPartsOfSpeech_DoesNotReturnReversalIndexPos() + { + // Arrange + var fwApi = (FwDataMiniLcmApi)BaseApi; + var reversalIndexRepository = fwApi.Cache.ServiceLocator.GetInstance(); + var analysisWs = fwApi.Cache.DefaultAnalWs; + + var reversalPosGuid = Guid.NewGuid(); + UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Create Reversal Index POS", + "Remove Reversal Index POS", + fwApi.Cache.ServiceLocator.ActionHandler, + () => + { + var reversalIndex = reversalIndexRepository.FindOrCreateIndexForWs(analysisWs); + var posFactory = fwApi.Cache.ServiceLocator.GetInstance(); + var reversalPos = posFactory.Create(reversalPosGuid, reversalIndex.PartsOfSpeechOA); + reversalPos.Name.set_String(analysisWs, "Reversal Test POS"); + }); + + // Act + var partsOfSpeech = await Api.GetPartsOfSpeech().ToArrayAsync(); + + // Assert + partsOfSpeech.Should().NotContain(pos => pos.Id == reversalPosGuid); + } }