Calculate the appropriate weight for each query term, Programming Languages

Assignment Help:

1-Create ir3.py based on ir2.py

2-Repeatedly prompt the user for a query (if they enter "q", then quit)

3-Find the terms in the query, and calculate the appropriate weight for each query term

• (hint:) : weight for query = log2 (total number of doc / number of times the word appear in all the Doc).

• weight for query =((log( float( len( documents) ) / docfreq [ term ] ))/log(2))

• the Output for the query ""quick brown vex zebras""should be :

Doc name

Term

Weights

Q

Quick

0.58

Q

Brown

1.58

Q

Vex

0.58

Q

Zebras

1.58

4-Calculate the similarity for each query/document pair

(hint:) : the similarity= Q * D1 / |Q||D1| for example :

2361_Calculate the appropriate weight for each query term.png

5-List the documents in order of decreasing similarity to the query, along with their similarity value

• Your results for "quick brown vex zebras" should be:

D1.txt 0.42, D3.txt 0.33, D2.txt 0.08

7-Make sure that querying "quick brown vex zebras" a 2nd time gives the same result

8-What is the result for the query "quick brown vex lion"?

Genral Hint :

• For user Input :
while True:
querystring = raw_input( '\nEnter query (q to quit): ' )
if querystring == 'q':
print '\nGoodbye!\n'
break
...do more stuff...

• To sort a dictionary in descending order by value from operator import itemgetter
items = results.items()
items.sort( key = itemgetter(1), reverse=True )
for (document, ranking) in items:
print document, "%.2f" % ranking


Related Discussions:- Calculate the appropriate weight for each query term

Program to output a triangle wave, 1.) Write a flowchart and program to do ...

1.) Write a flowchart and program to do the following: A pressure sensor in a cooling system measures the pressure of the refrigerant and is connected to Port -1 of the 8051. If th

What is linear programming problem, QUESTION 1 (a) (i) What is linear p...

QUESTION 1 (a) (i) What is linear programming problem? (ii) Define and explain the following terms: (1) objective function, (2) decision variable, (3) constraints, (4) feasi

Difference between CMP and SUB, 1. CMP and SUB CMP is used for comparing 2 ...

1. CMP and SUB CMP is used for comparing 2 registers by subtraction them from one another, but answer is not saved, whereas SUB subtracts 2 registers and saves the answer.

Developing a preprocessor for java, How and where to start to develop a pre...

How and where to start to develop a preprocessor for java

Design and implement a character analyser, Your task is to write an applica...

Your task is to write an application to analyse texts in a file.  Your application will employ  several kinds of text-analyser objects (which you also have to implement)  as descri

Assembly Language Programming, Complete the following program to move a val...

Complete the following program to move a value of 0xFFH to PORTB LIST p=18f4550 #include org 0x0000 movlw 0x00 _________ movlw 0xFF movwf PORTB end .

Lisp and Prolog, Is there one can help me in the language Lisp and Prolog

Is there one can help me in the language Lisp and Prolog

Use loop invariant to prove the working of the program, 1.  Use mathematica...

1.  Use mathematical induction to prove Whenever n is a positive integer. 2.  Use loop invariant to prove that the program for computing the sum of 1,...,n is correct.

Python 2.7.3, I have assignment about python language . Could you helpe me ...

I have assignment about python language . Could you helpe me to built it

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd