Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given a text file (FILE1) with lots of words (ex, an ebook),
and another file (FILE2) with a list of blacklist words
(slangs, porn, etc.), write a program to find the top 100
words(most frequent 100 words) from FILE1 which are not
present in FILE2.

Answer Posted / siva kumar reddy dandu

Steps to solve this.
1. open FILE1 in read mode
2. read content by using read()
3 split content by using
so that you can get lines
4 split lines by split(' ') so that you can get words
5 repeat above 4 lines with file FILE2
6 iterate words list and create dictionary word and frequency as key values.
skip the value if it is found in file2 key words.
7 sort dict by using x= list(sorted(wordsarr.items(),wordsarr.get, reverse=true)
so that we can get sorted dict in desc order.
8 return top 100 words by using print(x[:101])

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Boolean have 2 possible values. Are there types in python that have 3 possible values?

936


Is there any way to kill a thread in python?

910


Explain python’s pass by references vs pass by value. (Or) explain about python’s parameter passing mechanism?

877


How will you capitalize the first letter of string?

1533


When should you use the “break” in python?

955


What is enumerate python?

902


Give the output of this example: a[3] if a=[1,4,6,7,9,66,4,94].

766


Can we develop a web application using Python

865


How is unit test done in python?

901


What is sockets? Explain.

938


What is the incorrect declaration of a set?

985


What is the purpose of the single underscore “_” variable in python?

922


When does dictionary is used instead of a list in python?

886


Why do I receive a syntax error when printing a string in python 3?

1057


Is python a single inheritance?

814