Using the e-Entity & e-Link Pipeline

Introduction

In this tutorial you will be shown how the pipelining service can be used to process your content by the e-Entity and e-Link service by using a single call. For a detailed introduction how to use, create and store pipelines, have a look at the pipelines article.

Step 1 - Input text

For this tutorial we will choose a sentence, which we will run through the e-Entity and e-Link service. Let us take the sentence

This summer there is the Zomerbar in Antwerp, one of the most beautiful cities in Belgium.
	

Step 2 - Creating the pipeline request

Although we use two services, we only do a single call to the pipelining service. Therefor we need to construct a request that contains the parameters for both services, before calling the pipelining service.

A request to the pipelining service consists of an array where each service is an element of that array. In our case the first service is the e-Entity. The code looks like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "method": "POST",
  "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents/",
  "parameters": {
   "language": "en",
   "dataset": "dbpedia",
   "mode": "all"
  },
  "headers": {
    "content-type": "text/plain",
    "accept": "text/turtle"
  },
    "body": "This summer there is the Zomerbar in Antwerp, one of the most beautiful cities in Belgium."
}

The 'body' contains the aforementioned sentence, and 'endpoint' states that we want to use the e-Entity service. For a complete explanation of the code we refer to the e-Entity documentation. Next, we will define what we happens with the result of the e-Entity service. This results in the following code for the e-Link service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "method": "POST",
  "endpoint": "https://api.freme-project.eu/current/e-link/documents/",
  "parameters": {
    "templateid": "1"
  },
  "headers": {
    "content-type": "text/turtle",
    "accept": "text/turtle"
  }
}

We are using the first template via 'parameters.templateid'. Again, for more detailed information about the service we refer to the e-Link documentation. Now, we add the two pieces of code in an array, which results in:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[
{
  "method": "POST",
  "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents/",
  "parameters": {
   "language": "en",
   "dataset": "dbpedia",
   "mode": "all"
  },
  "headers": {
    "content-type": "text/plain",
    "accept": "text/turtle"
  },
  "body": "This summer there is the Zomerbar in Antwerp, one of the most beautiful cities in Belgium."
},
{
  "method": "POST",
  "endpoint": "https://api.freme-project.eu/current/e-link/documents/",
  "parameters": {
    "templateid": "1"
  },
  "headers": {
    "content-type": "text/turtle",
    "accept": "text/turtle"
  }
}
]

Step 3 - Calling the pipelining service

To call the pipelining service with the request we created above, we execute the following Terminal command:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '[{"method": "POST","endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents","parameters": {"language": "en","dataset": "dbpedia","mode": "all"},"headers": {"content-type": "text/plain","accept": "text/turtle"},"body": "This summer there is the Zomerbar in Antwerp, one of the most beautiful cities in Belgium."},{"method": "POST","endpoint": "https://api.freme-project.eu/current/e-link/documents/","parameters": {"templateid": "1"},"headers": {"content-type": "text/turtle","accept": "text/turtle"}}]' 'https://api.freme-project.eu/current/pipelining/chain'

Step 4 - Result

As you can see in the result, e.g., the city of 'Antwerp' was recognized:

1
2
3
4
5
6
7
8
9
<http://freme-project.eu/#char=37,44>
        a                     nif:Word , nif:Phrase , nif:String , nif:RFC5147String ;
        nif:anchorOf          "Antwerp"^^xsd:string ;
        nif:beginIndex        "37"^^xsd:nonNegativeInteger ;
        nif:endIndex          "44"^^xsd:nonNegativeInteger ;
        nif:referenceContext  <http://freme-project.eu/#char=0,90> ;
        itsrdf:taClassRef     <http://dbpedia.org/ontology/PopulatedPlace> , <http://dbpedia.org/ontology/Settlement> , <http://dbpedia.org/ontology/Location> , <http://dbpedia.org/ontology/Place> , <http://nerd.eurecom.fr/ontology#Location> ;
        itsrdf:taConfidence   "0.9942746344558188"^^xsd:double ;
        itsrdf:taIdentRef     <http://dbpedia.org/resource/Antwerp> .

Also the use of the e-Link service (and the use of template 1) provided us with the musea in or close to Antwerp. For instance:

1
2
3
4
5
<http://dbpedia.org/resource/Museum_aan_de_Stroom>
        foaf:based_near  <http://dbpedia.org/resource/Antwerp> .

<http://dbpedia.org/resource/Museums_of_the_Far_East>
        foaf:based_near  <http://dbpedia.org/resource/Antwerp> .