Examples of ClasspathResourceLoader


Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

   
    PhoneticFilterFactory ff = new PhoneticFilterFactory();
   
    args.put( PhoneticFilterFactory.ENCODER, "Metaphone" );
    ff.init( args );
    ff.inform(new ClasspathResourceLoader(ff.getClass()));
    assertTrue( ff.getEncoder() instanceof Metaphone );
    assertTrue( ff.inject ); // default

    args.put( PhoneticFilterFactory.INJECT, "false" );
    ff.init( args );
    ff.inform(new ClasspathResourceLoader(ff.getClass()));
    assertFalse( ff.inject );

    args.put( PhoneticFilterFactory.MAX_CODE_LENGTH, "2");
    ff.init(args);
    ff.inform(new ClasspathResourceLoader(ff.getClass()));
    assertEquals(2, ((Metaphone) ff.getEncoder()).getMaxCodeLen());
  }
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

   */
  public void testFactoryCaseFailure() throws IOException {
    Map<String,String> args = new HashMap<String, String>();
   
    PhoneticFilterFactory ff = new PhoneticFilterFactory();
    ClasspathResourceLoader loader = new ClasspathResourceLoader(ff.getClass());

    try {
      ff.init( args );
      ff.inform( loader );
      fail( "missing encoder parameter" );
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

   */
  public void testFactoryCaseReflection() throws IOException {
    Map<String,String> args = new HashMap<String, String>();
   
    PhoneticFilterFactory ff = new PhoneticFilterFactory();
    ClasspathResourceLoader loader = new ClasspathResourceLoader(ff.getClass());

    args.put( PhoneticFilterFactory.ENCODER, "org.apache.commons.codec.language.Metaphone" );
    ff.init( args );
    ff.inform( loader );
    assertTrue( ff.getEncoder() instanceof Metaphone );
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

    Map<String,String> args = new HashMap<String,String>();
    args.put("encoder", algName);
    args.put("inject", inject);
    PhoneticFilterFactory factory = new PhoneticFilterFactory();
    factory.init(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    TokenStream stream = factory.create(tokenizer);
    assertTokenStreamContents(stream, expected);
  }
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

*
**/
public class TestStopFilterFactory extends BaseTokenStreamTestCase {

  public void testInform() throws Exception {
    ResourceLoader loader = new ClasspathResourceLoader(getClass());
    assertTrue("loader is null and it shouldn't be", loader != null);
    StopFilterFactory factory = new StopFilterFactory();
    Map<String, String> args = new HashMap<String, String>();
    args.put("words", "stop-1.txt");
    args.put("ignoreCase", "true");
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

*/
public class TestTypeTokenFilterFactory extends BaseTokenStreamTestCase {

  @Test
  public void testInform() throws Exception {
    ResourceLoader loader = new ClasspathResourceLoader(getClass());
    TypeTokenFilterFactory factory = new TypeTokenFilterFactory();
    Map<String, String> args = new HashMap<String, String>();
    args.put("types", "stoptypes-1.txt");
    args.put("enablePositionIncrements", "true");
    factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

      TypeTokenFilterFactory typeTokenFilterFactory = new TypeTokenFilterFactory();
      Map<String, String> args = new HashMap<String, String>();
      args.put("enablePositionIncrements", "false");
      typeTokenFilterFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
      typeTokenFilterFactory.init(args);
      typeTokenFilterFactory.inform(new ClasspathResourceLoader(getClass()));
      fail("not supplying 'types' parameter should cause an IllegalArgumentException");
    } catch (IllegalArgumentException e) {
      // everything ok
    }
  }
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

   */
  public void testDecompounding() throws Exception {
    Reader reader = new StringReader("I like to play softball");
    Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
    DictionaryCompoundWordTokenFilterFactory factory = new DictionaryCompoundWordTokenFilterFactory();
    ResourceLoader loader = new ClasspathResourceLoader(getClass());
    Map<String,String> args = new HashMap<String,String>();
    args.put("dictionary", "compoundDictionary.txt");
    factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
    factory.init(args);
    factory.inform(loader);
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

    SynonymFilterFactory factory = new SynonymFilterFactory();
    Map<String,String> args = new HashMap<String,String>();
    args.put("synonyms", "synonyms.txt");
    factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
    factory.init(args);
    factory.inform(new ClasspathResourceLoader(getClass()));
    TokenStream ts = factory.create(new MockTokenizer(new StringReader("GB"), MockTokenizer.WHITESPACE, false));
    assertTrue(ts instanceof SynonymFilter);
    assertTokenStreamContents(ts,
        new String[] { "GB", "gib", "gigabyte", "gigabytes" },
        new int[] { 1, 0, 0, 0 });
View Full Code Here

Examples of org.apache.lucene.analysis.util.ClasspathResourceLoader

    SynonymFilterFactory factory = new SynonymFilterFactory();
    Map<String,String> args = new HashMap<String,String>();
    args.put("synonyms", "synonyms.txt");
    factory.setLuceneMatchVersion(Version.LUCENE_33);
    factory.init(args);
    factory.inform(new ClasspathResourceLoader(getClass()));
    TokenStream ts = factory.create(new MockTokenizer(new StringReader("GB"), MockTokenizer.WHITESPACE, false));
    assertTrue(ts instanceof SlowSynonymFilter);
    assertTokenStreamContents(ts,
        new String[] { "GB", "gib", "gigabyte", "gigabytes" },
        new int[] { 1, 0, 0, 0 });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.