/// <summary>
/// Entry point to the DiffIt application.
/// <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>
/// </summary>
/// <param name="args">the path to a file containing a stemmer table</param>
public static void Main(string[] args)
{
int ins = Get(0, args[0]);
int del = Get(1, args[0]);
int rep = Get(2, args[0]);
int nop = Get(3, args[0]);
// LUCENENET specific - reformatted with :
string charset = SystemProperties.GetProperty("egothor:stemmer:charset", "UTF-8");
var stemmerTables = new List <string>();
// LUCENENET specific
// command line argument overrides environment variable or default, if supplied
for (int i = 1; i < args.Length; i++)
{
if ("-e".Equals(args[i], StringComparison.Ordinal) || "--encoding".Equals(args[i], StringComparison.Ordinal))
{
charset = args[i];
}
else
{
stemmerTables.Add(args[i]);
}
}
foreach (var stemmerTable in stemmerTables)
{
// System.out.println("[" + args[i] + "]");
Diff diff = new Diff(ins, del, rep, nop);
using (TextReader input = new StreamReader(new FileStream(stemmerTable, FileMode.Open, FileAccess.Read), Encoding.GetEncoding(charset)))
{
string line;
while ((line = input.ReadLine()) != null)
{
try
{
line = line.ToLowerInvariant();
StringTokenizer st = new StringTokenizer(line);
st.MoveNext();
string stem = st.Current;
Console.WriteLine(stem + " -a");
while (st.MoveNext())
{
string token = st.Current;
if (token.Equals(stem, StringComparison.Ordinal) == false)
{
Console.WriteLine(stem + " " + diff.Exec(token, stem));
}
}
}
catch (InvalidOperationException /*x*/)
{
// no base token (stem) on a line
}
}
}
}
}