Search code examples
lucenefull-text-searchpylucenesnowballanalyzer

Using SnowBallAnalyzer with PyLucene


I'm trying to use SnowBallAnalyzer in PyLucene but I always get an error saying: InvalidArgsError when I try to create an instance of it like this:

analyzer = SnowBallAnalyzer("Spanish")

or

analyzer = SnowBallAnalyzer("Spanish", STOPWORDS)

What I really need is i.e if I search for "Fútbol", I should obtain the documents that have the word "futbol" or "fútbol". So... I would like to apply SnowBallAnalyzer to the text I would like to index an to the query.

Any help will be appreciated.

Thanks in advance.


Solution

  • I don't know pylucene very well as I only work with the java version but as far as I know pylucene is accessing the java implementation.

    If this is the case you are missing the Version parameter in the constructor.

    SnowballAnalyzer(Version matchVersion, String name, String[] stopWords)
    

    As SnowballAnalyzer has been deprecated in lucene 3.1.0, I suggest you directly use the spanish analyzer.

    SpanishAnalyzer(Version matchVersion, Set<?> stopwords)