Git Product home page Git Product logo

Comments (11)

lukedorney avatar lukedorney commented on May 18, 2024 1

a quick workaround is explicitly stating the encoding as being utf-8 in corpus.py line 37 i.e. change
with open(self.datadir+category+'.txt') as fin:
to
with open(self.datadir+category+'.txt', encoding='utf-8') as fin:
although this only works with python 3 (with py2 you'd need to use codecs)

from sacremoses.

alvations avatar alvations commented on May 18, 2024

Interesting, Windows is reading it as cp1252 instead of utf8. Are you using Python 3 or 2?

from sacremoses.

janwendt avatar janwendt commented on May 18, 2024

3.6

from sacremoses.

alvations avatar alvations commented on May 18, 2024

Very interesting now!

Looks like an upsteam bug/feature in CPython vs Windows... https://stackoverflow.com/questions/42070668/python-3-default-encoding-cp1252

My suggestion is to set the proper locale before the Python interpreter.

If you're on cygwin: https://stackoverflow.com/questions/24255407/permanently-set-python-path-for-anaconda-within-cygwin

If natively and globally on windows, see https://www.java.com/en/download/help/locale.xml

from sacremoses.

alvations avatar alvations commented on May 18, 2024

BTW, do you get the same when you import nltk?

from sacremoses.

sleighsoft avatar sleighsoft commented on May 18, 2024

I have the same issue. But not when importing nltk

from sacremoses.

alvations avatar alvations commented on May 18, 2024

Are you using Windows too?

from sacremoses.

sleighsoft avatar sleighsoft commented on May 18, 2024

Yes, Windows 10. Python 3.6.5

from sacremoses.

alvations avatar alvations commented on May 18, 2024

@lukedorney Hmmm.. It's weird that in Python3 the default encoding is already utf8 but Windows is doing something strange in the locale such that it's not the default.

from sacremoses.

alvations avatar alvations commented on May 18, 2024

@lukedorney @janwendt @sleighsoft I've added the patch and updated the package.

Please tell me if you still face the same problems after

pip install -U sacremoses

from sacremoses.

alvations avatar alvations commented on May 18, 2024

Going to close this issue. If there's any error in Windows from encoding problems again, please feel free to reopen this issue.

from sacremoses.

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.