mirror of https://github.com/apache/lucene.git
SOLR-1938: make ElisionFilterFactory user-friendly
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@951126 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ff01172f46
commit
f7673b59f1
|
@ -410,6 +410,9 @@ Other Changes
|
|||
option. It has never worked very well, and in recent versions of
|
||||
Solr hasn't worked at all. (hossman)
|
||||
|
||||
* SOLR-1938: ElisionFilterFactory will use a default set of French contractions
|
||||
if you do not supply a custom articles file. (rmuir)
|
||||
|
||||
* SOLR-1889: The default logic for the 'mm' param of DismaxQParser and
|
||||
ExtendedDismaxQParser has been changed to be determined based on the
|
||||
effective value of the 'q.op' param (hossman)
|
||||
|
|
|
@ -41,14 +41,13 @@ public class ElisionFilterFactory extends BaseTokenFilterFactory implements Reso
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("No articles specified for ElisionFilterFactory");
|
||||
}
|
||||
}
|
||||
|
||||
public ElisionFilter create(TokenStream input) {
|
||||
assureMatchVersion();
|
||||
return new ElisionFilter(luceneMatchVersion,input,articles);
|
||||
return articles == null ? new ElisionFilter(luceneMatchVersion,input) :
|
||||
new ElisionFilter(luceneMatchVersion,input,articles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,4 +49,19 @@ public class TestElisionFilterFactory extends BaseTokenTestCase {
|
|||
assertTokenStreamContents(stream, new String[] { "avion" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating an elision filter without specifying any articles
|
||||
*/
|
||||
public void testDefaultArticles() throws Exception {
|
||||
Reader reader = new StringReader("l'avion");
|
||||
Tokenizer tokenizer = new WhitespaceTokenizer(DEFAULT_VERSION, reader);
|
||||
ElisionFilterFactory factory = new ElisionFilterFactory();
|
||||
factory.init(DEFAULT_VERSION_PARAM);
|
||||
ResourceLoader loader = new SolrResourceLoader(null, null);
|
||||
factory.init(new HashMap<String,String>());
|
||||
factory.inform(loader);
|
||||
TokenStream stream = factory.create(tokenizer);
|
||||
assertTokenStreamContents(stream, new String[] { "avion" });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue