Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with 'utf-8' encoding #15

Open
murgado opened this issue Jul 2, 2021 · 4 comments
Open

Dealing with 'utf-8' encoding #15

murgado opened this issue Jul 2, 2021 · 4 comments

Comments

@murgado
Copy link

murgado commented Jul 2, 2021

Hello there!
I'm dealing with a .dic file containing special characters such as "ñ" or "í", the problem lies whenever I do have to read such dictionary.

As an example: I do have the word "abadía" in my corpus and whenever I read it with liwc it appears as : "abadÃ\xada".
How could I deal with this?
Thank you very much in advance.

@murgado
Copy link
Author

murgado commented Jul 2, 2021

I've managed to solve this issue myself by accessing to the liwc/liwc/dic.py file and changing the read_dic(filepath) method to read my file using the utf-8 encoding.

@vicru
Copy link

vicru commented Sep 6, 2021

I've managed to solve this issue myself by accessing to the liwc/liwc/dic.py file and changing the read_dic(filepath) method to read my file using the utf-8 encoding.

Thank you for sharing your own solution. I would appreciate if you provided the details about it.
I just added encoding='utf-8' to liwc/liwc/dic.py, but apparently that is not right, because I keep getting "KeyError: '8'"
with open(filepath, encoding='utf-8') as lines:

By the way, I am trying to use this library not with a Spanish but with a German (from 2001) version. That is why I think your suggested solution might make this library work with the German 2001 .dic

@murgado
Copy link
Author

murgado commented Sep 6, 2021

I've managed to solve this issue myself by accessing to the liwc/liwc/dic.py file and changing the read_dic(filepath) method to read my file using the utf-8 encoding.

Thank you for sharing your own solution. I would appreciate if you provided the details about it.
I just added encoding='utf-8' to liwc/liwc/dic.py, but apparently that is not right, because I keep getting "KeyError: '8'"
with open(filepath, encoding='utf-8') as lines:

By the way, I am trying to use this library not with a Spanish but with a German (from 2001) version. That is why I think your suggested solution might make this library work with the German 2001 .dic

That's exactly what we did, I noticed that by applying that tiny change our code worked but I'm not sure If maybe it should also be changed somewhere else. Have you debuggered your code?

@vicru
Copy link

vicru commented Sep 7, 2021

I've managed to solve this issue myself by accessing to the liwc/liwc/dic.py file and changing the read_dic(filepath) method to read my file using the utf-8 encoding.

Thank you for sharing your own solution. I would appreciate if you provided the details about it.
I just added encoding='utf-8' to liwc/liwc/dic.py, but apparently that is not right, because I keep getting "KeyError: '8'"
with open(filepath, encoding='utf-8') as lines:
By the way, I am trying to use this library not with a Spanish but with a German (from 2001) version. That is why I think your suggested solution might make this library work with the German 2001 .dic

That's exactly what we did, I noticed that by applying that tiny change our code worked but I'm not sure If maybe it should also be changed somewhere else. Have you debuggered your code?

Thank you very much for your quick reply. I actually haven't debugged the code. I don't find another solution for that, I will do that and post a reply.

By the way, I faced exactly the same situation with another LIWC python library and open an issue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants