How to access FREME using various programming languages

This tutorial shows some examples how to use FREME features in cURL, Javascript / jQuery or PHP V1. Please read the tutorial with the FREME 2016 February Webinar slides.

Table of Contents

  1. Example API Call
  2. Chaining of e-services client side
  3. Chaining of e-services via pipelines
  4. Simplified output
  5. Translation without e-Terminology
  6. e-Translation improved by e-Terminology
  7. HTML input processed with e-Terminology
  8. HTML input processed with e-Terminology and HTML output
  9. Distributed chaining of services

Example 1: Example API Call

This example shows how to call FREME NER.

Example in cURL

curl -X POST -H "Content-Type: text/plain" -H "Accept: text/turtle" -d 'Welcome to the city of Prague.' "https://api.freme-project.eu/current/e-entity/freme-ner/documents/?language=en&dataset=dbpedia"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-entity/freme-ner/documents/?language=en&dataset=dbpedia",
  "method": "POST",
  "headers": {
    "content-type": "text/plain",
    "accept": "text/turtle"
  },
  "data": "Welcome to the city of Prague."
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-entity/freme-ner/documents/');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'language' => 'en',
  'dataset' => 'dbpedia'
));

$request->setHeaders(array(
  'accept' => 'text/turtle',
  'content-type' => 'text/plain'
));

$request->setBody('Welcome to the city of Prague.');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 2: Chaining of e-services client side

This example shows how to combine e-Entiy with e-Link.

Example in cURL

Please download data-chain.txt before executing the CURL request.
curl -X POST -H "Content-Type: text/turtle" -H "Accept: text/turtle" -d @data-chain.txt "https://api.freme-project.eu/current/e-link/documents/?templateid=3"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-link/documents/?templateid=3",
  "method": "POST",
  "headers": {
    "content-type": "text/turtle",
    "accept": "text/turtle"
  },
  "data": "@prefix dbpedia-fr: <http://fr.dbpedia.org/resource/> .\n@prefix dbc:   <http://dbpedia.org/resource/Category:> .\n@prefix dbpedia-es: <http://es.dbpedia.org/resource/> .\n@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .\n@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\n@prefix dbpedia: <http://dbpedia.org/resource/> .\n@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .\n@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n@prefix dbpedia-de: <http://de.dbpedia.org/resource/> .\n@prefix dbpedia-ru: <http://ru.dbpedia.org/resource/> .\n@prefix freme-onto: <http://freme-project.eu/ns#> .\n@prefix dbpedia-nl: <http://nl.dbpedia.org/resource/> .\n@prefix dcterms: <http://purl.org/dc/terms/> .\n@prefix dbpedia-it: <http://it.dbpedia.org/resource/> .\n\n<http://freme-project.eu/#char=23,29>\n        a                     nif:String , nif:Word , nif:RFC5147String , nif:Phrase ;\n        nif:anchorOf          \"Prague\"^^xsd:string ;\n        nif:beginIndex        \"23\"^^xsd:int ;\n        nif:endIndex          \"29\"^^xsd:int ;\n        nif:referenceContext  <http://freme-project.eu/#char=0,30> ;\n        itsrdf:taClassRef     <http://dbpedia.org/ontology/Location> , <http://dbpedia.org/ontology/PopulatedPlace> , <http://nerd.eurecom.fr/ontology#Location> , <http://dbpedia.org/ontology/Place> , <http://dbpedia.org/ontology/City> , <http://dbpedia.org/ontology/Settlement> ;\n        itsrdf:taConfidence   \"0.9938091793011123\"^^xsd:double ;\n        itsrdf:taIdentRef     dbpedia:Prague .\n\n<http://freme-project.eu/#char=0,30>\n        a               nif:String , nif:Context , nif:RFC5147String ;\n        nif:beginIndex  \"0\"^^xsd:int ;\n        nif:endIndex    \"30\"^^xsd:int ;\n        nif:isString    \"Welcome to the city of Prague.\"^^xsd:string .\n"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-link/documents/');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'templateid' => '3'
));

$request->setHeaders(array(
  'accept' => 'text/turtle',
  'content-type' => 'text/turtle'
));

$request->setBody('@prefix dbpedia-fr: <http://fr.dbpedia.org/resource/> .
@prefix dbc:   <http://dbpedia.org/resource/Category:> .
@prefix dbpedia-es: <http://es.dbpedia.org/resource/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .
@prefix dbpedia-de: <http://de.dbpedia.org/resource/> .
@prefix dbpedia-ru: <http://ru.dbpedia.org/resource/> .
@prefix freme-onto: <http://freme-project.eu/ns#> .
@prefix dbpedia-nl: <http://nl.dbpedia.org/resource/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dbpedia-it: <http://it.dbpedia.org/resource/> .

<http://freme-project.eu/#char=23,29>
        a                     nif:String , nif:Word , nif:RFC5147String , nif:Phrase ;
        nif:anchorOf          "Prague"^^xsd:string ;
        nif:beginIndex        "23"^^xsd:int ;
        nif:endIndex          "29"^^xsd:int ;
        nif:referenceContext  <http://freme-project.eu/#char=0,30> ;
        itsrdf:taClassRef     <http://dbpedia.org/ontology/Location> , <http://dbpedia.org/ontology/PopulatedPlace> , <http://nerd.eurecom.fr/ontology#Location> , <http://dbpedia.org/ontology/Place> , <http://dbpedia.org/ontology/City> , <http://dbpedia.org/ontology/Settlement> ;
        itsrdf:taConfidence   "0.9938091793011123"^^xsd:double ;
        itsrdf:taIdentRef     dbpedia:Prague .

<http://freme-project.eu/#char=0,30>
        a               nif:String , nif:Context , nif:RFC5147String ;
        nif:beginIndex  "0"^^xsd:int ;
        nif:endIndex    "30"^^xsd:int ;
        nif:isString    "Welcome to the city of Prague."^^xsd:string .
');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 3: Chaining of e-services via pipelines

This example shows how to combine e-Entiy with e-Link via the FREME pipeline mechanism.

Example in cURL

curl -X POST -H "Content-Type: application/json" -d '[ {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents",   "parameters": {     "language": "en" ,  "dataset": "dbpedia"  },   "headers": {     "content-type": "text/plain",     "accept": "text/turtle"   },   "body": "Welcome to the city of Prague." }, {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-link/documents/",   "parameters": {     "templateid": "3"   },   "headers": {     "content-type": "text/turtle"   } } ]' "https://api.freme-project.eu/current/pipelining/chain"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/pipelining/chain",
  "method": "POST",
  "headers": {
    "content-type": "application/json"
  },
  "processData": false,
  "data": "[ {   \"method\": \"POST\",   \"endpoint\": \"https://api.freme-project.eu/current/e-entity/freme-ner/documents\",   \"parameters\": {     \"language\": \"en\" ,  \"dataset\": \"dbpedia\"  },   \"headers\": {     \"content-type\": \"text/plain\",     \"accept\": \"text/turtle\"   },   \"body\": \"Welcome to the city of Prague.\" }, {   \"method\": \"POST\",   \"endpoint\": \"https://api.freme-project.eu/current/e-link/documents/\",   \"parameters\": {     \"templateid\": \"3\"   },   \"headers\": {     \"content-type\": \"text/turtle\"   } } ]"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/pipelining/chain');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'content-type' => 'application/json'
));

$request->setBody('[ {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents",   "parameters": {     "language": "en" ,  "dataset": "dbpedia"  },   "headers": {     "content-type": "text/plain",     "accept": "text/turtle"   },   "body": "Welcome to the city of Prague." }, {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-link/documents/",   "parameters": {     "templateid": "3"   },   "headers": {     "content-type": "text/turtle"   } } ]');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 4: Simplified output

This example shows how to simplify the output via filtering.

Example in cURL

curl -X POST -H "Content-Type: application/json" -d '[ {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents",   "parameters": {     "language": "en" ,  "dataset": "dbpedia"  },   "headers": {     "content-type": "text/plain",     "accept": "text/turtle"   },   "body": "Welcome to the city of Prague." }, {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-link/documents/",   "parameters": {     "templateid": "3"   },   "headers": {     "content-type": "text/turtle"   } } ]' "https://api.freme-project.eu/current/pipelining/chain?filter=place-and-lat-long&output=csv"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/pipelining/chain?filter=place-and-lat-long&output=csv",
  "method": "POST",
  "headers": {
    "content-type": "application/json"
  },
  "processData": false,
  "data": '[ {   \"method\": \"POST\",   \"endpoint\": \"https://api.freme-project.eu/current/e-entity/freme-ner/documents\",   \"parameters\": {     \"language\": \"en\" ,  \"dataset\": \"dbpedia\"  },   \"headers\": {     \"content-type\": \"text/plain\",     \"accept\": \"text/turtle\"   },   \"body\": \"Welcome to the city of Prague.\" }, {   \"method\": \"POST\",   \"endpoint\": \"https://api.freme-project.eu/current/e-link/documents/\",   \"parameters\": {     \"templateid\": \"3\"   },   \"headers\": {     \"content-type\": \"text/turtle\"   } } ]'
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/pipelining/chain');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'filter' => 'place-and-lat-long',
  'output' => 'csv'
));

$request->setHeaders(array(
  'content-type' => 'application/json'
));

$request->setBody('[ {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-entity/freme-ner/documents",   "parameters": {     "language": "en" ,  "dataset": "dbpedia"  },   "headers": {     "content-type": "text/plain",     "accept": "text/turtle"   },   "body": "Welcome to the city of Prague." }, {   "method": "POST",   "endpoint": "https://api.freme-project.eu/current/e-link/documents/",   "parameters": {     "templateid": "3"   },   "headers": {     "content-type": "text/turtle"   } } ]');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 5: Translation without e-Terminology

This is an example call of e-Translation. The output is simplified.

Example in cURL

curl -X POST -H "Content-Type: text/plain" -d 'The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent.' "https://api.freme-project.eu/current/e-translation/tilde?source-lang=en&target-lang=nl&filter=original-and-translation"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-translation/tilde?source-lang=en&target-lang=nl&filter=original-and-translation",
  "method": "POST",
  "headers": {
    "content-type": "text/plain"
  },
  "data": "The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent."
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-translation/tilde');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'source-lang' => 'en',
  'target-lang' => 'nl',
  'filter' => 'original-and-translation'
));

$request->setHeaders(array(
  'content-type' => 'text/plain'
));

$request->setBody('The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent.');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 6: e-Translation improved by e-Terminology

This example is based on the tutorial How to translate from English to Dutch with e-Translation and e-Terminology.

Example in cURL

curl -X POST -H "Content-Type: application/json" -d '[     {       "method": "POST",       "endpoint": "https://api.freme-project.eu/current/e-terminology/tilde",       "parameters": {         "source-lang": "en",         "target-lang": "nl"       },       "headers": {         "content-type": "text/plain",         "accept": "application/json+ld"       },   "body": "The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent."     },     {       "method": "POST",       "endpoint": "https://api.freme-project.eu/current/e-translation/tilde",       "parameters": {         "source-lang": "en",         "target-lang": "nl"       },       "headers": {         "content-type": "application/json+ld",         "accept": "text/turtle"       }     }   ]' "https://api.freme-project.eu/current/pipelining/chain?filter=original-and-translation&output=csv"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/pipelining/chain?filter=original-and-translation&output=csv",
  "method": "POST",
  "headers": {
    "content-type": "application/json"
  },
  "processData": false,
  "data": "[     {       \"method\": \"POST\",       \"endpoint\": \"https://api.freme-project.eu/current/e-terminology/tilde\",       \"parameters\": {         \"source-lang\": \"en\",         \"target-lang\": \"nl\"       },       \"headers\": {         \"content-type\": \"text/plain\",         \"accept\": \"application/json+ld\"       },   \"body\": \"The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent.\"     },     {       \"method\": \"POST\",       \"endpoint\": \"https://api.freme-project.eu/current/e-translation/tilde\",       \"parameters\": {         \"source-lang\": \"en\",         \"target-lang\": \"nl\"       },       \"headers\": {         \"content-type\": \"application/json+ld\",         \"accept\": \"text/turtle\"       }     }   ]"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/pipelining/chain');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'filter' => 'original-and-translation',
  'output' => 'csv'
));

$request->setHeaders(array(
  'content-type' => 'application/json'
));

$request->setBody('[     {       "method": "POST",       "endpoint": "https://api.freme-project.eu/current/e-terminology/tilde",       "parameters": {         "source-lang": "en",         "target-lang": "nl"       },       "headers": {         "content-type": "text/plain",         "accept": "application/json+ld"       },   "body": "The EU in brief. The EU is a unique economic and political partnership between 28 European countries that together cover much of the continent."     },     {       "method": "POST",       "endpoint": "https://api.freme-project.eu/current/e-translation/tilde",       "parameters": {         "source-lang": "en",         "target-lang": "nl"       },       "headers": {         "content-type": "application/json+ld",         "accept": "text/turtle"       }     }   ]');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 7: HTML input processed with e-Terminology

This example shows how to process HTML input with e-Terminology. The output is turtle.

Example in cURL

curl -X POST -H "Content-Type: text/html" -H "Accept: text/turtle" -d '<!DOCTYPE html> <html lang="en" >   <head>     <meta charset="utf-8" > <title>Example</title>   </head>         <body> <h1>Example</h1>    <p>Welcome to the city of Prague.</p>   </body> </html>' "https://api.freme-project.eu/current/e-terminology/tilde?source-lang=en&target-lang=nl"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-terminology/tilde?source-lang=en&target-lang=nl",
  "method": "POST",
  "headers": {
    "content-type": "text/html",
    "accept": "text/turtle"
  },
  "data": "<!DOCTYPE html> <html lang='en' >   <head>     <meta charset='utf-8' > <title>Example</title>   </head>         <body> <h1>Example</h1>    <p>Welcome to the city of Prague.</p>   </body> </html>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-terminology/tilde');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'source-lang' => 'en',
  'target-lang' => 'nl'
));

$request->setHeaders(array(
  'accept' => 'text/turtle',
  'content-type' => 'text/html'
));

$request->setBody("<!DOCTYPE html> <html lang='en' >   <head>     <meta charset='utf-8' > <title>Example</title>   </head>         <body> <h1>Example</h1>    <p>Welcome to the city of Prague.</p>   </body> </html>");

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 8: HTML input processed with e-Terminology and HTML output

This example shows how to process HTML input with e-Terminology. The output is HTML.

Example in cURL

curl -X POST -H "Content-Type: text/html" -H "Accept: text/html" -d '<!DOCTYPE html> <html lang="en" >   <head>     <meta charset="utf-8" > <title>Example</title>   </head>         <body>     <p>Welcome to the city of Prague.</p>   </body> </html>' "https://api.freme-project.eu/current/e-terminology/tilde?source-lang=en&target-lang=nl"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-terminology/tilde?source-lang=en&target-lang=nl",
  "method": "POST",
  "headers": {
    "content-type": "text/html",
    "accept": "text/html"
  },
  "data": "<!DOCTYPE html> <html lang='en' >   <head>     <meta charset='utf-8' > <title>Example</title>   </head>         <body>     <p>Welcome to the city of Prague.</p>   </body> </html>"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-terminology/tilde');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'source-lang' => 'en',
  'target-lang' => 'nl'
));

$request->setHeaders(array(
  'accept' => 'text/html',
  'content-type' => 'text/html'
));

$request->setBody("<!DOCTYPE html> <html lang='en' >   <head>     <meta charset='utf-8' > <title>Example</title>   </head>         <body>     <p>Welcome to the city of Prague.</p>   </body> </html>");

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example 9: Distributed chaining of services

This example shows how to process output of a DKT service via FREME e-Link

Example in cURL

Please download distributed-chain.txt before executing the CURL request.
curl -X POST -H "Content-Type: text/turtle" -H "Accept: text/turtle" -d @distributed-chain.txt "https://api.freme-project.eu/current/e-link/documents/?templateid=2"

Example in Javascript / jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.freme-project.eu/current/e-link/documents/?templateid=2",
  "method": "POST",
  "headers": {
    "content-type": "text/turtle",
    "accept": "text/turtle"
  },
  "data": "@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .\n@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\n@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .\n\n<http://dkt.dfki.de/documents/#char=11,17>\n        a                     nif:RFC5147String , nif:String ;\n        nif:anchorOf          \"Prague\"^^xsd:string ;\n        nif:beginIndex        \"11\"^^xsd:nonNegativeInteger ;\n        nif:endIndex          \"17\"^^xsd:nonNegativeInteger ;\n        nif:entity            <http://dkt.dfki.de/ontologies/nif#location> ;\n        nif:geoPoint          \"50.083333333333336_14.416666666666666\"^^xsd:string ;\n        nif:referenceContext  <http://dkt.dfki.de/documents/#char=0,26> ;\n        itsrdf:taIdentRef     <http://dbpedia.org/resource/Prague> .\n\n<http://dkt.dfki.de/documents/#char=0,26>\n        a                    nif:RFC5147String , nif:String , nif:Context ;\n        nif:beginIndex       \"0\"^^xsd:nonNegativeInteger ;\n        nif:centralGeoPoint  \"50.083333333333336_14.416666666666666\"^^xsd:string ;\n        nif:endIndex         \"26\"^^xsd:nonNegativeInteger ;\n        nif:geoStandardDevs  \"0.0_0.0\"^^xsd:string ;\n        nif:isString         \"Welcome to Prague in 2016.\"^^xsd:string ."
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Example in PHP

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

$request = new HttpRequest();
$request->setUrl('https://api.freme-project.eu/current/e-link/documents/');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'templateid' => '2'
));

$request->setHeaders(array(
  'accept' => 'text/turtle',
  'content-type' => 'text/turtle'
));

$request->setBody('@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .
@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<http://dkt.dfki.de/documents/#char=11,17>
        a                     nif:RFC5147String , nif:String ;
        nif:anchorOf          "Prague"^^xsd:string ;
        nif:beginIndex        "11"^^xsd:nonNegativeInteger ;
        nif:endIndex          "17"^^xsd:nonNegativeInteger ;
        nif:entity            <http://dkt.dfki.de/ontologies/nif#location> ;
        nif:geoPoint          "50.083333333333336_14.416666666666666"^^xsd:string ;
        nif:referenceContext  <http://dkt.dfki.de/documents/#char=0,26> ;
        itsrdf:taIdentRef     <http://dbpedia.org/resource/Prague> .

<http://dkt.dfki.de/documents/#char=0,26>
        a                    nif:RFC5147String , nif:String , nif:Context ;
        nif:beginIndex       "0"^^xsd:nonNegativeInteger ;
        nif:centralGeoPoint  "50.083333333333336_14.416666666666666"^^xsd:string ;
        nif:endIndex         "26"^^xsd:nonNegativeInteger ;
        nif:geoStandardDevs  "0.0_0.0"^^xsd:string ;
        nif:isString         "Welcome to Prague in 2016."^^xsd:string .');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}