Hi Chris,
Thanks for the reply.
I am sure I have lucene-analyzers-common.jar added to my eclipse project.
However, I have figured out a way to run it. I am not sure whether this is a
bug or undocumented workflow for Snowball filters.
Map<String,String> args = new HashMap<>();
TokenStream tokenStream = new StandardTokenizer(Version.LUCENE_46, new
StringReader("Some text"));
args.put("luceneMatchVersion", "4.6");
args.put("language", "Catalan");
SnowballPorterFilterFactory factory = new SnowballPorterFilterFactory(args);
*factory.inform(new ClasspathResourceLoader());*
TokenFilter filter = factory.create(tokenStream);
As you can see, the key here is calling the *inform* method of the
SnowballProterFilterFactory to add the respected language stemmer's class.
This is actually the task of the *inform* method. The standard constructor
of this class does not call this method as you can see below:
/** Creates a new SnowballPorterFilterFactory */
public SnowballPorterFilterFactory(Map<String,String> args) {
super(args);
language = get(args, "language", "English");
wordFiles = get(args, PROTECTED_TOKENS);
if (!args.isEmpty()) {
throw new IllegalArgumentException("Unknown parameters: " + args);
}
}
@Override
public void inform(ResourceLoader loader) throws IOException {
String className = "org.tartarus.snowball.ext." + language + "Stemmer";
stemClass = loader.newInstance(className,
SnowballProgram.class).getClass();
if (wordFiles != null) {
protectedWords = getWordSet(loader, wordFiles, false);
}
}
looking forward for your feedback.
--
View this message in context:
http://lucene.472066.n3.nabble.com/Snowball-filter-Error-instantiating-stemmer-for-a-language-tp4156882p4157057.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]