Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:35:20+00:00 2026-06-02T09:35:20+00:00

I have a python dict that looks like: defaultdict(<type ‘int’>, {u’RT’: 1, u’be’: 1,

  • 0

I have a python dict that looks like:

defaultdict(<type 'int'>, {u'RT': 1, u'be': 1, u'uniforms': 1, u'@ProFootballWkly:': 1, u'in': 1, u'Nike': 1, u'Brooklyn.': 1, u'ET': 1, u"NFL's": 1, u'will': 1, u'a.m.': 1, u'at': 1, u'unveiled': 1, u'Jimmy': 3, u'11': 1, u'new': 1, u'The': 2, u'today': 1})

I’m processing it with:

freq_distribution = nltk.FreqDist(filtered_words)               
top_words = freq_distribution.keys()[:4]     
print top_words                 

This outputs the top 4 words which includes the word “The” I am trying to incorporate removal of Dolch “commonly used” words before this process happens with:

filtered_words = [w for w in word_count \
              if not w in stopwords.words('english')]

The problem is that I still end up with the word “The” because all of the (stopwords) from NLTK are lowercase. I need a way to take the input of word_count and switch it to lower case. I have tried adding lower() in various areas such as:

freq_distribution = nltk.FreqDist(word_count.lower())

But have not had any success, as I repeatedly get the following error:

AttributeError: 'list' object has no attribute 'lower'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:35:23+00:00Added an answer on June 2, 2026 at 9:35 am
    filtered_words = [w for w in word_count \
              if w.lower() not in stopwords.words('english')]
    

    This lowercases w before checking whether it’s in the stopwords list. So if w is “The”, it will be transformed to the before checking. Since “the” is in the list, it will get filtered out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python 2.x module.py file that looks like this: class A(object): KEYWORD
I have a dict of configuration variables that looks something like this: self.config =
Say I have a string that looks like this: str = The &yquick &cbrown
When using Python is it possible that a dict can have a value that
I have a string that looks like this: Name1=Value1;Name2=Value2;Name3=Value3 Is there a built-in class/function
So I have a python dict like: 1:[ red,blue,green] 2: [blue,blue,red].. and so on.
I have Python nested list that I'm trying to organize and eventually count number
so i've begun google's python class, and have not had that much difficulty with
I have a python class hierarchy, that I want to extend at runtime. Furthermore
I have a python script that parses an XML file that contains part information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.