lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r817643 - /lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
Date Tue, 22 Sep 2009 13:02:39 GMT
Author: shalin
Date: Tue Sep 22 13:02:39 2009
New Revision: 817643

URL: http://svn.apache.org/viewvc?rev=817643&view=rev
Log:
Added test for multi word synonyms

Added:
    lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java   (with
props)

Added: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java?rev=817643&view=auto
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java (added)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java Tue Sep
22 13:02:39 2009
@@ -0,0 +1,37 @@
+package org.apache.solr.analysis;
+
+import org.apache.lucene.analysis.WhitespaceTokenizer;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @version $Id$
+ * @since solr 1.4
+ */
+public class TestMultiWordSynonyms {
+
+  @Test
+  public void testMultiWordSynonmys() throws IOException {
+    List<String> rules = new ArrayList<String>();
+    rules.add("a b c,d");
+    SynonymMap synMap = new SynonymMap(true);
+    SynonymFilterFactory.parseRules(rules, synMap, "=>", ",", true, null);
+
+    SynonymFilter ts = new SynonymFilter(new WhitespaceTokenizer(new StringReader("a e")),
synMap);
+    TermAttribute termAtt = (TermAttribute) ts.getAttribute(TermAttribute.class);
+
+    ts.reset();
+    List<String> tokens = new ArrayList<String>();
+    while (ts.incrementToken()) tokens.add(termAtt.term());
+
+    // This fails because ["e","e"] is the value of the token stream
+    Assert.assertEquals(Arrays.asList("a", "e"), tokens);
+  }
+}

Propchange: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message