X-Git-Url: https://git.mdrn.pl/pylucene.git/blobdiff_plain/a2e61f0c04805cfcb8706176758d1283c7e3a55c..aaeed5504b982cf3545252ab528713250aa33eed:/lucene-java-3.4.0/lucene/contrib/analyzers/common/src/java/org/tartarus/snowball/TestApp.java?ds=sidebyside diff --git a/lucene-java-3.4.0/lucene/contrib/analyzers/common/src/java/org/tartarus/snowball/TestApp.java b/lucene-java-3.4.0/lucene/contrib/analyzers/common/src/java/org/tartarus/snowball/TestApp.java deleted file mode 100644 index 3da6f8c..0000000 --- a/lucene-java-3.4.0/lucene/contrib/analyzers/common/src/java/org/tartarus/snowball/TestApp.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - -Copyright (c) 2001, Dr Martin Porter -Copyright (c) 2002, Richard Boulton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the copyright holders nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - */ - -package org.tartarus.snowball; - -import java.lang.reflect.Method; -import java.io.Reader; -import java.io.Writer; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.OutputStream; -import java.io.FileOutputStream; - -public class TestApp { - private static void usage() - { - System.err.println("Usage: TestApp [-o ]"); - } - - public static void main(String [] args) throws Throwable { - if (args.length < 2) { - usage(); - return; - } - - Class stemClass = Class.forName("org.tartarus.snowball.ext." + - args[0] + "Stemmer").asSubclass(SnowballProgram.class); - SnowballProgram stemmer = stemClass.newInstance(); - Method stemMethod = stemClass.getMethod("stem", new Class[0]); - - Reader reader; - reader = new InputStreamReader(new FileInputStream(args[1])); - reader = new BufferedReader(reader); - - StringBuffer input = new StringBuffer(); - - OutputStream outstream; - - if (args.length > 2) { - if (args.length == 4 && args[2].equals("-o")) { - outstream = new FileOutputStream(args[3]); - } else { - usage(); - return; - } - } else { - outstream = System.out; - } - Writer output = new OutputStreamWriter(outstream); - output = new BufferedWriter(output); - - int repeat = 1; - if (args.length > 4) { - repeat = Integer.parseInt(args[4]); - } - - Object [] emptyArgs = new Object[0]; - int character; - while ((character = reader.read()) != -1) { - char ch = (char) character; - if (Character.isWhitespace(ch)) { - if (input.length() > 0) { - stemmer.setCurrent(input.toString()); - for (int i = repeat; i != 0; i--) { - stemMethod.invoke(stemmer, emptyArgs); - } - output.write(stemmer.getCurrent()); - output.write('\n'); - input.delete(0, input.length()); - } - } else { - input.append(Character.toLowerCase(ch)); - } - } - output.flush(); - } -}