Giter Site home page Giter Site logo

opennlp-service's People

Contributors

jpuck avatar rbehzadan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jpuck

opennlp-service's Issues

emoji in text body produces invalid JSON

consider this request:

curl http://localhost -d 'All of my drawing when I was an art major lol smh ๐Ÿ˜ญ'

results in this response:

{"sentences":[{"body":"All of my drawing when I was an art major lol smh \uD83D\uDE2D","chunks":[{"body":"All","end":1,"label":"NP","start":0},{"body":"of","end":2,"label":"PP","start":1},{"body":"my drawing","end":4,"label":"NP","start":2},{"body":"when","end":5,"label":"ADVP","start":4},{"body":"I","end":6,"label":"NP","start":5},{"body":"was","end":7,"label":"VP","start":6},{"body":"an art major lol smh \uD83D","end":13,"label":"NP","start":7}],"namedEntities":[],"parses":["(TOP (NP (NP (NP (DT All)) (PP (IN of) (NP (PRP$ my) (NN drawing)))) (SBAR (WHADVP (WRB when)) (S (NP (PRP I)) (VP (VBD was) (NP (DT an) (NN art) (JJ major) (NN lol) (NN smh))))) (. \uD83D\uDE2D)))"],"tokens":[{"body":"All","partOfSpeech":"DT"},{"body":"of","partOfSpeech":"IN"},{"body":"my","partOfSpeech":"PRP$"},{"body":"drawing","partOfSpeech":"NN"},{"body":"when","partOfSpeech":"WRB"},{"body":"I","partOfSpeech":"PRP"},{"body":"was","partOfSpeech":"VBD"},{"body":"an","partOfSpeech":"DT"},{"body":"art","partOfSpeech":"NN"},{"body":"major","partOfSpeech":"JJ"},{"body":"lol","partOfSpeech":"NN"},{"body":"smh","partOfSpeech":"NN"},{"body":"\uD83D","partOfSpeech":"NN"},{"body":"\uDE2D","partOfSpeech":"."}]}]}

which looks good at first. the emoji is correctly encoded in the JSON body attribute as \uD83D\uDE2D, however later on in the chunking process, it breaks the multibyte character in half (maybe because it views it as punctuation or something ๐Ÿคทโ€โ™‚ ) with:

{"body":"an art major lol smh \uD83D","end":13,"label":"NP","start":7}

and so the result that's returned for JSON encoding is just \uD83D which is no longer valid JSON. when trying to parse it with jq or even php's json_decode crashes with error:

parse error: Invalid \uXXXX\uXXXX surrogate pair escape at line 1, column 417

see also related issue: https://stackoverflow.com/a/42461709/4233593

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.