Giter Club home page Giter Club logo

iwnlp-py's Introduction

IWNLP-py

license Build Status

IWNLP-py is a Python port of IWNLP.Lemmatizer. IWNLP-py offers a lemmatization of German words based on the German Wiktionary which is processed by IWNLP.

How to setup IWNLP-py

  1. Use pip to install iwnlp
pip install iwnlp
  1. Download the latest processed IWNLP dump from https://dbs.cs.uni-duesseldorf.de/datasets/iwnlp/IWNLP.Lemmatizer_20181001.zip and unzip it.

How to use IWNLP-py

The Python package consists of the IWNLPWrapper class. Keep in mind that the lemmatizer will return None for unknown words rather than guessing a lemma. If more than one lemma is found, all lemmas are returned. In order to lemmatize single words, you can choose between two functions:

  1. lemmatize: If you have access to POS tags of your words, you should use this function. The POS tagset is Google's universal POS tagset. The lemmatization performance is tuned to be as high as possible, as listed here. Our paper describes our approach in more detail. Keep in mind, that our results have improved a lot over the last two years.
def lemmatize(self, word, pos_universal_google)

Usage:

from iwnlp.iwnlp_wrapper import IWNLPWrapper
lemmatizer = IWNLPWrapper(lemmatizer_path='data/IWNLP.Lemmatizer_20181001.json')
lemmatizer.lemmatize('Lkws', pos_universal_google='NOUN')
# ['Lkw']
lemmatizer.lemmatize('Onlineauftritten', pos_universal_google='NOUN')
# ['Onlineauftritt']
lemmatizer.lemmatize('gespielt', pos_universal_google='VERB')
# ['spielen']
  1. lemmatize: If you don't have access to POS tags or don't want to use them you can simply pass the word without any POS tag and retrieve any lemma that is present in IWNLP. You may also specify if you want the lookup to be case sensitive, which it is by default.
def lemmatize_plain(self, word, ignore_case=False):

Usage:

from iwnlp.iwnlp_wrapper import IWNLPWrapper
lemmatizer = IWNLPWrapper(lemmatizer_path='data/IWNLP.Lemmatizer_20181001.json')
lemmatizer.lemmatize_plain('birne')
# no result since the noun is lowercased
lemmatizer.lemmatize_plain('birne', ignore_case=True)
# ['Birne']
lemmatizer.lemmatize_plain('zerstreut', ignore_case=True)
# ['zerstreut', 'zerstreuen']

Citation

Please include the following BibTeX if you use IWNLP in your work:

@InProceedings{liebeck-conrad:2015:ACL-IJCNLP,
  author    = {Liebeck, Matthias  and  Conrad, Stefan},
  title     = {{IWNLP: Inverse Wiktionary for Natural Language Processing}},
  booktitle = {Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 2: Short Papers)},
  year      = {2015},
  publisher = {Association for Computational Linguistics},
  pages     = {414--418},
  url       = {http://www.aclweb.org/anthology/P15-2068}
}

iwnlp-py's People

Contributors

99991 avatar jcbgamboa avatar liebeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

iwnlp-py's Issues

Default lemmatizer included

Hi @Liebeck,

first of all, thanks for this awesome package! Is there any particular reason why an IWNLP dump is not included by default in the pip package (is it due to size?)? It would be nice to have while giving the user the option to specify their own path.

Cheers,
Steph

Nondeterministic lemmatization behavior

Really appreciate your work.

At the moment the lemmatization seems to be nondeterministic. For example running

from iwnlp.iwnlp_wrapper import IWNLPWrapper
lemmatizer = IWNLPWrapper(lemmatizer_path='IWNLP.Lemmatizer_20170501.json')
print(lemmatizer.lemmatize_plain('ein', False))

sometimes gives ['einen', 'ein'] and sometimes ['ein', 'einen'].

Is there already a way to get deterministic results? If not I see two possible solutions:

  1. If some kind of confidence values are available for each lemma option, return the list sorted by confidence.
  2. Return a set of lemmas instead of a list and let the user figure out which lemma to choose.

Add rules or suffix search?

Since German has arbitrary composita, a purely lookup-based lemmatiser will often fail because of OOV words. But in many cases a guess that is better than nothing at all could be to combine the prefix with the lemma of a known suffix, e.g: lemma("Mithelferinnen" ) = "Mit"+lemma("Helferinnen").

Are there any plans to add support for composita?

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.