Index: src/java/org/tartarus/snowball/TestApp.java =================================================================== --- src/java/org/tartarus/snowball/TestApp.java (revision 823069) +++ src/java/org/tartarus/snowball/TestApp.java (arbetskopia) @@ -1,22 +1,36 @@ -package org.tartarus.snowball; +/* -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +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; Index: src/java/org/tartarus/snowball/ext/DanishStemmer.java =================================================================== --- src/java/org/tartarus/snowball/ext/DanishStemmer.java (revision 823069) +++ src/java/org/tartarus/snowball/ext/DanishStemmer.java (arbetskopia) @@ -65,7 +65,7 @@ private int I_x; private int I_p1; - private StringBuffer S_ch = new StringBuffer(); + private StringBuilder S_ch = new StringBuilder(); private void copy_from(DanishStemmer other) { I_x = other.I_x; Index: src/java/org/tartarus/snowball/ext/KpStemmer.java =================================================================== --- src/java/org/tartarus/snowball/ext/KpStemmer.java (revision 823069) +++ src/java/org/tartarus/snowball/ext/KpStemmer.java (arbetskopia) @@ -125,7 +125,7 @@ private int I_p2; private int I_p1; private int I_x; - private StringBuffer S_ch = new StringBuffer(); + private StringBuilder S_ch = new StringBuilder(); private void copy_from(KpStemmer other) { B_GE_removed = other.B_GE_removed; Index: src/java/org/tartarus/snowball/ext/FinnishStemmer.java =================================================================== --- src/java/org/tartarus/snowball/ext/FinnishStemmer.java (revision 823069) +++ src/java/org/tartarus/snowball/ext/FinnishStemmer.java (arbetskopia) @@ -136,7 +136,7 @@ private static final char g_particle_end[] = {17, 97, 24, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 32 }; private boolean B_ending_removed; - private StringBuffer S_x = new StringBuffer(); + private StringBuilder S_x = new StringBuilder(); private int I_p2; private int I_p1; Index: src/java/org/tartarus/snowball/Among.java =================================================================== --- src/java/org/tartarus/snowball/Among.java (revision 823069) +++ src/java/org/tartarus/snowball/Among.java (arbetskopia) @@ -1,22 +1,36 @@ -package org.tartarus.snowball; +/* -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +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; public class Among { Index: src/java/org/tartarus/snowball/SnowballProgram.java =================================================================== --- src/java/org/tartarus/snowball/SnowballProgram.java (revision 823069) +++ src/java/org/tartarus/snowball/SnowballProgram.java (arbetskopia) @@ -1,34 +1,49 @@ -package org.tartarus.snowball; +/* -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +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.InvocationTargetException; /** * This is the rev 500 of the Snowball SVN trunk, * but modified: - * made abstract and introduced abstract method stem - * to avoid expensive + * made abstract and introduced abstract method stem to avoid expensive reflection in filter class. + * refactored StringBuffers to StringBuilder */ public abstract class SnowballProgram { protected SnowballProgram() { - current = new StringBuffer(); + current = new StringBuilder(); setCurrent(""); } @@ -59,12 +74,12 @@ // the buffer size will not decrease, and we will risk wasting a large // amount of memory. // Thanks to Wolfram Esser for spotting this problem. - current = new StringBuffer(); + current = new StringBuilder(); return result; } // current string - protected StringBuffer current; + protected StringBuilder current; protected int cursor; protected int limit; @@ -194,12 +209,12 @@ return true; } - protected boolean eq_v(StringBuffer s) + protected boolean eq_v(StringBuilder s) { return eq_s(s.length(), s.toString()); } - protected boolean eq_v_b(StringBuffer s) + protected boolean eq_v_b(StringBuilder s) { return eq_s_b(s.length(), s.toString()); } @@ -380,7 +395,7 @@ replace_s(bra, ket, s); } - protected void slice_from(StringBuffer s) + protected void slice_from(StringBuilder s) { slice_from(s.toString()); } @@ -397,13 +412,13 @@ if (c_bra <= ket) ket += adjustment; } - protected void insert(int c_bra, int c_ket, StringBuffer s) + protected void insert(int c_bra, int c_ket, StringBuilder s) { insert(c_bra, c_ket, s.toString()); } /* Copy the slice into the supplied StringBuffer */ - protected StringBuffer slice_to(StringBuffer s) + protected StringBuilder slice_to(StringBuilder s) { slice_check(); int len = ket - bra; @@ -411,7 +426,7 @@ return s; } - protected StringBuffer assign_to(StringBuffer s) + protected StringBuilder assign_to(StringBuilder s) { s.replace(0, s.length(), current.substring(0, limit)); return s; Index: src/java/overview.html =================================================================== --- src/java/overview.html (revision 823069) +++ src/java/overview.html (arbetskopia) @@ -26,6 +26,14 @@ together with classes integrating them with the Lucene search engine.

+A few changes has been made to the static Snowball code and compiled stemmers: +

+ +

See the Snowball home page for more information about the algorithms.

Index: README.txt =================================================================== --- README.txt (revision 823069) +++ README.txt (arbetskopia) @@ -4,7 +4,13 @@ based on revision 500 of the Tartarus Snowball repository, together with classes integrating them with the Lucene search engine. +A few changes has been made to the static Snowball code and compiled stemmers: + * Class SnowballProgram is made abstract and contains new abstract method stem() to avoid reflection in Lucene filter class SnowballFilter. + * All use of StringBuffers has been refactored to StringBuilder for speed. + * Snowball BSD license header has been added to the Java classes to avoid having RAT adding new ASL headers. + + IMPORTANT NOTICE ON BACKWARDS COMPATIBILITY! An index created using the Snowball module in Lucene 2.3.2 and below