commit 20a6d7c1cd00ad6da5b51cd5c81b77f57e865b82 Author: J.Fernando Sánchez Date: Thu Mar 15 21:32:37 2012 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb0f5cd --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +![GSI Logo](http://gsi.dit.upm.es/templates/jgsi/images/logo.png) +[Web 4.0](http://gsi.dit.upm.es) +================================== + +Description +--------------------- +This module is part of the Web4.0 project. + +You can use it to query the spotlight endpoint in order to tag text. + +Dependencies +-------------------- +To run this project, you will need to install the following dependencies through npm: + +- coffee-script +- request +- querify +- hook.io diff --git a/hook.io-spotlight.coffee b/hook.io-spotlight.coffee new file mode 100644 index 0000000..77de567 --- /dev/null +++ b/hook.io-spotlight.coffee @@ -0,0 +1,20 @@ +request = require 'request' +querystring = require 'querystring' + +cb = console.log + +query = "I like indie music" +#console.log " http://spotlight.dbpedia.org/rest/annotate?" + querystring.stringify({confidence:-1,"support":-1,text:query}) + +opts = + uri: "http://spotlight.dbpedia.org/rest/annotate?" + querystring.stringify({text:query,confidence:0.0,support:-1}) + headers: {"Accept": 'application/json'} + encoding: 'utf8' +request.get opts, (err, res, body) -> + if res?.statusCode is 200 +# cb? "Response: #{body}" + cb? null, JSON.parse body + else + cb? "Something went wrong" + cb? [err, res, body] + diff --git a/index.js b/index.js new file mode 100644 index 0000000..f0272ec --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +require('coffee-script') +require('./hook.io-spotlight')