retreval 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,606 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: TestQueryResult</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="./js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="./js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="./test/test_query_result_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="test/test_query_result.rb">test/test_query_result.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Test::Unit::TestCase</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-i-add_ranked_query_result">#add_ranked_query_result</a></li>
73
+
74
+ <li><a href="#method-i-add_test_judgements">#add_test_judgements</a></li>
75
+
76
+ <li><a href="#method-i-add_unranked_query_result">#add_unranked_query_result</a></li>
77
+
78
+ <li><a href="#method-i-test_eleven_point_precision">#test_eleven_point_precision</a></li>
79
+
80
+ <li><a href="#method-i-test_ranked_precision">#test_ranked_precision</a></li>
81
+
82
+ <li><a href="#method-i-test_ranked_recall">#test_ranked_recall</a></li>
83
+
84
+ <li><a href="#method-i-test_unranked_precision">#test_unranked_precision</a></li>
85
+
86
+ <li><a href="#method-i-test_unranked_recall">#test_unranked_recall</a></li>
87
+
88
+ </ul>
89
+ </div>
90
+
91
+
92
+ <!-- Included Modules -->
93
+
94
+ </div>
95
+
96
+ <div id="project-metadata">
97
+
98
+
99
+ <div id="fileindex-section" class="section project-section">
100
+ <h3 class="section-header">Files</h3>
101
+ <ul>
102
+
103
+ <li class="file"><a href="./CHANGELOG.html">CHANGELOG</a></li>
104
+
105
+ <li class="file"><a href="./TODO.html">TODO</a></li>
106
+
107
+ </ul>
108
+ </div>
109
+
110
+
111
+ <div id="classindex-section" class="section project-section">
112
+ <h3 class="section-header">Class Index
113
+ <span class="search-toggle"><img src="./images/find.png"
114
+ height="16" width="16" alt="[+]"
115
+ title="show/hide quicksearch" /></span></h3>
116
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
117
+ <fieldset>
118
+ <legend>Quicksearch</legend>
119
+ <input type="text" name="quicksearch" value=""
120
+ class="quicksearch-field" />
121
+ </fieldset>
122
+ </form>
123
+
124
+ <ul class="link-list">
125
+
126
+ <li><a href="./Retreval.html">Retreval</a></li>
127
+
128
+ <li><a href="./Retreval/Document.html">Retreval::Document</a></li>
129
+
130
+ <li><a href="./Retreval/GoldStandard.html">Retreval::GoldStandard</a></li>
131
+
132
+ <li><a href="./Retreval/Judgement.html">Retreval::Judgement</a></li>
133
+
134
+ <li><a href="./Retreval/Options.html">Retreval::Options</a></li>
135
+
136
+ <li><a href="./Retreval/Query.html">Retreval::Query</a></li>
137
+
138
+ <li><a href="./Retreval/QueryResult.html">Retreval::QueryResult</a></li>
139
+
140
+ <li><a href="./Retreval/QueryResultSet.html">Retreval::QueryResultSet</a></li>
141
+
142
+ <li><a href="./Retreval/RankedQueryResult.html">Retreval::RankedQueryResult</a></li>
143
+
144
+ <li><a href="./Retreval/ResultDocument.html">Retreval::ResultDocument</a></li>
145
+
146
+ <li><a href="./Retreval/Runner.html">Retreval::Runner</a></li>
147
+
148
+ <li><a href="./Retreval/UnrankedQueryResult.html">Retreval::UnrankedQueryResult</a></li>
149
+
150
+ <li><a href="./Retreval/User.html">Retreval::User</a></li>
151
+
152
+ <li><a href="./TestGoldStandard.html">TestGoldStandard</a></li>
153
+
154
+ <li><a href="./TestQueryResult.html">TestQueryResult</a></li>
155
+
156
+ </ul>
157
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
158
+ </div>
159
+
160
+
161
+ </div>
162
+ </div>
163
+
164
+ <div id="documentation">
165
+ <h1 class="class">TestQueryResult</h1>
166
+
167
+ <div id="description">
168
+ <p>
169
+ Some basic unit tests for QueryResult Unranked results include 4 documents
170
+ of 10, which are all retrieved. The ranked results are evaluated from this
171
+ table:
172
+ </p>
173
+ <pre>
174
+ Index Relevant Precision Recall Document ID
175
+ 1 [X] 1.000 0.250 doc1
176
+ 2 [X] 1.000 0.500 doc2
177
+ 3 [ ] 0.667 0.500 doc5
178
+ 4 [X] 0.750 0.750 doc3
179
+ 5 [ ] 0.600 0.750 doc6
180
+ 6 [X] 0.667 1.000 doc4
181
+ 7 [ ] 0.571 1.000 doc7
182
+ 8 [ ] 0.500 1.000 doc8
183
+ 9 [ ] 0.444 1.000 doc9
184
+ 10 [ ] 0.400 1.000 doc10</pre>
185
+
186
+ </div>
187
+
188
+ <!-- Constants -->
189
+
190
+
191
+ <!-- Attributes -->
192
+
193
+
194
+ <!-- Methods -->
195
+
196
+ <div id="public-instance-method-details" class="method-section section">
197
+ <h3 class="section-header">Public Instance Methods</h3>
198
+
199
+
200
+ <div id="add-ranked-query-result-method" class="method-detail ">
201
+ <a name="method-i-add_ranked_query_result"></a>
202
+
203
+ <div class="method-heading">
204
+
205
+ <span class="method-name">add_ranked_query_result</span><span
206
+ class="method-args">()</span>
207
+ <span class="method-click-advice">click to toggle source</span>
208
+
209
+ </div>
210
+
211
+ <div class="method-description">
212
+
213
+ <p>
214
+ Adds the ranked query results to be tested against to this test case
215
+ </p>
216
+
217
+
218
+
219
+ <div class="method-source-code"
220
+ id="add-ranked-query-result-source">
221
+ <pre>
222
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 55</span>
223
+ 55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_ranked_query_result</span>
224
+ 56:
225
+ 57: <span class="ruby-ivar">@query_result</span> = <span class="ruby-constant">Retreval</span><span class="ruby-operator">::</span><span class="ruby-constant">RankedQueryResult</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;query1&quot;</span>, <span class="ruby-value">:gold_standard</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@gold_standard</span>
226
+ 58:
227
+ 59: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc1&quot;</span>
228
+ 60: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc2&quot;</span>
229
+ 61: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc5&quot;</span>
230
+ 62: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc3&quot;</span>
231
+ 63: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc6&quot;</span>
232
+ 64: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc4&quot;</span>
233
+ 65: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc7&quot;</span>
234
+ 66: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc8&quot;</span>
235
+ 67: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc9&quot;</span>
236
+ 68: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;doc10&quot;</span>
237
+ 69:
238
+ 70: <span class="ruby-keyword kw">end</span></pre>
239
+ </div>
240
+
241
+ </div>
242
+
243
+
244
+
245
+
246
+ </div>
247
+
248
+
249
+ <div id="add-test-judgements-method" class="method-detail ">
250
+ <a name="method-i-add_test_judgements"></a>
251
+
252
+ <div class="method-heading">
253
+
254
+ <span class="method-name">add_test_judgements</span><span
255
+ class="method-args">()</span>
256
+ <span class="method-click-advice">click to toggle source</span>
257
+
258
+ </div>
259
+
260
+ <div class="method-description">
261
+
262
+ <p>
263
+ Adds 10 test judgements to this test case
264
+ </p>
265
+
266
+
267
+
268
+ <div class="method-source-code"
269
+ id="add-test-judgements-source">
270
+ <pre>
271
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 23</span>
272
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_test_judgements</span>
273
+ 24:
274
+ 25: <span class="ruby-ivar">@gold_standard</span> = <span class="ruby-constant">Retreval</span><span class="ruby-operator">::</span><span class="ruby-constant">GoldStandard</span>.<span class="ruby-identifier">new</span>
275
+ 26:
276
+ 27: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>) <span class="ruby-keyword kw">do</span>
277
+ 28: <span class="ruby-ivar">@gold_standard</span>.<span class="ruby-identifier">add_judgement</span> <span class="ruby-value">:document</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;doc#{i}&quot;</span>, <span class="ruby-value">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;query1&quot;</span>, <span class="ruby-value">:relevant</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>
278
+ 29: <span class="ruby-keyword kw">end</span>
279
+ 30:
280
+ 31: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">5</span><span class="ruby-operator">..</span><span class="ruby-value">10</span>) <span class="ruby-keyword kw">do</span>
281
+ 32: <span class="ruby-ivar">@gold_standard</span>.<span class="ruby-identifier">add_judgement</span> <span class="ruby-value">:document</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;doc#{i}&quot;</span>, <span class="ruby-value">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;query1&quot;</span>, <span class="ruby-value">:relevant</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>
282
+ 33: <span class="ruby-keyword kw">end</span>
283
+ 34:
284
+ 35: <span class="ruby-keyword kw">end</span></pre>
285
+ </div>
286
+
287
+ </div>
288
+
289
+
290
+
291
+
292
+ </div>
293
+
294
+
295
+ <div id="add-unranked-query-result-method" class="method-detail ">
296
+ <a name="method-i-add_unranked_query_result"></a>
297
+
298
+ <div class="method-heading">
299
+
300
+ <span class="method-name">add_unranked_query_result</span><span
301
+ class="method-args">()</span>
302
+ <span class="method-click-advice">click to toggle source</span>
303
+
304
+ </div>
305
+
306
+ <div class="method-description">
307
+
308
+ <p>
309
+ Adds the unranked query results to be tested against to this test case
310
+ </p>
311
+
312
+
313
+
314
+ <div class="method-source-code"
315
+ id="add-unranked-query-result-source">
316
+ <pre>
317
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 39</span>
318
+ 39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_unranked_query_result</span>
319
+ 40:
320
+ 41: <span class="ruby-ivar">@query_result</span> = <span class="ruby-constant">Retreval</span><span class="ruby-operator">::</span><span class="ruby-constant">UnrankedQueryResult</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;query1&quot;</span>, <span class="ruby-value">:gold_standard</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@gold_standard</span>
321
+ 42:
322
+ 43: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>) <span class="ruby-keyword kw">do</span>
323
+ 44: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;doc#{i}&quot;</span>
324
+ 45: <span class="ruby-keyword kw">end</span>
325
+ 46:
326
+ 47: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">5</span><span class="ruby-operator">..</span><span class="ruby-value">10</span>) <span class="ruby-keyword kw">do</span>
327
+ 48: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">add_document</span> <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;doc#{i}&quot;</span>
328
+ 49: <span class="ruby-keyword kw">end</span>
329
+ 50:
330
+ 51: <span class="ruby-keyword kw">end</span></pre>
331
+ </div>
332
+
333
+ </div>
334
+
335
+
336
+
337
+
338
+ </div>
339
+
340
+
341
+ <div id="test-eleven-point-precision-method" class="method-detail ">
342
+ <a name="method-i-test_eleven_point_precision"></a>
343
+
344
+ <div class="method-heading">
345
+
346
+ <span class="method-name">test_eleven_point_precision</span><span
347
+ class="method-args">()</span>
348
+ <span class="method-click-advice">click to toggle source</span>
349
+
350
+ </div>
351
+
352
+ <div class="method-description">
353
+
354
+ <p>
355
+ Tests the correct calculation of the eleven point precision as outlined
356
+ here: <a
357
+ href="http://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-ranked-retrieval-results-1.html">nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-ranked-retrieval-results-1.html</a>
358
+ </p>
359
+
360
+
361
+
362
+ <div class="method-source-code"
363
+ id="test-eleven-point-precision-source">
364
+ <pre>
365
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 142</span>
366
+ 142: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_eleven_point_precision</span>
367
+ 143:
368
+ 144: <span class="ruby-identifier">add_test_judgements</span>
369
+ 145: <span class="ruby-identifier">add_ranked_query_result</span>
370
+ 146: <span class="ruby-identifier">expected_results</span> = [
371
+ 147: <span class="ruby-value">1.0</span>,
372
+ 148: <span class="ruby-value">1.0</span>,
373
+ 149: <span class="ruby-value">1.0</span>,
374
+ 150: <span class="ruby-value">0.6666666666666666</span>,
375
+ 151: <span class="ruby-value">0.6666666666666666</span>,
376
+ 152: <span class="ruby-value">0.6666666666666666</span>,
377
+ 153: <span class="ruby-value">0.6</span>,
378
+ 154: <span class="ruby-value">0.6</span>,
379
+ 155: <span class="ruby-value">0.4</span>,
380
+ 156: <span class="ruby-value">0.4</span>,
381
+ 157: <span class="ruby-value">0.4</span>,
382
+ 158: ]
383
+ 159: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">eleven_point_precision</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
384
+ 160: <span class="ruby-identifier">assert_equal</span>(<span class="ruby-identifier">expected_results</span>[<span class="ruby-identifier">index</span>], <span class="ruby-identifier">p</span>[<span class="ruby-value">1</span>])
385
+ 161: <span class="ruby-keyword kw">end</span>
386
+ 162:
387
+ 163: <span class="ruby-keyword kw">end</span></pre>
388
+ </div>
389
+
390
+ </div>
391
+
392
+
393
+
394
+
395
+ </div>
396
+
397
+
398
+ <div id="test-ranked-precision-method" class="method-detail ">
399
+ <a name="method-i-test_ranked_precision"></a>
400
+
401
+ <div class="method-heading">
402
+
403
+ <span class="method-name">test_ranked_precision</span><span
404
+ class="method-args">()</span>
405
+ <span class="method-click-advice">click to toggle source</span>
406
+
407
+ </div>
408
+
409
+ <div class="method-description">
410
+
411
+ <p>
412
+ Tests if the ranked recalls are calculated correctly
413
+ </p>
414
+
415
+
416
+
417
+ <div class="method-source-code"
418
+ id="test-ranked-precision-source">
419
+ <pre>
420
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 94</span>
421
+ 94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_ranked_precision</span>
422
+ 95:
423
+ 96: <span class="ruby-identifier">add_test_judgements</span>
424
+ 97: <span class="ruby-identifier">add_ranked_query_result</span>
425
+ 98: <span class="ruby-identifier">expected_precision</span> = [
426
+ 99: <span class="ruby-value">1</span>,
427
+ 100: <span class="ruby-value">1</span>,
428
+ 101: <span class="ruby-value">0.6666666666666666</span>,
429
+ 102: <span class="ruby-value">0.75</span>,
430
+ 103: <span class="ruby-value">0.6</span>,
431
+ 104: <span class="ruby-value">0.6666666666666666</span>,
432
+ 105: <span class="ruby-value">0.5714285714285714</span>,
433
+ 106: <span class="ruby-value">0.5</span>,
434
+ 107: <span class="ruby-value">0.4444444444444444</span>,
435
+ 108: <span class="ruby-value">0.4</span>
436
+ 109: ]
437
+ 110: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">statistics</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rank</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
438
+ 111: <span class="ruby-identifier">assert_equal</span>(<span class="ruby-identifier">expected_precision</span>[<span class="ruby-identifier">index</span>], <span class="ruby-identifier">rank</span>[<span class="ruby-value">:precision</span>])
439
+ 112: <span class="ruby-keyword kw">end</span>
440
+ 113:
441
+ 114: <span class="ruby-keyword kw">end</span></pre>
442
+ </div>
443
+
444
+ </div>
445
+
446
+
447
+
448
+
449
+ </div>
450
+
451
+
452
+ <div id="test-ranked-recall-method" class="method-detail ">
453
+ <a name="method-i-test_ranked_recall"></a>
454
+
455
+ <div class="method-heading">
456
+
457
+ <span class="method-name">test_ranked_recall</span><span
458
+ class="method-args">()</span>
459
+ <span class="method-click-advice">click to toggle source</span>
460
+
461
+ </div>
462
+
463
+ <div class="method-description">
464
+
465
+ <p>
466
+ Tests if the ranked recalls are calculated correctly
467
+ </p>
468
+
469
+
470
+
471
+ <div class="method-source-code"
472
+ id="test-ranked-recall-source">
473
+ <pre>
474
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 117</span>
475
+ 117: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_ranked_recall</span>
476
+ 118:
477
+ 119: <span class="ruby-identifier">add_test_judgements</span>
478
+ 120: <span class="ruby-identifier">add_ranked_query_result</span>
479
+ 121: <span class="ruby-identifier">expected_recall</span> = [
480
+ 122: <span class="ruby-value">0.25</span>,
481
+ 123: <span class="ruby-value">0.5</span>,
482
+ 124: <span class="ruby-value">0.5</span>,
483
+ 125: <span class="ruby-value">0.75</span>,
484
+ 126: <span class="ruby-value">0.75</span>,
485
+ 127: <span class="ruby-value">1</span>,
486
+ 128: <span class="ruby-value">1</span>,
487
+ 129: <span class="ruby-value">1</span>,
488
+ 130: <span class="ruby-value">1</span>,
489
+ 131: <span class="ruby-value">1</span>
490
+ 132: ]
491
+ 133: <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">statistics</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rank</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
492
+ 134: <span class="ruby-identifier">assert_equal</span>(<span class="ruby-identifier">expected_recall</span>[<span class="ruby-identifier">index</span>], <span class="ruby-identifier">rank</span>[<span class="ruby-value">:recall</span>])
493
+ 135: <span class="ruby-keyword kw">end</span>
494
+ 136:
495
+ 137: <span class="ruby-keyword kw">end</span></pre>
496
+ </div>
497
+
498
+ </div>
499
+
500
+
501
+
502
+
503
+ </div>
504
+
505
+
506
+ <div id="test-unranked-precision-method" class="method-detail ">
507
+ <a name="method-i-test_unranked_precision"></a>
508
+
509
+ <div class="method-heading">
510
+
511
+ <span class="method-name">test_unranked_precision</span><span
512
+ class="method-args">()</span>
513
+ <span class="method-click-advice">click to toggle source</span>
514
+
515
+ </div>
516
+
517
+ <div class="method-description">
518
+
519
+ <p>
520
+ Tests the unranked precision
521
+ </p>
522
+
523
+
524
+
525
+ <div class="method-source-code"
526
+ id="test-unranked-precision-source">
527
+ <pre>
528
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 74</span>
529
+ 74: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_unranked_precision</span>
530
+ 75:
531
+ 76: <span class="ruby-identifier">add_test_judgements</span>
532
+ 77: <span class="ruby-identifier">add_unranked_query_result</span>
533
+ 78: <span class="ruby-identifier">assert_equal</span>(<span class="ruby-value">0.4</span>, <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">statistics</span>[<span class="ruby-value">:precision</span>])
534
+ 79:
535
+ 80: <span class="ruby-keyword kw">end</span></pre>
536
+ </div>
537
+
538
+ </div>
539
+
540
+
541
+
542
+
543
+ </div>
544
+
545
+
546
+ <div id="test-unranked-recall-method" class="method-detail ">
547
+ <a name="method-i-test_unranked_recall"></a>
548
+
549
+ <div class="method-heading">
550
+
551
+ <span class="method-name">test_unranked_recall</span><span
552
+ class="method-args">()</span>
553
+ <span class="method-click-advice">click to toggle source</span>
554
+
555
+ </div>
556
+
557
+ <div class="method-description">
558
+
559
+ <p>
560
+ Tests if the unranked recall is calculated correctly
561
+ </p>
562
+
563
+
564
+
565
+ <div class="method-source-code"
566
+ id="test-unranked-recall-source">
567
+ <pre>
568
+ <span class="ruby-comment cmt"># File test/test_query_result.rb, line 84</span>
569
+ 84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_unranked_recall</span>
570
+ 85:
571
+ 86: <span class="ruby-identifier">add_test_judgements</span>
572
+ 87: <span class="ruby-identifier">add_unranked_query_result</span>
573
+ 88: <span class="ruby-identifier">assert_equal</span>(<span class="ruby-value">1.0</span>, <span class="ruby-ivar">@query_result</span>.<span class="ruby-identifier">statistics</span>[<span class="ruby-value">:recall</span>])
574
+ 89:
575
+ 90: <span class="ruby-keyword kw">end</span></pre>
576
+ </div>
577
+
578
+ </div>
579
+
580
+
581
+
582
+
583
+ </div>
584
+
585
+
586
+ </div>
587
+
588
+
589
+ </div>
590
+
591
+
592
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
593
+
594
+ <p>Disabled; run with --debug to generate this.</p>
595
+
596
+ </div>
597
+
598
+ <div id="validator-badges">
599
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
600
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
601
+ Rdoc Generator</a> 1.1.6</small>.</p>
602
+ </div>
603
+
604
+ </body>
605
+ </html>
606
+