GithubHelp home page GithubHelp logo

oleg-st / russianmorphology Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akuznetsov/russianmorphology

0.0 1.0 0.0 10.12 MB

Russian Morphology for Lucene

License: Apache License 2.0

Java 100.00%

russianmorphology's Introduction

Russian Morphology for Apache Lucene

Russian and English morphology for Java and Apache Lucene 7.2 framework based on open source dictionary from site АОТ. It uses dictionary base morphology with some heuristics for unknown words. It supports homonym for example for Russian word "вина" it gives two variants "вино" and "вина".

How to use

Build project, by running mvn clean package, this will provide you the latest versions of the artifacts - 1.7, add it to your classpath. You could select which version to use - Russian or English.

Now you can create a Lucene Analyzer:

  RussianAnalayzer russian = new RussianAnalayzer();
  EnglishAnalayzer english = new EnglishAnalayzer();

You can write you own analyzer using filter that convert word in its right forms.

  LuceneMorphology luceneMorph = new EnglishLuceneMorphology();
  TokenStream tokenStream = new MorphlogyFilter(result, luceneMorph);

Because usually LuceneMorphology contains a lot of data needing for its functionality, it is better didn't create this object for each MorphologyFilter.

Also, if you need get a list of base forms of word, you can use following example

 LuceneMorphology luceneMorph = new EnglishLuceneMorphology();
 List<String> wordBaseForms = luceneMorph.getMorphInfo(word);

Solr

You can use the LuceneMorphology as morphology filter in a Solr schema.xml using a MorphologyFilterFactory:

<fieldType name="content" class="solr.TextField" positionIncrementGap="100">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
		<filter class="org.apache.lucene.analysis.morphology.MorphologyFilterFactory" language="Russian"/>
		<filter class="org.apache.lucene.analysis.morphology.MorphologyFilterFactory" language="English"/>
      </analyzer>
</fieldType>

Just add morphology-1.7.jar in your Solr lib-directories

Restrictions

  • It works only with UTF-8.
  • It assumes what letters е and ё are the same.
  • Word forms with prefixes like "наибольший" treated as separate word.

License

Apache License, Version 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.