You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by rm...@apache.org on 2010/01/16 23:28:13 UTC
svn commit: r900031 - in
/lucene/java/trunk/src/test/org/apache/lucene/analysis:
TestPorterStemFilter.java porterTestData.zip
Author: rmuir
Date: Sat Jan 16 22:28:13 2010
New Revision: 900031
URL: http://svn.apache.org/viewvc?rev=900031&view=rev
Log:
LUCENE-2212: add test for PorterStemFilter
Added:
lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java (with props)
lucene/java/trunk/src/test/org/apache/lucene/analysis/porterTestData.zip (with props)
Added: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java?rev=900031&view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java Sat Jan 16 22:28:13 2010
@@ -0,0 +1,59 @@
+package org.apache.lucene.analysis;
+
+/**
+ * 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.zip.ZipFile;
+
+/**
+ * Test the PorterStemFilter with Martin Porter's test data.
+ */
+public class TestPorterStemFilter extends BaseTokenStreamTestCase {
+ /**
+ * Run the stemmer against all strings in voc.txt
+ * The output should be the same as the string in output.txt
+ */
+ public void testPorterStemFilter() throws IOException {
+ Tokenizer tokenizer = new KeywordTokenizer(new StringReader(""));
+ TokenStream filter = new PorterStemFilter(tokenizer);
+ ZipFile zipFile = new ZipFile(
+ new File(getClass().getResource("porterTestData.zip").getFile()));
+ InputStream voc = zipFile.getInputStream(zipFile.getEntry("voc.txt"));
+ InputStream out = zipFile.getInputStream(zipFile.getEntry("output.txt"));
+ BufferedReader vocReader = new BufferedReader(new InputStreamReader(
+ voc, "UTF-8"));
+ BufferedReader outputReader = new BufferedReader(new InputStreamReader(
+ out, "UTF-8"));
+ String inputWord = null;
+ while ((inputWord = vocReader.readLine()) != null) {
+ String expectedWord = outputReader.readLine();
+ assertNotNull(expectedWord);
+ tokenizer.reset(new StringReader(inputWord));
+ filter.reset();
+ assertTokenStreamContents(filter, new String[] { expectedWord });
+ }
+ vocReader.close();
+ outputReader.close();
+ zipFile.close();
+ }
+}
Propchange: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/src/test/org/apache/lucene/analysis/porterTestData.zip
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/porterTestData.zip?rev=900031&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lucene/java/trunk/src/test/org/apache/lucene/analysis/porterTestData.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream