Skip to content

Instantly share code, notes, and snippets.

@maxjakob
Created May 18, 2012 10:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxjakob/2724633 to your computer and use it in GitHub Desktop.
Save maxjakob/2724633 to your computer and use it in GitHub Desktop.
DBpedia Spotlight Web Service example call
val exampleText = "Residential Search List Page - Mortgage advice from SPF, WT.conv, Mortgage Advice From SPF, WT.tx_e, conv, WT.dl, 85], selector:a[href*=mortgages]}]},"
val urlEncoded = java.net.URLEncoder.encode(exampleText, "utf-8")
val url = new java.net.URL("http://spotlight.dbpedia.org/rest/annotate")
val data = "text=" + urlEncoded + "&support=10&confidence=0.2"
val conn = url.openConnection
conn.setDoOutput(true)
val out = new java.io.OutputStreamWriter(conn.getOutputStream)
out.write(data)
out.flush
out.close
val in = conn.getInputStream()
println(io.Source.fromInputStream(in).mkString(""))
in.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment