Giter Club home page Giter Club logo

germalemma's Introduction

GermaLemma

April/Mai 2017, Markus Konrad [email protected] / Berlin Social Science Center

A Lemmatizer for German language text

In order to use GermaLemma, you will need to install some additional packages (see Requirements section below) and then download the TIGER corpus from the University of Stuttgart. You will need to use the CONLL09 format, not the XML format. The corpus is free to use for non-commercial purposes (see License Agreement).

Then, you should convert the corpus into pickle format for faster loading by executing germalemma.py and passing the path to the corpus file in CONLL09 format:

python germalemma.py tiger_release_[...].conll09

This will place a lemmata.pickle file in the "data" directory which is then automatically loaded.

Part-of-Speech (POS) Tagging

You will need to apply Part-of-Speech (POS) tagging to your text before you can lemmatize its words. See this blog post on how to do that.

Usage

You have set up GermaLemma to use the TIGER corpus (as explained above). You have tokenized your text (e.g. with NLTK). You have POS-tagged your tokens. Now you can use GermaLemma:

from germalemma import GermaLemma

lemmatizer = GermaLemma()

# passing the word and the POS tag ("N" for noun)
lemma = lemmatizer.find_lemma(u'Feinstaubbelastungen', u'N')
print(lemma)
# -> lemma is "Feinstaubbelastung"

Valid POS tags

You can pass POS tags from the STTS tagset, however, only four POS tags can be processed:

  • 'N...' (nouns)
  • 'V...' (verbs)
  • 'ADJ...' (adjectives)
  • 'ADV...' (adverbs)

All other POS tags will result in a ValueError so you should wrap the call to find_lemma in a try-except block.

Accuracy

Using 90% of the TIGER corpus as lemmata dictionary and the remaining 10% as test data, GermaLemma finds out the correct lemma for about ~84% of all nouns, verbs, adjectives and adverbs, when the Pattern package is installed. Without Pattern, about 71% accuracy can be achieved. Run evaluate_germalemma.py to see the exact results and see this blog post for more information.

Requirements

  • Python 2.7 or Python 3.x
  • required package Pyphen
  • optional package Pattern (This package is only available for Python 2.x but improves the accuracy from ~71% to ~84%)

License

Apache License 2.0. See LICENSE file.

The TIGER corpus is not part of this repository and has to be downloaded separately under separate license conditions.

germalemma's People

Contributors

internaut avatar

Watchers

James Cloos avatar Frederik 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.