Giter Site home page Giter Site logo

Comments (5)

dan-blanchard avatar dan-blanchard commented on June 5, 2024

Detection for small strings in general is pretty flakey, as the algorithm is intended to work on larger samples. That said, I'm surprised to see the output is so different between major Python versions. Thanks for bringing that to our attention.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 5, 2024

Hey @mitya57 thanks for reporting this. I just want you to realize that both @dan-blanchard and I are the maintainers and we both have a lot of other responsibilities and very little time to devote to chardet. If you wait for us to attempt to fix this, it will probably be a big wait time. If you have time to spare and care to investigate this, you would be really accelerating how quickly this is fixed.

Cheers

from chardet.

mitya57 avatar mitya57 commented on June 5, 2024

Hmm, looks like Python 2.7 has some problems with interpreting unicode given inside -c argument. Replacing é with its \xe9 equivalent gives me a behaviour that is consistent between Python 2 and Python 3, but still inconsistent between one-char and two-chars strings.

$ python2.7 -c "import chardet; print(chardet.detect(u'\xe9'.encode('utf-8')))"
{'confidence': 0.73, 'encoding': 'windows-1252'}
$ python3.4 -c "import chardet; print(chardet.detect(u'\xe9'.encode('utf-8')))"
{'confidence': 0.73, 'encoding': 'windows-1252'}
$ python2.7 -c "import chardet; print(chardet.detect(u'\xe9\xe9'.encode('utf-8')))"
{'confidence': 0.7525, 'encoding': 'utf-8'}
$ python3.4 -c "import chardet; print(chardet.detect(u'\xe9\xe9'.encode('utf-8')))"
{'confidence': 0.7525, 'encoding': 'utf-8'}

from chardet.

dan-blanchard avatar dan-blanchard commented on June 5, 2024

@mitya57 That makes a lot more sense. I didn't think about the fact that you were calling it from the command-line with -c before.

Anyway, the difference in results between one and two character strings is to be expected. The more data you give it, the more accurate it will be, so it is wrong for one-character and correct for two characters.

from chardet.

mitya57 avatar mitya57 commented on June 5, 2024

OK, that's understandable.

Actually I filed this issue because currently beautifylsoup4's tests fail with an error, I will now file a pull request against beautifulsoup4 to use double \xe9 in their tests instead of a single.

from chardet.

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.