based on question I posted on How to find documents from the list by term in the query (if atleast one query term exists in the documents of list), I want to ask other question. that is assume we have constant query and dynamic documents which is added to list from time to time. so I want to not view documents I seen before when the program is run and want to view only new documents added to list. from the list given here assume the first three documents are seen before and the left three are new added documents which I want to view. but still my program gives all related docs rather than new one. so share me an idea how to solve it? my code in python is as follow
queries = ['drug dosage form development Society', 'new drugs through activity evaluation of some medicinally used plants', 'Evaluation of drugs available on market for their quality, effectiveness']
docs = ['A Comparison of Urinalysis Technologies for Drugs Testing in Criminal Justice', 'development society and health care', 'buying drugs on the market without prescription may results in death', 'plants and their contribution in pharmacology', 'health care in developing countries','Herbal Drugs and hytopharmaceuticals','Neonatology: Management, Procedures, On-Call Problems, Diseases, and Drugs' ]
words = {}
for index, doc in enumerate(lines):
for word in cleanDoc(doc.split(" ")):
if not word or word==" ":
pass
elif not word in words: words[word]=[index]
elif index not in words[word]: words[word].append(index)
for query in queries:
matches = []
map(lambda x: matches.extend(words[x]), filter(lambda x: x in query, words))
if matches:# list(set(matches)):
for i in list(set(matches)):
viewed =[]
if len(lines[i])> 1:
pass
if all_docs[i] not in viewed:#viewed is empty for now (first time the program is run)
print str(all_docs[i])#print all related docs from list
viewed.append(all_docs[i]) #add printed docs to viewed and viewed should not be empty next time program is run(my assumption)
else:
print "No new document for now"
ch = raw_input("do you want again results you have viewed before? Y/N ")
if ch == 'yes' or 'YES' or 'Yes' or 'y' or 'Y':
print viewed
else:
sys.exit()
else:
print "No related document"
