Lab T2 Exercise 4-3 & 4-7

組別 : 第三組
組員 : 岑志豪 任祥偉 李耀軒

4-3

Exact matches. Search engines often support “exact match” queries, where the
words in the page must match the words in the query in the same order with no
additional words in between. Create a new version of getrows that only returns
results that are exact matches. (Hint: you can use subtraction in SQL to get the
difference between the word locations.)

題目要求把搜索的判斷條件更改, 由原來只是包含關改為要判斷字的連貫性.

還好他有給提示: 在 SQL 中加入字與字之間的 location 距離判斷

於是我把判斷條件改了一下:

clauselist+='w%d.urlid=w%d.urlid and abs(w%d.location-w%d.location) = 1 and ' % (tablenumber-1,tablenumber,tablenumber-1,tablenumber)

就完成了

下面為更改前與更改後的截圖:

更改前:

更改後:  

 

4-7

尚在研究...orz