简体   繁体   中英

Error in RAKE keyword extraction in python

I am using RAKE as instructed in this simple tutorial for keyword extraction from text.

However, I want to add a custom stopword file stopwords.txt (not the default one that is named as SmartStoplist.txt ). My code is as follows.

stoppath = "stopwords.txt"
rake_object = rake.Rake(stoppath)

for text in documents_list:
    print(rake_object.run(text))

However, when I try to run this it gives an error saying;

FileNotFoundError: [Errno 2] No such file or directory: 'SmartStoplist.txt'

They means their default stopword list, but I want to run it with my current stopword list that is named as stopwords.txt .

Please let me know how to fix this issue?

Within the RAKE-tutorial folder search for the file rake.py In line 29, set

test = False

The problem is that test is set to true, and this makes many of their default functionalities work. By setting it to false you can resolve your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM