DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Testing Polish Language Analysis Solr 4.0

Rafał Kuć user avatar by
Rafał Kuć
·
Apr. 05, 12 · Interview
Like (0)
Save
Tweet
Share
7.76K Views

Join the DZone community and get the full member experience.

Join For Free

Because Polish language analysis functionality has been present in Lucene (and Solr) for some time I decided to take a look and compare it on the basis of upcoming Lucene and Solr 4.0.

Options

At the time of writing, the following options were present when it comes to analyzing Polish:

  • Use Stempel library (available since Solr 3.1)
  • Use Hunspell and Polish dictionaries (available since Solr 3.5)
  • Use Morfologik library (will be available in Solr 4.0, SOLR-3272).

Configuration

Lets look at how to configure all the above options in Solr (please remember that all the following configuration examples are based on Solr 4.0).

Stempel

In order to add Polish stemming using the Stempel library, we just need to add the following filter to our type definition
<filter class="solr.StempelPolishStemFilterFactory" />

In addition to that, you need to add lucene-analyzers-stempel-4.0.jar library and apache-solr-analysis-extras-4.0.jar library to SOLR_HOME/lib. It’s also a good idea to use solr.LowerCaseFilterFactory before the Stempel filter.

Hunspell

Similar to the configuration above, to use Hunspell you need to add a new filter to your type definition. For example in the following way:

<filter class="solr.HunspellStemFilterFactory" dictionary="pl_PL.dic" affix="pl_PL.aff" ignoreCase="true" />

Parameters dictionary and affix are responsible for dictionary definition that we want to use. The ignoreCase parameter set to true tells Hunspell to ignore character case. You can find Hunspell dictionaries at the following URL: http://wiki.services.openoffice.org/wiki/Dictionaries.

Morfologik

Similar to the two above examples all you need to change in your schema.xml is adding a new filter, this time the following way:

<filter class="solr.MorfologikFilterFactory" dictionary="MORFOLOGIK" />

The dictionary parameter tell Solr which dictionary you would like to use. You can choose the one from the following three:

  • MORFOLOGIK
  • MORFEUSZ
  • COMBINED

In addition to that, you need to add the following libraries to the SOLR_HOME/lib: lucene-analyzers-morfologik-4.0.jar, apache-solr-analysis-extras-4.0.jar, morfologik-fsa-1.5.2.jar, morfologik-polish-1.5.2.jar and morfologik-stemming-1.5.2.jar.

Results Comparison

Of course I wasn’t able to judge the results of analysis from the above three filters on the whole Polish language corpus and that’s why I decided to choose four work, to see the each of the filters behave. Those words are: “urodzić urodzony urodzona urodzeni” (this words are variations of the born word in Polish). The results are as follows:

Stempel

The terms I got from Stempel were the following ones:

[urodzić] [urodzo] [urodzona] [urodzeni]

Not all of them are words, but you have to remember that Stempel is a stemmer and because of that it produce stems which can be different from the actual words or their root forms. It is important to have the words we are interested in to be processed to the same tokens, which will allow to find those words by Lucene/Solr. Remembering that, I have to say, that the results of analysis using Stempel are not as good as I would like them to be. For example by searching for urodzić word you won’t be able to find documents with words like urodzona or urodzić.

Hunspell

The result of Hunspell analysis were as follows:

[urodzić, urodzić] [urodzony, urodzić] [urodzić] [urodzić, urodzony, urodzenie]

Comparing the results I got when using Hunspell to those Stempel produced we can see the difference. Our sample query for the urodzić word, would find documents with words like urodzony, urodzona oraz urodzeni, which is quite nice. You can also notice, that with three words we got more than one term on the same positions. The results I got when using Hunspell are OK and I think they should satisfy most of the users (they do satisfy me), but lets have a look on the newly introduced filter in Lucene and Solr – Morrfologik.

Morfologik

The results of Morfologik analysis were as follows:

[urodzić] [urodzony, urodzić] [urodzić] [urodzić, urodzony]

Again, if you compare those the the ones got when using Hunspell you can hardly see the difference (of course in this particular case). The only difference between Hunspell and Morfologik is the last term for which we got different results. In my opinion the results achieved with Morfologik, are satisfying.

Performance

The performance test was done in a simple manner – for each filter I’ve indexed 5 million documents, where all the text fields were based on Polish language analysis with appropriate filter (in addition to that some standard filters like stopwords, synonyms and so on). Every time the indexation was done on a clean Solr 4.0 instance. Because of using Data Import Handler I’ve sent commit every 100k documents. The index contained several fields, but the actual index structure was not crucial for the test as I indexed the same set of documents every time. Following are the test results:

FilterStempelHunspellMorfologik
Indexing time99 minutes> 10 hours100 minutes

Warning: At the time of writing, according to  SOLR-3245 JIRA issue there is a problem with Hunspell performance with Polish dictionaries and Solr 4.0. I’m almost certain that this situation will be resolved by the time Solr 4.0 will be released. But right now performance of Hunspell with Polish dictionaries and Solr 4.0 may not be sufficient.

Short Summary

Despite not having performance results for Hunspell (because I don’t count the ones I have right now as correct ones) we can see that Hunspell and Morfologik are good candidates for Polish language analysis. Looking at Morfologik we have similar performance to Stempel, but Morfologik results are better in my opinion and that will make your user more happy.

Filter (software) Dictionary (software)

Published at DZone with permission of Rafał Kuć, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Keep Your Application Secrets Secret
  • AWS CodeCommit and GitKraken Basics: Essential Skills for Every Developer
  • Getting a Private SSL Certificate Free of Cost
  • The Beauty of Java Optional and Either

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: