freme-project / freme-project.github.io

Apache License 2.0
2 stars 0 forks source link

[Tutorials] How to write tutorials - tilde example shows strange response #312

Closed bgrusdt closed 7 years ago

bgrusdt commented 8 years ago

The example API Call in the article how to write a Tutorial is a call to tilde/translation. Its response seems to be wrong:

{
  "@id" : "http://freme-project.eu/#char=0,44",
  "@type" : [ "nif:String", "nif:RFC5147String", "nif:Context" ],
  "beginIndex" : "0",
  "endIndex" : "44",
  "isString" : "Show%20me%20the%20source%20of%20the%20light.",
  "mtConfidence" : "0.387758945872871",
  "target" : {
    "@language" : "de",
    "@value" : "20 %20source%, 20 %20me%, 20, %20the%."
  },
  "@context" : {
    "target" : "http://www.w3.org/2005/11/its/rdf#target",
    "mtConfidence" : "http://www.w3.org/2005/11/its/rdf#mtConfidence",
    "isString" : "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#isString",
    "endIndex" : {
      "@id" : "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#endIndex",
      "@type" : "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
    },
    "beginIndex" : {
      "@id" : "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#beginIndex",
      "@type" : "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
    },
    "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "xsd" : "http://www.w3.org/2001/XMLSchema#",
    "itsrdf" : "http://www.w3.org/2005/11/its/rdf#",
    "rdfs" : "http://www.w3.org/2000/01/rdf-schema#",
    "nif" : "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#"
  }
}

The same call with Postman contains the translated sentence it its response:

 "@id": "http://freme-project.eu/#char=0,32",
  "@type": [
    "nif:String",
    "nif:RFC5147String",
    "nif:Context"
  ],
  "beginIndex": "0",
  "endIndex": "32",
  "isString": "Show me the source of the light.",
  "mtConfidence": "0.794227640429572",
  "target": {
    "@language": "de",
    "@value": "Zeigen sie mir ein Beispiel zu Folgen."
  },
jnehring commented 8 years ago

This is odd. When I do the API call in postman I get a proper translation "Zeigen sie mir ein Beispiel zu folgen", the tutorial shows something different: "20 %20source%, 20 %20me%, 20, %20the%.".

@andish can you please take a look at this tutorial?

andish commented 8 years ago

seems that here is double-escaped text submitted for translation.

andish commented 8 years ago

Here is a javascript function sendAPIRequest() containing an ajax method. As ajax post method do not override content-type , by default it is content-type: application/x-www-form-urlencoded, this means that there is no need to encode the input value.

So change encodeURIComponent($("#input").val()) to $("#input").val()

jnehring commented 8 years ago

@bgrusdt please try to update the code.

bgrusdt commented 7 years ago

Thank you, @andish for the explanation. It was the problem and is fixed now.