C#-API for the Wortschatz Leipzig webservices

csharp webserviceAt the weekend I was looking for a way to find synonyms for a given word. After a quick search on the net I came across the Openthesaurus project, which offers an offline database of synonyms for download. However, I wanted to have a second source for comparison. After further searching, I went to the thesaurus of the “Wortschatz Leipzig” project.  Although they offer no offline synonym database, but a free webservice.

Since this web service can not be easily integrated in the Visual Studio into your own projects and it took me some time and energy to figure out how to get things up and running, I have enclosed my whole web service client code into a small library.

If you’re not interested in a “ready-to-use” library, but in the technical sight of things, you should read that article first.

Example: Get synonyms for “Kindergarten”

The Wortschatz Leipzig thesaurus can be easily used by my library. First, of course, the “WortschatzLeipzigAPI.dll” must be added to the references. Thereafter, in order to facilitate the work, a using-statement can be used.

using WortschatzLeipzigAPI;

Now the actual service call can take place. The method GetSynonyms() is static and can be found in the class “Thesaurus”.

List<string> synonyms = Thesaurus.GetSynonyms(“Kindergarten”);

Synonmys contains now, after calling GetSynonyms(“Kindergarten”), a list of synonyms for the word “Kindergarten”.

The method GetSynonyms() takes two more additional parameters that are preset by default.

 GetSynonyms(
 string inputWord,
 int maxSynonyms = 500,
 string corpus = "de"
 )

inputWord

  • Type: string
  • The input word for which synonyms should be searched

maxSynonyms (optional)

  • Type: int
  • The maximum number of synonyms that should be picked up by the web service

Corpus (optional)

  • Type: string
  • The dictionary of synonyms which should be used. Theoretically more dictionaries than the german (de=>deutschland<=>germany) should be available. Unfortunately in practice I couldn’t get any of them to work.

Download

Direct download: WortschatzLeipzigAPI.dll
Direct download: WortschatzLeipzigAPI + testprogram (source + Visual Studio project)
Github: WortschatzLeipzigAPI + testprogram (source + Visual Studio project)

Leave a comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked