0

I am trying to retrieve synonym and antonyms using Wiktionary API. I am getting some response but it's a bit hazy. I have used this code:

$(document).ready(function() {
    var page= $( this ).val();
    $.getJSON(baseURL+'/w/api.php?action=parse&format=json&prop=text|revid|displaytitle|extracts&callback=?&page=' + page,
    function(json) {
      if(json.parse.revid > 0) {                
        //showPage(page,json.parse.text['*']);
                var markup = json.parse.text['*'];
                var blurb = $('<div></div>').html(markup);
                var last = $(blurb).find('p');
        $('#article').html(last);
                console.log(last);
      } else {
         // error code
      }
    });
  });

Is it possible to get the exact word? If yes, then I need some clue.

Nemo
  • 2,441
  • 2
  • 29
  • 63
Sariban D'Cl
  • 2,197
  • 2
  • 28
  • 42

1 Answers1

0

Nemo's 0th rule of wiki development: if you find yourself parsing wikitext, you're doing it wrong.

If you're using the English Wiktionary, you are lucky: you can and should use the Wiktionary RDF extraction by DBpedia and help improve it as needed. If you need other Wiktionary languages, please contribute to their DBpedia extraction.

Nemo
  • 2,441
  • 2
  • 29
  • 63
  • The wiktionary aspect of DBPedia shows signs of neglect or abandonment. Most pages produce 404 errors, and the examples do not return meaning results – havlock Jul 18 '17 at 17:56
  • @havlock True. I posted other answers about Wiktionary which may be more relevant now (for some things Wikidata, the new REST API or other systems may be more fruitful now). – Nemo Jul 20 '17 at 22:28