Skip to content

Commit

Permalink
Fixes #(959): Fix TermStats.TermText access, add CLI comments and 1 C…
Browse files Browse the repository at this point in the history
…LI bug fix (#963)

* Make TermStats.TermText public (#959)

* SWEEP: Added XML comments for Main(args) methods that are only intended for command line  CLI usage.

* BUG: Lucene,Net.Cli.BenchmarkFindQualityQueriesCommand: fixed mapping to QualityQueriesFinder.Main(args)

* Better approach to fixing TermStats.TermText to fix one failing unit test.

* Address PR feedback

---------

Co-authored-by: Paul Irwin <[email protected]>
  • Loading branch information
rclabo and paulirwin authored Oct 22, 2024
1 parent 4a190ff commit 1939665
Show file tree
Hide file tree
Showing 31 changed files with 442 additions and 127 deletions.
18 changes: 18 additions & 0 deletions src/Lucene.Net.Analysis.Kuromoji/Tools/DictionaryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ namespace Lucene.Net.Analysis.Ja.Util
* limitations under the License.
*/

/// <summary>
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// analysis kuromoji-build-dictionary.
/// </summary>
public static class DictionaryBuilder // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
{
public enum DictionaryFormat { IPADIC, UNIDIC };
Expand Down Expand Up @@ -62,6 +71,15 @@ ConnectionCostsWriter connectionCosts
Console.WriteLine("done");
}

/// <summary>
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// analysis kuromoji-build-dictionary.
/// </summary>
public static void Main(string[] args)
{
DictionaryFormat format;
Expand Down
18 changes: 17 additions & 1 deletion src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/Compile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ namespace Egothor.Stemmer
{
/// <summary>
/// The Compile class is used to compile a stemmer table.
/// <para />
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// analysis stempel-compile-stems
/// </summary>
public static class Compile // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
{
Expand All @@ -75,11 +83,19 @@ public static class Compile // LUCENENET specific: CA1052 Static holder types sh

/// <summary>
/// Entry point to the Compile application.
/// <para/>
/// <para />
/// This program takes any number of arguments: the first is the name of the
/// desired stemming algorithm to use (a list is available in the package
/// description) , all of the rest should be the path or paths to a file or
/// files containing a stemmer table to compile.
/// <para />
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// analysis stempel-compile-stems
/// </summary>
/// <param name="args">the command line arguments</param>
public static void Main(string[] args)
Expand Down
19 changes: 17 additions & 2 deletions src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/DiffIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ namespace Egothor.Stemmer
/// <summary>
/// The DiffIt class is a means generate patch commands from an already prepared
/// stemmer table.
/// <para />
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// analysis stempel-patch-stems
/// </summary>
public static class DiffIt // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
{
Expand All @@ -83,11 +91,18 @@ internal static int Get(int i, string s)

/// <summary>
/// Entry point to the DiffIt application.
/// <para>
/// <para />
/// This application takes one argument, the path to a file containing a
/// stemmer table. The program reads the file and generates the patch commands
/// for the stems.
/// </para>
/// <para />
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// analysis stempel-patch-stems
/// </summary>
/// <param name="args">the path to a file containing a stemmer table</param>
public static void Main(string[] args)
Expand Down
10 changes: 9 additions & 1 deletion src/Lucene.Net.Benchmark/ByTask/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public virtual void Execute()

/// <summary>
/// Run the benchmark algorithm.
/// <para />
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark
/// </summary>
/// <param name="args">Benchmark config and algorithm files.</param>
public static void Main(string[] args)
Expand All @@ -120,7 +128,7 @@ public static void Exec(string[] args)
//Environment.Exit(1);
}

// verify input files
// verify input files
FileInfo algFile = new FileInfo(args[0]);
if (!algFile.Exists /*|| !algFile.isFile() ||!algFile.canRead()*/ )
{
Expand Down
19 changes: 19 additions & 0 deletions src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,28 @@ namespace Lucene.Net.Benchmarks.ByTask.Programmatic

/// <summary>
/// Sample performance test written programmatically - no algorithm file is needed here.
/// <para />
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// benchmark sample
/// </summary>
public static class Sample // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
{

/// <summary>
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark sample
/// </summary>
/// <param name="args">The command line arguments</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Sample shows optional args[] parameter")]
public static void Main(string[] args)
{
Expand Down
19 changes: 19 additions & 0 deletions src/Lucene.Net.Benchmark/Quality/Trec/QueryDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,28 @@ namespace Lucene.Net.Benchmarks.Quality.Trec

/// <summary>
/// Command-line tool for doing a TREC evaluation run.
/// <para />
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// benchmark run-trec-eval
/// </summary>
public static class QueryDriver // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
{
/// <summary>
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark run-trec-eval
/// </summary>
/// <param name="args">Must contain 4 or 5 values</param>
/// <exception cref="ArgumentException">Thrown if the incorrect number of arguments are provided.</exception>
public static void Main(string[] args)
{
if (args.Length < 4 || args.Length > 5)
Expand Down
16 changes: 15 additions & 1 deletion src/Lucene.Net.Benchmark/Quality/Utils/QualityQueriesFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ namespace Lucene.Net.Benchmarks.Quality.Utils
/// <summary>
/// Suggest Quality queries based on an index contents.
/// Utility class, used for making quality test benchmarks.
/// <para />
/// LUCENENET specific: In the Java implementation, this class' Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to that method:
/// benchmark find-quality-queries
/// </summary>
public class QualityQueriesFinder
{
Expand All @@ -43,7 +51,13 @@ private QualityQueriesFinder(Store.Directory dir)
}

/// <summary>
///
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark find-quality-queries
/// </summary>
/// <param name="args">{index-dir}</param>
/// <exception cref="IOException">if cannot access the index.</exception>
Expand Down
10 changes: 10 additions & 0 deletions src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ protected virtual void ExtractFile(FileInfo sgmFile)
}
}

/// <summary>
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark extract-reuters
/// </summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
if (args.Length != 2)
Expand Down
10 changes: 10 additions & 0 deletions src/Lucene.Net.Benchmark/Utils/ExtractWikipedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ public virtual void Extract()
Console.WriteLine("Extraction took " + (finish - start) + " ms");
}

/// <summary>
/// LUCENENET specific: In the Java implementation, this Main method
/// was intended to be called from the command line. However, in .NET a
/// method within a DLL can't be directly called from the command line so we
/// provide a <see href="https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools">.NET tool</see>,
/// <see href="https://www.nuget.org/packages/lucene-cli">lucene-cli</see>,
/// with a command that maps to this method:
/// benchmark extract-wikipedia
/// </summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{

Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net.Demo/Facet/AssociationsFacetsExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class AssociationsFacetsExample
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -158,6 +158,7 @@ public FacetResult RunDrillDown()


/// <summary>Runs the sum int/float associations examples and prints the results.</summary>
/// <param name="args">The command line arguments</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Demo shows use of optional args argument")]
public static void Main(string[] args)
{
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net.Demo/Facet/DistanceFacetsExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public sealed class DistanceFacetsExample : IDisposable
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -264,6 +264,7 @@ public void Dispose()
}

/// <summary>Runs the search and drill-down examples and prints the results.</summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
using DistanceFacetsExample example = new DistanceFacetsExample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public class ExpressionAggregationFacetsExample
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -116,6 +116,7 @@ public FacetResult RunSearch()
}

/// <summary>Runs the search and drill-down examples and prints the results.</summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
Console.WriteLine("Facet counting example:");
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net.Demo/Facet/MultiCategoryListsFacetsExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class MultiCategoryListsFacetsExample
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -135,6 +135,7 @@ public IList<FacetResult> RunSearch()
}

/// <summary>Runs the search example and prints the results.</summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
Console.WriteLine("Facet counting over multiple category lists example:");
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net.Demo/Facet/RangeFacetsExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public sealed class RangeFacetsExample : IDisposable
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -126,6 +126,7 @@ public void Dispose()
}

/// <summary>Runs the search and drill-down examples and prints the results.</summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
using RangeFacetsExample example = new RangeFacetsExample();
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net.Demo/Facet/SimpleFacetsExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class SimpleFacetsExample
/// <summary>
/// Using a constant for all functionality related to a specific index
/// is the best strategy. This allows you to upgrade Lucene.Net first
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// and plan the upgrade of the index binary format for a later time.
/// Once the index is upgraded, you simply need to update the constant
/// version and redeploy your application.
/// </summary>
private const LuceneVersion EXAMPLE_VERSION = LuceneVersion.LUCENE_48;
Expand Down Expand Up @@ -234,6 +234,7 @@ public IList<FacetResult> RunDrillSideways()
}

/// <summary>Runs the search and drill-down examples and prints the results.</summary>
/// <param name="args">The command line arguments</param>
public static void Main(string[] args)
{
Console.WriteLine("Facet counting example:");
Expand Down
Loading

0 comments on commit 1939665

Please sign in to comment.