Python Forum
Omit pronoun/common words when searching in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Omit pronoun/common words when searching in Python
#1
I have a python program to count most appearing words in a file. Now I want to omit most common words from the file. I have written 2 program for this. How can combine them or call internally?

--Snippet of code

def order_bag_of_words(bag_of_words, desc=False):
    words = [(word, cnt) for word, cnt in bag_of_words.items()]
    return sorted(words, key=lambda x: x[1], reverse=desc)
-- snippet of stop words

from nltk.corpus import stopwords
from nltk.tokenize import wordpunct_tokenize

stop_words = set(stopwords.words('english')) # creating a set makes the 
searching faster
print (stop_words)
Reply
#2
So you have a way to get words you want to ignore. And you have a way to sort words. I'm confused on what you need help with, isn't that everything?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code for Longest Common Subsequence Bolt 3 910 Sep-22-2023, 08:09 AM
Last Post: Bolt
  Python implementation of Longest Common Substring problem Bolt 0 531 Sep-17-2023, 08:31 PM
Last Post: Bolt
  python-docx regex : Browse the found words in turn from top to bottom Tmagpy 0 1,488 Jun-27-2022, 08:45 AM
Last Post: Tmagpy
  Generate a string of words for multiple lists of words in txt files in order. AnicraftPlayz 2 2,756 Aug-11-2021, 03:45 PM
Last Post: jamesaarr
  How do I change this code for searching duplicats in python ? Eidrizi 0 1,486 Mar-17-2021, 01:34 PM
Last Post: Eidrizi
  Voynich search engine in python using dashes & dot totals to find Italian words Pleiades 3 3,440 Oct-10-2019, 10:04 PM
Last Post: Pleiades
  Compare words Python xSphere 3 2,553 Jan-24-2019, 10:52 AM
Last Post: perfringo
Photo How to Extract Specific Words from PDFs with Python danvsv 1 4,492 Jan-17-2019, 11:07 AM
Last Post: Larz60+
  searching file for unique words Siylo 2 2,473 Nov-20-2018, 08:28 PM
Last Post: wavic
  Compare all words in input() to all words in file Trianne 1 2,716 Oct-05-2018, 06:27 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020