Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 150 lines (124 sloc) 5.546 kb

Description

  • takes a GET or POST request with a parameter called input
  • queries dbpedia-spotlight annotation endpoint for named entity recognition on the given input
  • supports mapping of dbpedia to NERD ontology classes (version 0.4)

Links:

Interface

  • it's stateless
  • it takes POST or GET requests
  • it takes the following parameters

Parameters

required

  • input-type = 'text'
  • input = 'some text'
    • url encoded text
  • nif = 'true' | 'nif-1.0'

optional

  • prefix = 'URI'
  • format = 'rdfxml' | 'json' | 'jsonp'
    • output format
    • default: rdfxml

Dependencies

Usage

  • install node-js
  • install npm (curl http://npmjs.org/install.sh | sh)
  • install xmlbuilder package (npm install xmlbuilder)
  • install log4js-node package (npm install log4js)
# start the server
node server.js

# curl the server
curl http://localhost:1337 --data-urlencode input="fun with nodejs, json, rdf and nif." -d input-type=text -d nif=true -d prefix="http://myprefix.whatever.de/"
<?xml version='1.0' encoding='UTF-8' ?>
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:scms="http://ns.aksw.org/scms/"
  xmlns:str="http://nlp2rdf.lod2.eu/schema/string/">
  <rdf:Description rdf:about="http://myprefix.whatever.de/offset_0_35_fun+with+nodejs%2C+jso">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/Document"/>
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString"/>
    <str:sourceString>fun with nodejs, json, rdf and nif.</str:sourceString>
    <str:subString rdf:resource="http://myprefix.whatever.de/offset_9_15_nodejs"/>
    <str:subString rdf:resource="http://myprefix.whatever.de/offset_17_21_json"/>
    <str:subString rdf:resource="http://myprefix.whatever.de/offset_23_26_rdf"/>
    <str:subString rdf:resource="http://myprefix.whatever.de/offset_31_34_nif"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://myprefix.whatever.de/offset_9_15_nodejs">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString"/>
    <str:anchorOf>nodejs</str:anchorOf>
    <scms:means rdf:resource="http://dbpedia.org/resource/Node.js"/>
    <str:beginIndex>9</str:beginIndex>
    <str:endIndex>15</str:endIndex>
  </rdf:Description>
  <rdf:Description rdf:about="http://myprefix.whatever.de/offset_17_21_json">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString"/>
    <str:anchorOf>json</str:anchorOf>
    <scms:means rdf:resource="http://dbpedia.org/resource/JSON"/>
    <str:beginIndex>17</str:beginIndex>
    <str:endIndex>21</str:endIndex>
  </rdf:Description>
  <rdf:Description rdf:about="http://myprefix.whatever.de/offset_23_26_rdf">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString"/>
    <str:anchorOf>rdf</str:anchorOf>
    <scms:means rdf:resource="http://dbpedia.org/resource/Resource_Description_Framework"/>
    <str:beginIndex>23</str:beginIndex>
    <str:endIndex>26</str:endIndex>
  </rdf:Description>
  <rdf:Description rdf:about="http://myprefix.whatever.de/offset_31_34_nif">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/string/OffsetBasedString"/>
    <str:anchorOf>nif</str:anchorOf>
    <scms:means rdf:resource="http://dbpedia.org/resource/Neuroscience_Information_Framework"/>
    <str:beginIndex>31</str:beginIndex>
    <str:endIndex>34</str:endIndex>
  </rdf:Description>
</rdf:RDF>

Error handling

  • the webservice handles some errors that can occur

  • dbpedia spotlight endpoint does not response, i.e.:

<?xml version='1.0' encoding='UTF-8' ?>
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:error="http://nlp2rdf.lod2.eu/schema/error/">
  <rdf:Description rdf:about="http://myprefix.whatever.de/error_0">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/error/Error"/>
    <error:fatal>1</error:fatal>
    <error:hasMessage>Error: ENODATA, DNS server returned answer with no data</error:hasMessage>
  </rdf:Description>
</rdf:RDF>
  • wrong input parameters, i.e.:
<?xml version='1.0' encoding='UTF-8' ?>
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:error="http://nlp2rdf.lod2.eu/schema/error/">
  <rdf:Description rdf:about="http://myprefix.whatever.de/error_0">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/error/Error"/>
    <error:fatal>1</error:fatal>
    <error:hasMessage>Wrong parameter, please provide valid input, input-type and nif.</error:hasMessage>
  </rdf:Description>
  <rdf:Description rdf:about="http://myprefix.whatever.de/error_1">
    <rdf:type rdf:resource="http://nlp2rdf.lod2.eu/schema/error/Error"/>
    <error:fatal>1</error:fatal>
    <error:hasMessage>Parameter input-type must equal text.</error:hasMessage>
  </rdf:Description>
</rdf:RDF>

ToDo

  • add context-hash-based URIs
  • nice to have: accept and return multiple data types (bold data types are already supported)
    • incoming: text, rdf
    • outgoing: xml, json, jsonp, n3, turtle
Something went wrong with that request. Please try again.