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

KeyError: 8 German 2001 .dic #16

Open
vicru opened this issue Sep 6, 2021 · 1 comment
Open

KeyError: 8 German 2001 .dic #16

vicru opened this issue Sep 6, 2021 · 1 comment

Comments

@vicru
Copy link

vicru commented Sep 6, 2021

Hi,
has anybody used the German 2001 .dic with this library? I am getting "KeyError: 8" when I try to load the lexicon.

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

Originally posted by @vicru in #15 (comment)

@Hadjimina
Copy link

Hi

You need to make sure that in you dic that you provide the gap between expression and group is not made up of spaces but of one single tab. That goes also for when you have one expression assigned to multiple groups. You can use an editor like vs code to see where you have space and where you have tabs, as you will not be able to see it solely by looking at it since both are whitespace.

Right:
image

Wrong:
image

Basically, try to not have any spaces anywhere in your dic file and only use single tabs. Let me know if this works, though I just realised that this is a super old issue 😅.

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