GithubHelp home page GithubHelp logo

rpdcoetic / lemma Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiamx/lemma

0.0 1.0 0.0 367 KB

A Morphological Parser (Analyser) / Lemmatizer written in Elixir.

License: Apache License 2.0

Elixir 100.00%

lemma's Introduction

Lemma

Build Status Hex.pm license

A Morphological Parser (Analyser) / Lemmatizer written in Elixir. It is implemented using a textbook classic method relying in an abstraction called Finite State Transducer.

What are morphological parsing and lemmatization?

For grammatical reasons, documents are going to use different forms of a word, such as organize, organizes, and organizing. Additionally, there are families of derivationally related words with similar meanings, such as democracy, democratic, and democratization. In many situations, it seems as if it would be useful for a search for one of these words to return documents that contain another word in the set.
The goal of both stemming and lemmatization is to reduce inflectional forms and sometimes derivationally related forms of a word to a common base form. For instance:

am, are, is ⇒ be
car, cars, car's, cars' ⇒ car

The result of this mapping of text will be something like:
the boy's cars are different colors ⇒ the boy car be differ color.
-- Stanford NLP Group

Not for production use, this library is neither cpu nor memory efficient

Example Usage

# Initialize a new morphological parser for English
parser = Lemma.new :en
assert {:ok, "play"} == parser |> Lemma.parse("plays")

Documentation can be found at https://hexdocs.pm/lemma.

Installation

If available in Hex, the package can be installed by adding lemma to your list of dependencies in mix.exs:

def deps do
  [{:lemma, "~> 0.1.0"}]
end

Benchmarking

Lemmatize a paragraph of words

A simple benchmarking script is provided to test the performance of performing lemmatization on a paragraph of words. The script can be invoked with mix run benchmarks/lemmatizing.exs

Sample output

Benchmark using 430 fixture words
Operating System: Windows
CPU Information: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Number of Available Cores: 4
Available memory: 12.753915904 GB
Elixir 1.5.0
Erlang 19.2
Benchmark suite executing with the following configuration:
warmup: 2.00 s
time: 5.00 s
parallel: 1
inputs: none specified
Estimated total run time: 7.00 s


Benchmarking Lemmatize input sequential...

Name                                 ips        average  deviation         median
Lemmatize input sequential          4.31      232.14 ms    68.17%      110.00 ms

Compile-time vs Runtime parser

To evaluate the difference between building the parser at compile time vs. building the parser at runtime, we have another benchmarking script. The script can be invoked with mix run benchmarks/runtime_vs_compiletime.exs

Sample output

Operating System: Windows
CPU Information: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Number of Available Cores: 4
Available memory: 12.753915904 GB
Elixir 1.5.0
Erlang 19.2
Benchmark suite executing with the following configuration:
warmup: 2.00 s
time: 5.00 s
parallel: 1
inputs: none specified
Estimated total run time: 14.00 s


Benchmarking Compiled parser...
Benchmarking Dynamic parser...

Name                      ips        average  deviation         median
Compiled parser       15.91 K       62.86 us   123.32%         0.0 us
Dynamic parser         3.80 K      262.91 us   118.03%      160.00 us

Comparison:
Compiled parser       15.91 K
Dynamic parser         3.80 K - 4.18x slower

lemma's People

Contributors

janpieper avatar xiamx avatar

Watchers

 avatar

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.