// Path: linked_data/src/main/java/com/markwatson/linkeddata/DBpediaLookupClient.java
// public class DBpediaLookupClient extends DefaultHandler {
//   public DBpediaLookupClient(String query) throws Exception {
//     this.query = query;
//     HttpClient client = new HttpClient();
// 
//     String query2 = query.replaceAll(" ", "+");
//     HttpMethod method =
//         new GetMethod("http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryString=" +
//             query2);
//     try {
//       client.executeMethod(method);
//       InputStream ins = method.getResponseBodyAsStream();
//       SAXParserFactory factory = SAXParserFactory.newInstance();
//       SAXParser sax = factory.newSAXParser();
//       sax.parse(ins, this);
//     } catch (HttpException he) {
//       System.err.println("Http error connecting to lookup.dbpedia.org");
//     } catch (IOException ioe) {
//       System.err.println("Unable to connect to lookup.dbpedia.org");
//     }
//     method.releaseConnection();
//   }
// 
//   public void printResults(List<Map<String, String>> results) {
//     for (Map<String, String> result : results) {
//       System.out.println("\nNext result:\n");
//       for (String key : result.keySet()) {
//         System.out.println("  " + key + "\t:\t" + result.get(key));
//       }
//     }
//   }
// 
//   private List<Map<String, String>> variableBindings = new ArrayList<Map<String, String>>();
//   private Map<String, String> tempBinding = null;
//   private String lastElementName = null;
// 
//   public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
//     //System.out.println("startElement " + qName);
//     if (qName.equalsIgnoreCase("result")) {
//       tempBinding = new HashMap<String, String>();
//     }
//     lastElementName = qName;
//   }
// 
//   public void endElement(String uri, String localName, String qName) throws SAXException {
//     //System.out.println("endElement " + qName);
//     if (qName.equalsIgnoreCase("result")) {
//       if (!variableBindings.contains(tempBinding) && containsSearchTerms(tempBinding))
//         variableBindings.add(tempBinding);
//     }
//   }
// 
//   public void characters(char[] ch, int start, int length) throws SAXException {
//     String s = new String(ch, start, length).trim();
//     //System.out.println("characters (lastElementName='" + lastElementName + "'): " + s);
//     if (s.length() > 0) {
//       if ("Description".equals(lastElementName)) {
//         if (tempBinding.get("Description") == null) {
//           tempBinding.put("Description", s);
//         }
//         tempBinding.put("Description", "" + tempBinding.get("Description") + " " + s);
//       }
//       //if ("URI".equals(lastElementName)) tempBinding.put("URI", s);
//       if ("URI".equals(lastElementName) && s.indexOf("Category") == -1 && tempBinding.get("URI") == null) {
//         tempBinding.put("URI", s);
//       }
//       if ("Label".equals(lastElementName)) tempBinding.put("Label", s);
//     }
//   }
// 
//   public List<Map<String, String>> variableBindings() {
//     return variableBindings;
//   }
// 
//   private boolean containsSearchTerms(Map<String, String> bindings) {
//     StringBuilder sb = new StringBuilder();
//     for (String value : bindings.values()) sb.append(value);  // do not need white space
//     String text = sb.toString().toLowerCase();
//     StringTokenizer st = new StringTokenizer(this.query);
//     while (st.hasMoreTokens()) {
//       if (text.indexOf(st.nextToken().toLowerCase()) == -1) {
//         return false;
//       }
//     }
//     return true;
//   }
// 
//   private String query = "";
// }


import  com.markwatson.linkeddata.DBpediaLookupClient;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
package com.markwatson.linkeddata;




/**
 * Unit test for NLP.
 */
public class DBPediaTest extends TestCase {

  public DBPediaTest(String testName) {
    super(testName);
  }

  public static Test suite() {
    return new TestSuite(DBPediaTest.class);
  }

  public void testSentenceSplitter() {
    assertTrue(true);
    try {
      //DBpediaLookupClient client = new DBpediaLookupClient("Bill Clinton");
// Path: linked_data/src/main/java/com/markwatson/linkeddata/DBpediaLookupClient.java
// public class DBpediaLookupClient extends DefaultHandler {
//   public DBpediaLookupClient(String query) throws Exception {
//     this.query = query;
//     HttpClient client = new HttpClient();
// 
//     String query2 = query.replaceAll(" ", "+");
//     HttpMethod method =
//         new GetMethod("http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryString=" +
//             query2);
//     try {
//       client.executeMethod(method);
//       InputStream ins = method.getResponseBodyAsStream();
//       SAXParserFactory factory = SAXParserFactory.newInstance();
//       SAXParser sax = factory.newSAXParser();
//       sax.parse(ins, this);
//     } catch (HttpException he) {
//       System.err.println("Http error connecting to lookup.dbpedia.org");
//     } catch (IOException ioe) {
//       System.err.println("Unable to connect to lookup.dbpedia.org");
//     }
//     method.releaseConnection();
//   }
// 
//   public void printResults(List<Map<String, String>> results) {
//     for (Map<String, String> result : results) {
//       System.out.println("\nNext result:\n");
//       for (String key : result.keySet()) {
//         System.out.println("  " + key + "\t:\t" + result.get(key));
//       }
//     }
//   }
// 
//   private List<Map<String, String>> variableBindings = new ArrayList<Map<String, String>>();
//   private Map<String, String> tempBinding = null;
//   private String lastElementName = null;
// 
//   public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
//     //System.out.println("startElement " + qName);
//     if (qName.equalsIgnoreCase("result")) {
//       tempBinding = new HashMap<String, String>();
//     }
//     lastElementName = qName;
//   }
// 
//   public void endElement(String uri, String localName, String qName) throws SAXException {
//     //System.out.println("endElement " + qName);
//     if (qName.equalsIgnoreCase("result")) {
//       if (!variableBindings.contains(tempBinding) && containsSearchTerms(tempBinding))
//         variableBindings.add(tempBinding);
//     }
//   }
// 
//   public void characters(char[] ch, int start, int length) throws SAXException {
//     String s = new String(ch, start, length).trim();
//     //System.out.println("characters (lastElementName='" + lastElementName + "'): " + s);
//     if (s.length() > 0) {
//       if ("Description".equals(lastElementName)) {
//         if (tempBinding.get("Description") == null) {
//           tempBinding.put("Description", s);
//         }
//         tempBinding.put("Description", "" + tempBinding.get("Description") + " " + s);
//       }
//       //if ("URI".equals(lastElementName)) tempBinding.put("URI", s);
//       if ("URI".equals(lastElementName) && s.indexOf("Category") == -1 && tempBinding.get("URI") == null) {
//         tempBinding.put("URI", s);
//       }
//       if ("Label".equals(lastElementName)) tempBinding.put("Label", s);
//     }
//   }
// 
//   public List<Map<String, String>> variableBindings() {
//     return variableBindings;
//   }
// 
//   private boolean containsSearchTerms(Map<String, String> bindings) {
//     StringBuilder sb = new StringBuilder();
//     for (String value : bindings.values()) sb.append(value);  // do not need white space
//     String text = sb.toString().toLowerCase();
//     StringTokenizer st = new StringTokenizer(this.query);
//     while (st.hasMoreTokens()) {
//       if (text.indexOf(st.nextToken().toLowerCase()) == -1) {
//         return false;
//       }
//     }
//     return true;
//   }
// 
//   private String query = "";
// }


// Path: linked_data/src/test/java/com/markwatson/linkeddata/DBPediaTest.java
import  com.markwatson.linkeddata.DBpediaLookupClient;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

package com.markwatson.linkeddata;




/**
 * Unit test for NLP.
 */
public class DBPediaTest extends TestCase {

  public DBPediaTest(String testName) {
    super(testName);
  }

  public static Test suite() {
    return new TestSuite(DBPediaTest.class);
  }

  public void testSentenceSplitter() {
    assertTrue(true);
    try {
      //DBpediaLookupClient client = new DBpediaLookupClient("Bill Clinton");
      DBpediaLookupClient client = new DBpediaLookupClient("London UK");