Edit in JSFiddle

var iod_apikey = "your-apikey-here";// get an apikey from IDOL OnDemand
var iod_findrelatedconcepts_url = "https://api.idolondemand.com/1/api/sync/findrelatedconcepts/v1";

// Note this is the article, but the webUrl has a lot of 'noise' from advertisements, links, menus, etc, so this test takes the clean text of the article instead of the guardian_webUrl.
var guardian_webUrl = "http://www.theguardian.com/technology/2014/jun/09/what-is-the-alan-turing-test";
var findRelatedConceptsForURL = guardian_webUrl;

var out = document.getElementById("output");

$('#button1').click( function() {

function fnFindRelatedConcepts(){	
    xhr = new XMLHttpRequest();
	xhr.open('POST', iod_findrelatedconcepts_url, true);	
    var fd = new FormData();
	fd.append("apikey", iod_apikey);  
    var guardian_text = document.getElementById('guardian_text');
    // Note the URL option contains a lot of noise currently
    //fd.append("url", findRelatedConceptsForURL);
    fd.append("text", guardian_text.innerHTML);
    // only search in English news sources
    // To see which newssites are used go here:
    // https://www.idolondemand.com/developer/docs/PublicDatasets.html
    fd.append("indexes", "news_eng");
    // return only news articles younger than 2014-01-01
    fd.append("min_date", "2014-01-01");

    xhr.onreadystatechange = function(){
        out.innerHTML = "onreadystatechange...";
        var r = fnReady();	
    xhr.onload = function(){ };
    out.innerHTML = "Waiting for response...<br><br>";

function fnReady() {
  if (xhr.readyState === 4)
	out.innerHTML += "<br>status: "+xhr.status+": "+xhr.statusText+"<br>";
    var r = xhr.responseText;
        //out.innerHTML += "responseText:<br>"+r+"<br><br>";
		json = JSON.parse(r);
		var entities = json.entities;
            var relatedConcepts = "";
			$(entities).each(function(i) {

				var txt = entities[i].text;
				text = replaceAll(txt, "\n", "<br>");
                var docsWithPhrase = entities[i].docs_with_phrase;
                var occurrences = entities[i].occurrences;
                var docsWithAllTerms = entities[i].docs_with_all_terms;
                var cluster = entities[i].cluster;
                relatedConcepts += "'"+text + "' ["+occurrences+" occurrences in ["+docsWithAllTerms+"] news articles]<br>";
            var out3 = document.getElementById('output3');
            out3.innerHTML += "<br>Related Concepts in the news: "+"<div style=\"background-color:lightgray;\">"+relatedConcepts+"</div><br>";
            var btn2 = document.getElementById('button2');
            btn2.style.visibility = 'visible';
            $('#button2').click( function() {
		out.innerHTML += "Error: no response.<br>";
      out.innerHTML = "xhr.readyState: "+xhr.readyState;

function replaceAll(string, find, replace) {
  return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
function escapeRegExp(string) {
    return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");

function fnCreateBubbleChart(json) {	
    var r = 600,
        format = d3.format(",d"),
        fill = d3.scale.category20c();
    var bubble = d3.layout.pack()
        .size([r, r])
    var vis = d3.select("#chart").append("svg")
        .attr("width", r)
        .attr("height", r)
        .attr("class", "bubble");
      var node = vis.selectAll("g.node")
          .filter(function(d) { 
              return !d.children; 
          .attr("class", "node")
          .attr("transform", function(d) { 
              return "translate(" + d.x + "," + d.y + ")"; 
      var circle = node.append("circle")
          .attr("r", function(d) { return d.r; })
          .style("fill", function(d) { return fill(d.text); });
    var div = d3.select("body").append("div") 
            .attr("class", "tooltip");
      .on("mouseover", function(d) {
                .style("opacity", .9);      
                .style("left", (d3.event.pageX) + "px")     
                .style("top", (d3.event.pageY - 28) + "px");
      .on("mouseout", function(d) {       
                .style("opacity", 0);
      var textLabel = node.append("text")
      .attr("dy", ".3em")
      .style("text-anchor", "middle")
      .text(function(d) { return d.text.substring(0, d.r / 3); });
       .on("mouseover", function(d) {
                .style("opacity", .9);      
                .style("left", (d3.event.pageX) + "px")     
                .style("top", (d3.event.pageY - 28) + "px");
      .on("mouseout", function(d) {       
                .style("opacity", 0);


      "text": "concerns over",
      "docs_with_phrase": 7,
      "occurrences": 7,
      "docs_with_all_terms": 17,
      "cluster": 1
function classes2(root) {
  var classes2 = [];
  function recurse(node) {
      if (node.entities){
          node.entities.forEach(function(child) { 
                  text: node.text, 
                  className: node.text, 
                  value: node.occurrences
  return {children: classes2};
<b>Code example - IDOL OnDemand Find Related Concepts in the News.</b><br>
To see those concepts in the news (in index news_eng) that most relate to the Guardian article below, press the Find Related Concepts button.<br>
<input type="button" value="Find Related Concepts in the News" id="button1">
<div id="output"></div>     
<input type="button" value="Create Bubble Chart" id="button2" style="visibility:hidden;"><div id="output2"></div> 
<div id="chart"></div>     
<div id="output3"></div>     
<h2>Text from Guardian article:</h2>
<div><pre id="guardian_text">
The Guardian home

Computer simulating 13-year-old boy becomes first to pass Turing test<br>
'Eugene Goostman' fools 33% of interrogators into thinking it is human, in what is seen as a milestone in artificial intelligence

- In 'his own' words: how Eugene fooled the Turing judges
- What is the Turing test? And are we all doomed now?
Press Association
theguardian.com, Monday 9 June 2014 07.09 EDT
turing test

Codebreaker Alan Turing devised a test in 1950, saying that if a machine was indistinguishable from a human, then it was 'thinking'. Photograph: Sherborne School/AFP/Getty Images

A "super computer" has duped humans into thinking it was a 13-year-old boy to become the first machine to pass the Turing test, experts have said. Five machines were tested at the Royal Society in central London to see if they could fool people into thinking they were humans during text-based conversations.

The test was devised in 1950 by computer science pioneer and second world war codebreaker Alan Turing, who said that if a machine was indistinguishable from a human, then it was "thinking".

No computer had ever previously passed the Turing test, which requires 30% of human interrogators to be duped during a series of five-minute keyboard conversations, organisers from the University of Reading said.

But "Eugene Goostman", a computer programme developed to simulate a 13-year-old boy, managed to convince 33% of the judges that it was human, the university said.

Professor Kevin Warwick, from the University of Reading, said: "In the field of artificial intelligence, there is no more iconic and controversial milestone than the Turing test. It is fitting that such an important landmark has been reached at the Royal Society in London, the home of British science and the scene of many great advances in human understanding over the centuries. This milestone will go down in history as one of the most exciting."

The successful machine was created by Russian-born Vladimir Veselov, who lives in the United States, and Ukrainian Eugene Demchenko, who lives in Russia.

Veselov said: "It's a remarkable achievement for us and we hope it boosts interest in artificial intelligence and chatbots."

Warwick said there had been previous claims that the test was passed in similar competitions around the world. "A true Turing test does not set the questions or topics prior to the conversations," he said. "We are therefore proud to declare that Alan Turing's test was passed for the first time."

Warwick said having a computer with such artificial intelligence had "implications for society" and would serve as a "wake-up call to cybercrime".

The event on Saturday was poignant as it took place on the 60th anniversary of the death of Turing, who laid the foundations of modern computing. During the second world war, his critical work at Britain's codebreaking centre at Bletchley Park helped shorten the conflict and save many thousands of lives.

Instead of being hailed a hero, Turing was persecuted for his homosexuality. After his conviction in 1952 for gross indecency with a 19-year-old Manchester man, he was chemically castrated. Two years later, he died from cyanide poisoning in an apparent suicide, though there have been suggestions that his death was an accident.

Last December, after a long campaign, Turing was given a posthumous royal pardon.

In 2011, at the Techniche festival in Guwahati, India, an application called Cleverbot took part in a Turing-type test and was perceived to be human by 59.3% of its interlocutors (compared with a score of 63.3% human for the average human participant). However, because the programme draws on a database of real conversations, many disputed whether it was in fact exhibiting true "intelligence".
div.tooltip {   
  position: absolute;           
  text-align: center;           
  width: auto;                  
  height: auto;                 
  padding: 5px;             
  font: 12px sans-serif;        
  background: lightyellow;   
  border: 1px solid red;      
  border-radius: 8px;           
  pointer-events: none;         

External resources loaded into this fiddle: