From 4cad9445ec9c4a76417c2237d7e783fe4741ce2b Mon Sep 17 00:00:00 2001 From: John Lambert Date: Tue, 26 Nov 2024 14:19:06 -0500 Subject: [PATCH] Allow for zero corpora --- src/SIL.Machine/Corpora/NParallelTextCorpus.cs | 2 -- .../SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs index c8f2c904..d3df81da 100644 --- a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs @@ -12,8 +12,6 @@ public class NParallelTextCorpus : NParallelTextCorpusBase public NParallelTextCorpus(IEnumerable corpora, IComparer rowRefComparer = null) { Corpora = corpora.ToImmutableArray(); - if (Corpora.Count < 1) - throw new ArgumentException("There must be at least one corpora.", nameof(corpora)); RowRefComparer = rowRefComparer ?? new DefaultRowRefComparer(); AllRows = new bool[Corpora.Count] .Select(_ => false) diff --git a/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs b/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs index 68dc9f90..e07c23ce 100644 --- a/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs @@ -6,6 +6,14 @@ namespace SIL.Machine.Corpora; [TestFixture] public class NParallelTextCorpusTests { + [Test] + public void GetRows_ZeroCorpora() + { + var nParallelCorpus = new NParallelTextCorpus([]); + NParallelTextRow[] rows = nParallelCorpus.ToArray(); + Assert.That(rows.Length, Is.EqualTo(0)); + } + [Test] public void GetRows_ThreeCorpora() {