diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9304186d54..6fb92b13cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Lucene.NET Contributor's Guide +# Lucene.NET Contributor's Guide Have you found a bug or do you have an idea for a cool new enhancement? Contributing code is a great way to give something back to the open-source community. Before you dig right into the code there are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. @@ -26,7 +26,7 @@ There are several [**Open Issues on GitHub**](https://github.com/apache/lucenene * Helping update the API, or at least just providing feedback on which API changes are affecting the usability. There are several things on our radar, like integrating something like [Lucene.Net.Linq](https://github.com/themotleyfool/Lucene.Net.Linq) directly into our project, [converting the remaining public-facing iterator classes into `IEnumerator`](https://issues.apache.org/jira/projects/LUCENENET/issues/LUCENENET-469?filter=allopenissues) so they can be used with foreach loops, adding extension methods to remove the need for casting, etc. * Making demos and tutorials, blogging about Lucene.Net, etc. (and providing feedback on how we can make the API better!). If you write a helpful Lucene.Net post on your blog, be sure to let us know so we can link to it. * Helping out with documentation. We are still trying to make the API docs easily navigable (see #206), and there are many files that are not formatted correctly (links not appearing, tables not very readable, etc). Also, we need help getting all of the Java-related documentation converted to use .NET methodologies. -* Fixing TODOs. There are several TODOs throughout the code that need to be reviewed and action taken, if necessary. Search for `LUCENENET TODO|LUCENE TO-DO` using the regular expression option in Visual Studio to find them. Do note there are a lot of TODOs left over from Java Lucene that are safe to ignore. +* Fixing TODOs. There are several TODOs throughout the code that need to be reviewed and action taken, if necessary. Search for `LUCENENET TODO` using the regular expression option in Visual Studio to find them. Do note there are a lot of TODOs left over from Java Lucene that are safe to ignore. * Reviewing code. Pick a random section, review line by line, comparing the code against the [original Lucene 4.8.0 code](https://github.com/apache/lucene-solr/tree/releases/lucene-solr/4.8.0/lucene). Many of the bugs have been found this way, as the tests are not showing them. Let us know if you find anything suspicious on the [dev mailing list](https://cwiki.apache.org/confluence/display/LUCENENET/Mailing+Lists) or [submit a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) with a fix. * Creating projects to make Lucene.Net easier to use with various .NET frameworks (ASP.NET MVC, WebApi, AspNetCore, WPF, EntityFramework, etc). In general, we would like common tasks as easy as possible to integrate into applications build on these frameworks without everyone having to write the same boilerplate code. * Building automation tools to eliminate some of the manual work of managing the project, updating information on various web pages, creating tools to make porting/upgrading more automated, etc. @@ -35,4 +35,4 @@ Or, if none of that interests you, join our [dev mailing list](https://cwiki.apa ## Thank You For Your Help! -Again, thank you very much for your contribution. May the fork be with you! \ No newline at end of file +Again, thank you very much for your contribution. May the fork be with you! diff --git a/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingInfixSuggester.cs b/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingInfixSuggester.cs index 7a62cee329..48e42b4778 100644 --- a/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingInfixSuggester.cs +++ b/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingInfixSuggester.cs @@ -138,7 +138,7 @@ public AnalyzingInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyz /// ngrams (increasing index size but making lookups /// faster). // LUCENENET specific - LUCENE-5889, a 4.11.0 feature. calls new constructor with extra param. - // LUCENENET TODO: Remove method at version 4.11.0. Was retained for perfect 4.8 compatibility + // LUCENENET UPGRADE TODO: Remove method at version 4.11.0. Was retained for perfect 4.8 compatibility public AnalyzingInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars) : this(matchVersion, dir, indexAnalyzer, queryAnalyzer, minPrefixChars, commitOnBuild: false) @@ -896,4 +896,4 @@ public override long Count } } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Suggest/Suggest/Analyzing/BlendedInfixSuggester.cs b/src/Lucene.Net.Suggest/Suggest/Analyzing/BlendedInfixSuggester.cs index d7d8f9756d..ffc6d4a245 100644 --- a/src/Lucene.Net.Suggest/Suggest/Analyzing/BlendedInfixSuggester.cs +++ b/src/Lucene.Net.Suggest/Suggest/Analyzing/BlendedInfixSuggester.cs @@ -105,7 +105,7 @@ public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer /// Factor to multiply the number of searched elements before ponderate /// If there are problems opening the underlying Lucene index. // LUCENENET specific - LUCENE-5889, a 4.11.0 feature. calls new constructor with extra param. - // LUCENENET TODO: Remove method at version 4.11.0. Was retained for perfect 4.8 compatibility + // LUCENENET UPGRADE TODO: Remove method at version 4.11.0. Was retained for perfect 4.8 compatibility public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlenderType blenderType, int numFactor) : this(matchVersion, dir, indexAnalyzer, queryAnalyzer, minPrefixChars, blenderType, numFactor, commitOnBuild: false) @@ -325,4 +325,4 @@ public virtual int Compare(Lookup.LookupResult o1, Lookup.LookupResult o2) } } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs index 56ccd4dda6..88d333ab5c 100644 --- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs +++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs @@ -52,7 +52,7 @@ public void TestBasic() }; Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); IList results = suggester.DoLookup(TestUtil.StringToCharSequence("ear", Random).ToString(), 10, true, true); @@ -95,14 +95,14 @@ public void TestAfterLoad() DirectoryInfo tempDir = CreateTempDir("AnalyzingInfixSuggesterTest"); Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 try { suggester.Build(new InputArrayEnumerator(keys)); assertEquals(2, suggester.Count); suggester.Dispose(); - suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 IList results = suggester.DoLookup(TestUtil.StringToCharSequence("ear", Random).ToString(), 10, true, true); assertEquals(2, results.size()); assertEquals("a penny saved is a penny earned", results[0].Key); @@ -145,7 +145,7 @@ public override string ToString() internal class TestHighlightAnalyzingInfixSuggester : AnalyzingInfixSuggester { public TestHighlightAnalyzingInfixSuggester(AnalyzingInfixSuggesterTest outerInstance, Analyzer a) - : base(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3) //LUCENENET TODO: add extra false param at version 4.11.0 + : base(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3) //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 { } @@ -254,7 +254,7 @@ public void TestRandomMinPrefixLength() Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); int minPrefixLength = Random.nextInt(10); - AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixLength); //LUCENENET TODO: add extra false param at version 4.11.0 + AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixLength); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 try { suggester.Build(new InputArrayEnumerator(keys)); @@ -330,7 +330,7 @@ public void TestRandomMinPrefixLength() // Make sure things still work after close and reopen: suggester.Dispose(); - suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixLength); //LUCENENET TODO: add extra false param at version 4.11.0 + suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixLength); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 } } finally @@ -348,7 +348,7 @@ public void TestHighlight() }; Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); IList results = suggester.DoLookup(TestUtil.StringToCharSequence("penn", Random).ToString(), 10, true, true); assertEquals(1, results.size()); @@ -359,7 +359,7 @@ internal class TestHighlightChangeCaseAnalyzingInfixSuggester : AnalyzingInfixSu { private readonly AnalyzingInfixSuggesterTest outerInstance; public TestHighlightChangeCaseAnalyzingInfixSuggester(AnalyzingInfixSuggesterTest outerInstance, Analyzer a) - : base(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3) //LUCENENET TODO: add extra false param at version 4.11.0 + : base(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3) //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 { this.outerInstance = outerInstance; } @@ -381,7 +381,7 @@ public void TestHighlightCaseChange() Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, true); IList results; - using (AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3)) //LUCENENET TODO: add extra false param at version 4.11.0 + using (AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3)) //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 { suggester.Build(new InputArrayEnumerator(keys)); results = suggester.DoLookup(TestUtil.StringToCharSequence("penn", Random).ToString(), 10, true, true); @@ -445,7 +445,7 @@ public void TestSuggestStopFilter() public void TestEmptyAtStart() { Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(new Input[0])); suggester.Add(new BytesRef("a penny saved is a penny earned"), null, 10, new BytesRef("foobaz")); suggester.Add(new BytesRef("lend me your ear"), null, 8, new BytesRef("foobar")); @@ -483,7 +483,7 @@ public void TestEmptyAtStart() public void TestBothExactAndPrefix() { Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(new Input[0])); suggester.Add(new BytesRef("the pen is pretty"), null, 10, new BytesRef("foobaz")); suggester.Refresh(); @@ -595,7 +595,7 @@ public void TestRandomNRT() Console.WriteLine(" minPrefixChars=" + minPrefixChars); } - AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixChars); //LUCENENET TODO: add extra false param at version 4.11.0 + AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixChars); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 try { @@ -692,7 +692,7 @@ public void TestRandomNRT() } lookupThread.Finish(); suggester.Dispose(); - suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixChars); //LUCENENET TODO: add extra false param at version 4.11.0 + suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, minPrefixChars); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 lookupThread = new LookupThread(this, suggester); lookupThread.Start(); @@ -896,7 +896,7 @@ public void TestBasicNRT() }; Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); - using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + using AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewDirectory(), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); IList results = suggester.DoLookup(TestUtil.StringToCharSequence("ear", Random).ToString(), 10, true, true); @@ -1053,13 +1053,13 @@ public void TestBasicContext() Analyzer a = new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false); if (iter == 0) { - suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); } else { // Test again, after close/reopen: - suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET TODO: add extra false param at version 4.11.0 + suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, 3); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 } // No context provided, all results returned diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/BlendedInfixSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/BlendedInfixSuggesterTest.cs index 968aa0e368..e5e6541beb 100644 --- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/BlendedInfixSuggesterTest.cs +++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/BlendedInfixSuggesterTest.cs @@ -49,7 +49,7 @@ public void TestBlendedSort() BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, BlendedInfixSuggester.BlenderType.POSITION_LINEAR, - BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); // we query for star wars and check that the weight @@ -100,7 +100,7 @@ public void TestBlendingType() // BlenderType.RECIPROCAL is using 1/(1+p) * w where w is weight and p the position of the word suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, - BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 1); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 1); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); assertEquals(w, GetInResults(suggester, "top", pl, 1)); @@ -134,7 +134,7 @@ public void TestRequiresMore() // if factor is small, we don't get the expected element BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, - BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 1); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 1); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); @@ -154,7 +154,7 @@ public void TestRequiresMore() // if we increase the factor we have it suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, - BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 2); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, 2); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); // we have it @@ -186,7 +186,7 @@ public void TestNullPrefixToken() BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, BlendedInfixSuggester.BlenderType.POSITION_LINEAR, - BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); GetInResults(suggester, "of ", payload, 1); @@ -217,7 +217,7 @@ public void TestTrying() BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, NewFSDirectory(tempDir), a, a, AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS, BlendedInfixSuggester.BlenderType.POSITION_RECIPROCAL, - BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET TODO: add extra false param at version 4.11.0 + BlendedInfixSuggester.DEFAULT_NUM_FACTOR); //LUCENENET UPGRADE TODO: add extra false param at version 4.11.0 suggester.Build(new InputArrayEnumerator(keys)); diff --git a/src/Lucene.Net.Tests.TestFramework/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs b/src/Lucene.Net.Tests.TestFramework/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs index d0a758539f..01afac4db4 100644 --- a/src/Lucene.Net.Tests.TestFramework/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs +++ b/src/Lucene.Net.Tests.TestFramework/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs @@ -1,4 +1,4 @@ -//LUCENENET TODO: Incompatibility issues because this was ported from Lucene 8.2.0, and we are 4.8.0 +//LUCENENET UPGRADE TODO: Incompatibility issues because this was ported from Lucene 8.2.0, and we are 4.8.0 //Lucene version compatibility level 8.2.0 //using Lucene.Net.Analysis; diff --git a/src/Lucene.Net/Util/CharsRef.cs b/src/Lucene.Net/Util/CharsRef.cs index 4ab00fe4fd..14cc2b1de8 100644 --- a/src/Lucene.Net/Util/CharsRef.cs +++ b/src/Lucene.Net/Util/CharsRef.cs @@ -362,7 +362,7 @@ public virtual int Compare(CharsRef a, CharsRef b) /* aChar != bChar, fix up each one if they're both in or above the surrogate range, then compare them */ if (aChar >= 0xd800 && bChar >= 0xd800) - {//LUCENE TO-DO possible truncation or is char 16bit? + { if (aChar >= 0xe000) { aChar -= (char)0x800;