tags:

views:

73

answers:

0

A portion of our project is included here..plagiarism detector.. we are trying to extract common keywords from two input files by comparing each word in file with a database.we created the database and we were able to take word by word from the file and also each row from the table(keyword). now our problem is that the while loop is not working.. its for comparing the rows and each word in file..

import sys
import MySQLdb
import string
dbmod = MySQLdb

conn = MySQLdb.connect (host = "localhost",
                           user = "root",
                           passwd = "1234",
                           db = "mydb")
cursor = conn.cursor ()
cursor.execute ("SELECT * from keyword")
rows = cursor.fetchall()
numrows = cursor.rowcount
print numrows
a=raw_input("Enter the file name:")
s=open(a,"r")
str1=s.read()
word_list1=str1.split(None)
status1=[0]*len(word_list1)
b=raw_input("Enter the file name:")
p=open(b,"r")
str2=p.read()
word_list2=str2.split(None)
status2=[0]*len(word_list2)
cursor.execute ("SELECT * from keyword")
row = cursor.fetchall()
cnt=0
**while cnt<numrows:               #not entering into the while loop
    #print row[cnt]
    i=0
    for word in word_list1:
        if row[cnt]==word_list1[i] and status1[i]==0:
            status1[i]=1
            print word_list1[i]
        i+=1    
    j=0
    for word in word_list2:
        if row[cnt]==word_list2[j] and status2[j]==0:
            status2[j]=1
            print word_list2[j]
        j+=1
    cnt+=1**
i=0
for word in word_list1:
    if status1[i]==0:
        print word_list1[i],status1[i]
    i+=1    
j=0
for word in word_list2:
    if status2[j]==0:
        print word_list2[j]
    j+=1
cursor.close ()
conn.close ()