appending nltk stopwords to a file of stopwords

Tags:
nltk
Python
I have a file of stopwords and would like to add them to the nltk list of stop words. How do I do it?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
To add words to it:

stopwords = nltk.corpus.stopwords.words(‘english’)
stopwords.append(‘newWord’)

or extend to append a list of words

stopwords = nltk.corpus.stopwords.words(‘english’)
newStopWords = [‘stopWord1′,’stopWord2’]
stopwords.extend(newStopWords)

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen

    Try Append method to add words to it. It is better for your purpose would be to wrap the stop_words in a class that maintains the state of the list through the lifetime of the program. You can simply use the append method to add words to it:

    130,580 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: