Package: py-openthesaurus
Python wrapper for obtaining synonyms in the German language from OpenThesaurusWhen working in Natural Language Processing (NLP) area, synonyms can be an essential part of the data augmentation process. The task of obtaining synonyms for the German language is currently limited since there are no easily accessible lexical databases for the German language. Compared to the WordNet
lexical database for the English language, which is available as annltkpackage,GermaNetrepresents only one German lexical database alternative. However, to useGermaNetfor further research purposes, it is necessary to obtain the license manually.This repository represents a Python wrapper implementation for obtaining synonyms in a faster and easier way, using the German synonym database and API fromOpenThesaurus.InstallationThe library can be installed from PyPI:pip install py-openthesaurusDownload open-thesaurus database dumpDownload the official open-thesaurus database dump from the followinglink.
If the link is not working, please visit the followingpageand download the up-to-date database dump.Setup mysql and import open-thesaurus database dumpTo install mysql-server on Ubuntu run:sudo apt-get updatesudo apt-get install mysql-serverCreate a new database:mysql -u user_name -pmysql> create database database_name;mysql> exitExtract the downloaded database dump file to import it using the following command:mysql -u user_name -p database_name < openthesaurus_dump.sqlTo use themysqlclientlibrary in Python on Ubuntu, install the following dependencies:sudo apt-get install python3-pip python3-dev libmysqlclient-devThis library, as a dependency, usesmysqlclientPython library. For support on other systems, please check the followinglink.UsageAs a Python library, retrieving results from a previously imported database:frompy_openthesaurusimportOpenThesaurusDbopen_thesaurus=OpenThesaurusDb(host="host",user="user",passwd="passwd",db_name="database_name")# to get the short version of synonyms as a listsynonyms=open_thesaurus.get_synonyms(word="München")# to get the long version of synonyms as a listsynonyms_long=open_thesaurus.get_synonyms(word="München",form="long")As a Python library, retrieving results from a web end-point:frompy_openthesaurusimportOpenThesaurusWebopen_thesaurus=OpenThesaurusWeb()# to get the short version of synonyms as a listsynonyms=open_thesaurus.get_synonyms(word="München")# to get the long version of synonyms as a listsynonyms_long=open_thesaurus.get_synonyms(word="München",form="long")As a command-line tool (which currently obtains results from a web API):usage: py_openthesaurus [-h] [--form {long,short}] --word WORDGet synonyms of German words from www.openthesaurus.deoptional arguments:-h, --help           show this help message and exit--form {long,short}  Defaults to form=short which means that short versionsof synonyms will be returned, without nach/zuprefixes/suffixes. On the other hand, form=long returnsthe full versions of synonyms, including nach/zu, sichprefixes/suffixes.required arguments:--word WORD          A word from which synonyms will be obtainedAcknowledgmentsOpenThesaurusfor developing a German synonym database with API from which synonyms for the German language can be obtainedLicenceEven though this project is under MIT license, please check information aboutOpenThesauruslicensing and API limitations (only 60 requests per minute are currently supported) from the followinglink, in the case your software will need an exhaustive amount of web API requests in a short period of time.