24 public static void Main(System.String[] args)
32 System.Type stemClass = System.Type.GetType(
"SF.Snowball.Ext." + args[0] +
"Stemmer");
34 System.Reflection.MethodInfo stemMethod = stemClass.GetMethod(
"stem", (
new System.Type[0] == null)?
new System.Type[0]:(System.Type[])
new System.Type[0]);
36 System.IO.StreamReader reader;
37 reader =
new System.IO.StreamReader(
new System.IO.FileStream(args[1], System.IO.FileMode.Open, System.IO.FileAccess.Read), System.Text.Encoding.Default);
38 reader =
new System.IO.StreamReader(reader.BaseStream, reader.CurrentEncoding);
40 System.Text.StringBuilder input =
new System.Text.StringBuilder();
42 System.IO.Stream outstream = System.Console.OpenStandardOutput();
44 if (args.Length > 2 && args[2].Equals(
"-o"))
46 outstream =
new System.IO.FileStream(args[3], System.IO.FileMode.Create);
48 else if (args.Length > 2)
53 System.IO.StreamWriter output =
new System.IO.StreamWriter(outstream, System.Text.Encoding.Default);
54 output =
new System.IO.StreamWriter(output.BaseStream, output.Encoding);
59 repeat = System.Int32.Parse(args[4]);
62 System.Object[] emptyArgs =
new System.Object[0];
64 while ((character = reader.Read()) != - 1)
66 char ch = (char) character;
67 if (System.Char.IsWhiteSpace(ch))
72 for (
int i = repeat; i != 0; i--)
74 stemMethod.Invoke(stemmer, (System.Object[]) emptyArgs);
78 input.Remove(0, input.Length - 0);
83 input.Append(System.Char.ToLower(ch));
89 private static void ExitWithUsage()
91 System.Console.Error.WriteLine(
"Usage: TestApp <stemmer name> <input file> [-o <output file>]");
92 System.Environment.Exit(1);