Long days to see you (Python ) :)

My friend gave me a task on python

Ques :

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.

So i feel to try this . 🙂

file1 consits of words arranged like this




and in second file too

search for most repeated word that not found in second file 🙂

My python programing is this

import sys
file1 = open("file1.txt","r")
file2 = open("file2.txt","r")
b1 = []
file1_words = []
b2 = []
for line in file1:
for line in file2:
b3 = [val for val in b2 if val in b1]
#print b1
var = 1
while var == 1:
	for line in b3:
if line in b1:
		     var = 0
                	#print b1
for line in b1:
counter = 1for item in set(b1):
if file1_value.count(item) > counter:
print "%s - %d times" % (item,counter+1)
print "tolal word that not found in in file2 is "
print  len(file1_value)

output :
[sathia@sathia]$ python task.py
red – 2 time
sit – 3 times
tolal word that not found in in file2 is 17


About sathia

Web developer at cloudmint
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Long days to see you (Python ) :)

  1. yogeshkannan says:

    kalakura machi!!!!!!!!!!!!

  2. V.Ramachandran says:

    Great. Nice work..
    Keep rocking…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s