Giter Site home page Giter Site logo

Comments (11)

fmikaelian avatar fmikaelian commented on July 23, 2024 1

@mamrou

The issue was due to the fact that JSON.stringify(this.json) (function that is supposed to convert a JSON object to a JSON string) converts special characters like - or " into characters that are not JSON compliant. To avoid this I followed the SO links above to create a computed property named valid_json that post-process the JSON file after JSON.stringify() by replacing non-compliant characters by their unicode equivalents. This makes the JSON file valid:

    valid_json: function () {
      var json = JSON.stringify(this.json).replace(/[\u007F-\uFFFF]/g, function(chr) {
          return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
      })
      return json
    }

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

Hi @mamrou

  • What code did you use to load the json file?
  • Can you load the original input json file (before annotations)?

from cdqa-annotator.

mamrou avatar mamrou commented on July 23, 2024

Hi @fmikaelian

  • a classic with open('output.json') as json_file: bnp_data = json.load(json_file)
  • Yes, there is no issue when loading the original input file before annotations.

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

It seems it is an encoding error due to the followinf character: http://www.hexadecimaldictionary.com/hexadecimal/0xAC/. Maybe the annotator does not encode the question / answers with the correct format. We could compare squad json and our custom annotated json types to see where we are wrong?

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

If you load the original json, do nothing and export it directly, can you read the output?

from cdqa-annotator.

mamrou avatar mamrou commented on July 23, 2024

Same encoding error message as above.

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

Ok. Could you run a diff between original file and output file (without annotations)?

See https://stackoverflow.com/questions/30139597/visual-studio-code-is-there-a-compare-feature-like-that-plugin-for-notepad

from cdqa-annotator.

mamrou avatar mamrou commented on July 23, 2024

I run a diff between the two json to spot potential tracks of failure. What I can say is that the encoding of some specific punctuations or characters (like `, ' or ) may be at the origin of the issue.
I will clean the original json from all those special characters and punctuations and keep you posted about the result.

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

Could we just encode the output json with the same format as input directly in the annotator? Do you know what is the encoding format of the input SQuAD? Maybe we can find this info online?

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

vscode report the following error for many lines in the output json: Invalid characters in string. Control characters must be escaped.json(262)

from cdqa-annotator.

fmikaelian avatar fmikaelian commented on July 23, 2024

from cdqa-annotator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.