hey i am a beginner as far as python is concerned..i am having diff in understanding this code..i am supp to do it in python..if anyone can tell me wht it does it wud be really helpful

for qid,query in "as2.qrys": 
       for word in query: 
         docs = set(index[word]) 
         for doc in docs: 
           number_of_matched_words [doc] ++ 
       for doc in matches: 
         if number_of_matched_words[doc] == length(query): 
           print qid, 0, doc, 0, 1, 0

Recommended Answers

All 3 Replies

i am having diff in understanding this code..i am supp to do it in python

for qid,query in "as2.qrys": 
       for word in query: 
         docs = set(index[word]) 
         for doc in docs: 
           number_of_matched_words [doc] ++ 
       for doc in matches: 
         if number_of_matched_words[doc] == length(query): 
           print qid, 0, doc, 0, 1, 0

Is this psuedo-code that you're supposed to translate into Python?

yes....its v similar to python. i am not sure however what matches exactly contains.....index is a dictionary which has words as keys and document numbers that contain words as the values...ie index = {tracl:["num1","num2","num3"...],field:[.....],...} ... i have been given a test list from which i have to take all words and compare with the index and find out documents which contain the words

Maybe you should give your thread a more meaningful title.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.