-- Feb 22 In-Class Exercise Thread
d1="All the king's horses and all the king's men"
d2 = "Which is correct: all of the people, all the people, or all people?"
rankProximity processing:
Initially:
u = -infinity
nextCover("all", "the", -infinity) would give us [0:0,0:1]
Thus, [u, v] = [0, 1]
d = 0
score = 0
j = 0
Iterating through while loop:
1.
docid(u) = 0, d = 0
score += 1/(1-0+1) = 1/2
nextCover("all", "the", 0) would give us [0:1,0:5]
Thus, [u, v] = [1, 5]
2.
docid(u) = 0, d = 0
score += 1/(5-1+1) = 1/2 + 1/5 = 7/10
nextCover("all", "the", 1) would give us [0:5,0:6]
Thus, [u, v] = [3, 5]
3.
docid(u) = 0, d = 0
score += 1/(6-5+1) = 7/10 + 1/2 = 6/5 = 1.2
nextCover("all", "the", 5) would give us [1:3,1:5]
Thus, [u, v] = [3, 5]
4.
docid(u) = 1, d = 0
From if condition (d<docid(u)):
j = 1
Result[1].docid = 0
Result[1].score = 1.16
d = 1
score = 0
score += 1/(5-3+1) = 1/3
nextCover("all", "the", 3) would give us [1:5,1:7]
Thus, [u, v] = [5, 7]
5.
docid(u) = 1, d = 1
score += 1/(7-5+1) = 1/3 + 1/3 = 2/3
nextCover("all", "the", 7) would give us [1:7,1:8]
Thus, [u, v] = [7, 8]
6.
docid(u) = 1, d = 1
score += 1/(8-7+1) = 2/3 + 1/2 = 7/6
nextCover("all", "the", 7) would give us [1:8,1:11]
Thus, [u, v] = [8, 11]
7.
docid(u) = 1, d = 1
score += 1/(11-8+1) = 7/6 + 1/4 = 17/12
nextCover("all", "the", 8) would give us [infinity, infinity]
Thus, [u, v] = [infinity, infinity]
Exiting the while loop and checking the if condition (d<infinity),
j = 2
Result[2].docid = 1
Result[2].score = 17/12 = 1.46
Sorting Result by score and returning top 2 documents:
1. {docid: 1, score: 1.46}
2. {docid: 0, score: 1.2}
<pre>
d1="All the king's horses and all the king's men"
d2 = "Which is correct: all of the people, all the people, or all people?"
rankProximity processing:
'''Initially:'''
u = -infinity
nextCover("all", "the", -infinity) would give us [0:0,0:1]
Thus, [u, v] = [0, 1]
d = 0
score = 0
j = 0
'''Iterating through while loop:'''
1.
docid(u) = 0, d = 0
score += 1/(1-0+1) = 1/2
nextCover("all", "the", 0) would give us [0:1,0:5]
Thus, [u, v] = [1, 5]
2.
docid(u) = 0, d = 0
score += 1/(5-1+1) = 1/2 + 1/5 = 7/10
nextCover("all", "the", 1) would give us [0:5,0:6]
Thus, [u, v] = [3, 5]
3.
docid(u) = 0, d = 0
score += 1/(6-5+1) = 7/10 + 1/2 = 6/5 = 1.2
nextCover("all", "the", 5) would give us [1:3,1:5]
Thus, [u, v] = [3, 5]
4.
docid(u) = 1, d = 0
From if condition (d<docid(u)):
j = 1
Result[1].docid = 0
Result[1].score = 1.16
d = 1
score = 0
score += 1/(5-3+1) = 1/3
nextCover("all", "the", 3) would give us [1:5,1:7]
Thus, [u, v] = [5, 7]
5.
docid(u) = 1, d = 1
score += 1/(7-5+1) = 1/3 + 1/3 = 2/3
nextCover("all", "the", 7) would give us [1:7,1:8]
Thus, [u, v] = [7, 8]
6.
docid(u) = 1, d = 1
score += 1/(8-7+1) = 2/3 + 1/2 = 7/6
nextCover("all", "the", 7) would give us [1:8,1:11]
Thus, [u, v] = [8, 11]
7.
docid(u) = 1, d = 1
score += 1/(11-8+1) = 7/6 + 1/4 = 17/12
nextCover("all", "the", 8) would give us [infinity, infinity]
Thus, [u, v] = [infinity, infinity]
Exiting the while loop and checking the if condition (d<infinity),
j = 2
Result[2].docid = 1
Result[2].score = 17/12 = 1.46
Sorting Result by score and returning top 2 documents:
1. {docid: 1, score: 1.46}
2. {docid: 0, score: 1.2}
</pre>