Search code examples
c#wiktionary

API WiktionaryNET


I am trying to use the Wiktionary's API trying to know if some words are defined or not. I have seen the open source's WiktionaryNET and they use this code:

In my console code:

var word = Wiktionary.Define("clean");
foreach (var def in word.Definition)
     Console.WriteLine(def);

In the app.config:

<system.net>
   <defaultProxy useDefaultCredentials="true" />
 </system.net>

I use the same things but the result is always "Definition.Count = 0" Someone know, how can I use or set up to get results?

Thanks in advance for your help.


Solution

  • I'm the implementer of this library. Thanks for pointing this out. I'll try to explain what happened and what can you do if you really need this fixed right now.

    The wiktionary response is in JSON format but it's terrible to parse. It's actually one single blub of text. What happened is that the JSON response from wiktionary was modified since the wiktionaryNET was implemented. It now contains an additional field. The wiktionaryNET parser mistakenly interprets this as the content it was supposed to parse in the first place. The result is an empty response from the library.

    You can download the project from GitHub. Then go to WiktionaryJsonQuery.cs and modify the AddQuery statements to include the rawcontinue:

    AddQuery("format=json");
    AddQuery("rawcontinue");  // <-- add this line
    AddQuery("action=query");
    AddQuery("prop=revisions");
    AddQuery("rvprop=content");
    AddQuery("titles=" + word);
    

    Build the project and add the resulting dll to your project.

    Please note this is only in beta.