for match in re.finditer(r'\w+', text, re.UNICODE):
yield match.group(0)
parse, category_names = liwc.load_token_parser('LIWC2015_English_flat_decoded.dic')
tokens=tokenize(text.lower())
counts = Counter(category for token in tokens for category in parse(token))`
to get the counts. I have a valid .dic file saved under the same directory of the script. It ran fine on my windows machine. However, when i move the file and script to ubuntu and also installed the package using pip3 install -U liwc, it shows me below error:
File "predict.py", line 71, in liwc_convert parse, category_names = liwc.load_token_parser('LIWC2015_English_flat_decoded.dic') File "/home/ubuntu/.local/lib/python3.6/site-packages/liwc/__init__.py", line 21, in load_token_parser lexicon, category_names = read_dic(filepath) File "/home/ubuntu/.local/lib/python3.6/site-packages/liwc/dic.py", line 36, in read_dic with open(filepath) as lines: FileNotFoundError: [Errno 2] No such file or directory: 'LIWC2015_English_flat_decoded.dic'
But the truth is that i put the file right in the same directory of the script (here is predict.py). I don't understand why this happens. Can anybody help? I'm hitting a deadline for a competition. So if anyone who can help in a timely fashion, i highly appreciate it! Thank you!
---UPDATE----
This is not an issue any more! I'm an idiot! It turns out i have two versions of the files and i copied the other one to the server which is LIWC2015_English_Flat_decoded.dic but in my script, i referenced as LIWC2015_English_flat_decoded.dic. I'm closing this issue. Sorry for the confusion!
Hi all,
I used the sample code:
`def tokenize(text):
you may want to use a smarter tokenizer
to get the counts. I have a valid .dic file saved under the same directory of the script. It ran fine on my windows machine. However, when i move the file and script to ubuntu and also installed the package using
pip3 install -U liwc
, it shows me below error:File "predict.py", line 71, in liwc_convert parse, category_names = liwc.load_token_parser('LIWC2015_English_flat_decoded.dic') File "/home/ubuntu/.local/lib/python3.6/site-packages/liwc/__init__.py", line 21, in load_token_parser lexicon, category_names = read_dic(filepath) File "/home/ubuntu/.local/lib/python3.6/site-packages/liwc/dic.py", line 36, in read_dic with open(filepath) as lines: FileNotFoundError: [Errno 2] No such file or directory: 'LIWC2015_English_flat_decoded.dic'
But the truth is that i put the file right in the same directory of the script (here is
predict.py
). I don't understand why this happens. Can anybody help? I'm hitting a deadline for a competition. So if anyone who can help in a timely fashion, i highly appreciate it! Thank you!---
UPDATE
---- This is not an issue any more! I'm an idiot! It turns out i have two versions of the files and i copied the other one to the server which isLIWC2015_English_Flat_decoded.dic
but in my script, i referenced asLIWC2015_English_flat_decoded.dic
. I'm closing this issue. Sorry for the confusion!