@@ -229,90 +229,48 @@ context "suggestions",
229
229
assert .equal - 1 , suggestion .generateHtml ().indexOf (" http://ninjawords.com" )
230
230
231
231
context " RankingUtils.wordRelevancy" ,
232
- should " get a higher relevancy score in shorter URLs" , ->
233
- highScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflow.com/short" , " nothing " )
234
- lowScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflow.com/longer" , " nothing " )
232
+ should " score higher in shorter URLs" , ->
233
+ highScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflow.com/short" , " a-title " )
234
+ lowScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflow.com/longer" , " a-title " )
235
235
assert .isTrue highScore > lowScore
236
236
237
- should " get a higher relevancy score in shorter titles" , ->
238
- highScore = RankingUtils .wordRelevancy ([" ffee " ], " http://stackoverflow.com/same " , " Coffeescript" )
239
- lowScore = RankingUtils .wordRelevancy ([" ffee " ], " http://stackoverflow.com/same " , " Coffeescript rocks" )
237
+ should " score higher in shorter titles" , ->
238
+ highScore = RankingUtils .wordRelevancy ([" coffee " ], " a-url " , " Coffeescript" )
239
+ lowScore = RankingUtils .wordRelevancy ([" coffee " ], " a-url " , " Coffeescript rocks" )
240
240
assert .isTrue highScore > lowScore
241
241
242
- should " get a higher relevancy score for matching the start of a word (in a URL)" , ->
243
- lowScore = RankingUtils .wordRelevancy ([" stack" ], " http://Xstackoverflow.com/same" , " nothing " )
244
- highScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflowX.com/same" , " nothing " )
242
+ should " score higher for matching the start of a word (in a URL)" , ->
243
+ lowScore = RankingUtils .wordRelevancy ([" stack" ], " http://Xstackoverflow.com/same" , " a-title " )
244
+ highScore = RankingUtils .wordRelevancy ([" stack" ], " http://stackoverflowX.com/same" , " a-title " )
245
245
assert .isTrue highScore > lowScore
246
246
247
- should " get a higher relevancy score for matching the start of a word (in a title)" , ->
248
- lowScore = RankingUtils .wordRelevancy ([" ted " ], " http://stackoverflow.com/same " , " Dist racted" )
249
- highScore = RankingUtils .wordRelevancy ([" ted " ], " http://stackoverflow.com/same " , " Distrac ted" )
247
+ should " score higher for matching the start of a word (in a title)" , ->
248
+ lowScore = RankingUtils .wordRelevancy ([" te " ], " a-url " , " Dist racted" )
249
+ highScore = RankingUtils .wordRelevancy ([" te " ], " a-url " , " Distrac ted" )
250
250
assert .isTrue highScore > lowScore
251
251
252
- should " get a higher relevancy score for matching a whole word (in a URL)" , ->
253
- lowScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflow.comX/same" , " nothing " )
254
- highScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflowX.com/same" , " nothing " )
252
+ should " score higher for matching a whole word (in a URL)" , ->
253
+ lowScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflow.comX/same" , " a-title " )
254
+ highScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflowX.com/same" , " a-title " )
255
255
assert .isTrue highScore > lowScore
256
256
257
- should " get a higher relevancy score for matching a whole word (in a title)" , ->
258
- lowScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflow.com/same " , " abc comX" )
259
- highScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflow.com/same " , " abcX com" )
257
+ should " score higher for matching a whole word (in a title)" , ->
258
+ lowScore = RankingUtils .wordRelevancy ([" com" ], " a-url " , " abc comX" )
259
+ highScore = RankingUtils .wordRelevancy ([" com" ], " a-url " , " abcX com" )
260
260
assert .isTrue highScore > lowScore
261
261
262
262
# # TODO: (smblott)
263
263
# # Word relevancy should take into account the number of matches (it doesn't currently).
264
- # should "get a higher relevancy score for multiple matches (in a URL)", ->
265
- # lowScore = RankingUtils.wordRelevancy(["stack"], "http://stackoverflow.com/Xxxxxx", "nothing ")
266
- # highScore = RankingUtils.wordRelevancy(["stack"], "http://stackoverflow.com/Xstack", "nothing ")
264
+ # should "score higher for multiple matches (in a URL)", ->
265
+ # lowScore = RankingUtils.wordRelevancy(["stack"], "http://stackoverflow.com/Xxxxxx", "a-title ")
266
+ # highScore = RankingUtils.wordRelevancy(["stack"], "http://stackoverflow.com/Xstack", "a-title ")
267
267
# assert.isTrue highScore > lowScore
268
268
269
- # should "get a higher relevancy score for multiple matches (in a title)", ->
269
+ # should "score higher for multiple matches (in a title)", ->
270
270
# lowScore = RankingUtils.wordRelevancy(["bbc"], "http://stackoverflow.com/same", "BBC Radio 4 (XBCr4)")
271
271
# highScore = RankingUtils.wordRelevancy(["bbc"], "http://stackoverflow.com/same", "BBC Radio 4 (BBCr4)")
272
272
# assert.isTrue highScore > lowScore
273
273
274
- # WARNING: The following tests are hardware dependent. They depend upon
275
- # different but algebraically-equivalent sequences of floating point
276
- # operations yielding the same results. That they ever work at all is quite
277
- # remarkable.
278
- # TODO: (smblott)
279
- # Remove these tests when `oldWordRelevancy` is removed.
280
- context " RankingUtils.wordRelevancy (temporary hardware-dependent tests)" ,
281
- should " exactly equal oldWordRelevancy for whole word matches (in a URL)" , ->
282
- newScore = RankingUtils .wordRelevancy ([" com" ], " http://stackoverflow.com/same" , " irrelevant" )
283
- oldScore = RankingUtils .oldWordRelevancy ([" com" ], " http://stackoverflow.com/same" , " irrelevant" )
284
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
285
-
286
- should " yield 2/3 * oldWordRelevancy for matches at the start of a word (in a URL)" , ->
287
- newScore = RankingUtils .wordRelevancy ([" sta" ], " http://stackoverflow.com/same" , " irrelevant" )
288
- oldScore = (2.0 / 3.0 ) * RankingUtils .oldWordRelevancy ([" sta" ], " http://stackoverflow.com/same" , " irrelevant" )
289
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
290
-
291
- should " yield 1/3 * oldWordRelevancy for matches within a word (in a URL)" , ->
292
- newScore = RankingUtils .wordRelevancy ([" over" ], " http://stackoverflow.com/same" , " irrelevant" )
293
- oldScore = (1.0 / 3.0 ) * RankingUtils .oldWordRelevancy ([" over" ], " http://stackoverflow.com/same" , " irrelevant" )
294
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
295
-
296
- should " exactly equal oldWordRelevancy for whole word matches (in a title)" , ->
297
- newScore = RankingUtils .wordRelevancy ([" relevant" ], " http://stackoverflow.com/same" , " XX relevant YY" )
298
- # Multiply by 2 to account for new wordRelevancy favoring title.
299
- oldScore = 2 * RankingUtils .oldWordRelevancy ([" relevant" ], " http://stackoverflow.com/same" , " XX relevant YY" )
300
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
301
-
302
- should " 2/3 * oldWordRelevancy for matches at the start of a word (in a title)" , ->
303
- newScore = RankingUtils .wordRelevancy ([" relev" ], " http://stackoverflow.com/same" , " XX relevant YY" )
304
- # Multiply by 2 to account for new wordRelevancy favoring title.
305
- oldScore = (2.0 / 3.0 ) * 2 * RankingUtils .oldWordRelevancy ([" relev" ], " http://stackoverflow.com/same" , " XX relevant YY" )
306
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
307
-
308
- should " 1/3 * oldWordRelevancy for matches within a word (in a title)" , ->
309
- newScore = RankingUtils .wordRelevancy ([" elev" ], " http://stackoverflow.com/same" , " XX relevant YY" )
310
- # Multiply by 2 to account for new wordRelevancy favoring title.
311
- oldScore = (1.0 / 3.0 ) * 2 * RankingUtils .oldWordRelevancy ([" elev" ], " http://stackoverflow.com/same" , " XX relevant YY" )
312
- assert .equal newScore, oldScore # remarkable! Exactly equal floats.
313
- #
314
- # End of hardware-dependent tests.
315
-
316
274
context " Suggestion.pushMatchingRanges" ,
317
275
should " extract ranges matching term (simple case, two matches)" , ->
318
276
ranges = []
0 commit comments