QAnswer

QAnswer

  • Docs
  • API
  • Community
  • Blog

›Tutorial (API)

Introduction

  • Introduction

Quick Intro

  • Create a Playground
  • Create our first node
  • Create our first relation
  • My creativity ....
  • Learning a bit ....
  • Making it prettier
  • Free me in the WWW

Tutorial (UI)

  • Part 1 (RDF to QA)
  • Part 2 (Signup and Login)
  • Part 3 (Upload and index)
  • Part 4 (Query)
  • Part 5 (Feedback and train)
  • Part 6 (Contextual information)
  • Part 7 (Additional services)

Tutorial (API)

  • Part 1 (API)
  • Part 2 (Signup and Login)
  • Part 3 (Upload and index)
  • Part 4 (Query)
  • Part 5 (Feedback and train)
  • Part 6 (Contextual information)
  • Part 7 (Additional services)

Requirements

  • Requirements
  • Requirement 1
  • Requirement 2
  • Requirement 3 (Optional)

Terms of Use

  • Terms of use

Tutorial: Upload and index

Now you are ready to upload your first dataset. The cocktail dataset can be downloaded here: cocktails.nt. To upload a new dataset you can use one of the following code snippets (remember to use the Bearer Token that you get at Signin Part 2):

cURL
Java
JavaScript
curl -X POST \
'https://qanswer-core1.univ-st-etienne.fr/api/dataset/upload?dataset=cocktails' \
-H 'Authorization: Bearer eyJhbGciOiJIUz .....' \
-F file=@/path/to/file/cocktails.nt
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"cocktails.nt\"\r\nContent-Type: false\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
.url("https://qanswer-core1.univ-st-etienne.fr/api/dataset/upload?dataset=cocktails")
.post(body)
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ....")
.build();

Response response = client.newCall(request).execute();
var form = new FormData();
form.append("file", "/path/to/file/cocktails.nt");

var settings = {
"async": true,
"crossDomain": true,
"url": "https://qanswer-core1.univ-st-etienne.fr/api/dataset/upload?dataset=cocktails",
"method": "POST",
"headers": {
"Authorization": "Bearer eyJhbGciOiJIUzUxMi......",
},
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form
}

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




IMPORTANT: The dataset must be in N-Triple format and must be syntactically correct. You can both check and clean a file using serdi

serdi -i ntriples -o ntriples dump.nt > dump_clean.nt



After uploading the dataset it needs to be indexed. This can be done with the following code snippets:

cURL
Java
JavaScript
curl -X POST \
'https://qanswer-core1.univ-st-etienne.fr/api/dataset/index?dataset=cocktails' \
-H 'Authorization: Bearer eyJhbGciOiJIUzUxMi....' \
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
.url("https://qanswer-core1.univ-st-etienne.fr/api/dataset/index?dataset=cocktails")
.post(null)
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ....")
.build();

Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://qanswer-core1.univ-st-etienne.fr/api/dataset/index?dataset=cocktails",
"method": "POST",
"headers": {
"Authorization": "Bearer eyJhbGciOiJIUzUx.....",
}
}

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

The dataset is now ready to be queried!

← Part 2 (Signup and Login)Part 4 (Query) →
Docs
Getting StartedAPI ReferenceTerms of use
Community
Twitter
More
GitHubStar
Us
Imprint
Copyright © 2021 QAnswer