chbrown / liwc-python

Linguistic Inquiry and Word Count (LIWC) analyzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Key Error (revisted!)

altanner opened this issue · comments

Hello,
Thanks for providing these scripts. I know you've closed this issue before but I am also getting a key error. I get why it is erroring, in that it doesn't like lines with unusual structure and symbols I guess. But does it normally deal with them fine? Here is the traceback:

at9362$ python3 example.py 
Traceback (most recent call last):
  File "example.py", line 10, in <module>
    parse, category_names = liwc.load_token_parser('LIWC2007_English100131.dic')
  File "python/liwc/__init__.py", line 76, in load_token_parser
    lexicon, category_names = read_dic(filepath)
  File "python/liwc/__init__.py", line 27, in read_dic
    lexicon[parts[0]] = [category_mapping[category_id] for category_id in parts[1:]]
  File "python/liwc/__init__.py", line 27, in <listcomp>
    lexicon[parts[0]] = [category_mapping[category_id] for category_id in parts[1:]]
KeyError: '<of>131/125'

Grateful for any help :)

Taking out two lines (one with "<" in it, one with "(" in it) solves the issue - but I am still interested in how this is working for others without deleting those two lines from the dictionary.

sed -i -e '/[<(]/d' LIWC2007_English100131.dic
fixes things for me.

btw, how to fix a similar bug when I load the 2015 dictionary?

thx

Hi! I believe this is a duplicate of #3 at this point (not that #3 is solved, but for consolidation).

Please open a new issue (albeit yet another 😉) if you encounter any problems aside from the two caveats in #3 (comment)

@altanner @chbrown I may have to keep those two lines especially for

like (02 134)125/464 (02 134)126 (02 134)126 253

@chbrown Btw, I encountered this issue with a 2007 version of .dic