You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2024/01/20 14:04:59 UTC
(lucenenet) branch master updated: BUG: Lucene.Net.Analysis.Miscellaneous.TestStemmerOverrideFilter::TestRandomRealisticWhiteSpace(): Ported patch from https://github.com/apache/lucene/commit/bce10efeb40c11271cb398c37b859408818b8a00 to fix rare random test failures. Fixes #896.
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 6868c38bf BUG: Lucene.Net.Analysis.Miscellaneous.TestStemmerOverrideFilter::TestRandomRealisticWhiteSpace(): Ported patch from https://github.com/apache/lucene/commit/bce10efeb40c11271cb398c37b859408818b8a00 to fix rare random test failures. Fixes #896.
6868c38bf is described below
commit 6868c38bf18d80f2696343905c7a5aced4f16a48
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Jan 20 20:52:51 2024 +0700
BUG: Lucene.Net.Analysis.Miscellaneous.TestStemmerOverrideFilter::TestRandomRealisticWhiteSpace(): Ported patch from https://github.com/apache/lucene/commit/bce10efeb40c11271cb398c37b859408818b8a00 to fix rare random test failures. Fixes #896.
---
.../Miscellaneous/TestStemmerOverrideFilter.cs | 34 ++++++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilter.cs
index 699d86fa8..fc5e47f82 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestStemmerOverrideFilter.cs
@@ -4,6 +4,7 @@ using J2N.Collections.Generic.Extensions;
using J2N.Text;
using Lucene.Net.Analysis.Core;
using Lucene.Net.Analysis.En;
+using Lucene.Net.Analysis.Util;
using Lucene.Net.Attributes;
using Lucene.Net.Util;
using NUnit.Framework;
@@ -99,7 +100,14 @@ namespace Lucene.Net.Analysis.Miscellaneous
public virtual void TestRandomRealisticWhiteSpace()
{
IDictionary<string, string> map = new Dictionary<string, string>();
+ // LUCENENET: Ported the patch from https://github.com/apache/lucene/commit/bce10efeb40c11271cb398c37b859408818b8a00
+ // so we don't have random failures.
+ ISet<string> seen = new HashSet<string>();
int numTerms = AtLeast(50);
+ bool ignoreCase = Random.nextBoolean();
+
+ CharacterUtils charUtils = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+
for (int i = 0; i < numTerms; i++)
{
string randomRealisticUnicodeString = TestUtil.RandomRealisticUnicodeString(Random);
@@ -116,16 +124,36 @@ namespace Lucene.Net.Analysis.Miscellaneous
}
if (sb.Length > 0)
{
- string value = TestUtil.RandomSimpleString(Random);
- map[sb.ToString()] = value.Length == 0 ? "a" : value;
+ string inputValue = sb.ToString();
+ // Make sure we don't try to add two inputs that vary only by case:
+ string seenInputValue;
+ if (ignoreCase)
+ {
+ // TODO: can we simply use inputValue.toLowerCase(Locale.ROOT)???
+ char[] buffer = inputValue.ToCharArray();
+ charUtils.ToLower(buffer, 0, buffer.Length);
+ seenInputValue = buffer.ToString();
+ }
+ else
+ {
+ seenInputValue = inputValue;
+ }
+
+ if (seen.Contains(seenInputValue) == false)
+ {
+ seen.Add(seenInputValue);
+ string value = TestUtil.RandomSimpleString(Random);
+ map[inputValue] =
+ value == string.Empty ? "a" : value;
+ }
}
}
if (map.Count == 0)
{
map["booked"] = "books";
}
- StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(Random.nextBoolean());
+ StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(ignoreCase);
IDictionary<string, string> entrySet = map;
StringBuilder input = new StringBuilder();
IList<string> output = new JCG.List<string>();