Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/autocomplete/bookmark_provider.cc

Issue 18083017: Omnibox: Improve Bookmarks Provider Comments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/bookmark_provider.h" 5 #include "chrome/browser/autocomplete/bookmark_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 match.description.size()); 181 match.description.size());
182 match.starred = true; 182 match.starred = true;
183 183
184 // Summary on how a relevance score is determined for the match: 184 // Summary on how a relevance score is determined for the match:
185 // 185 //
186 // For each term matching within the bookmark's title (as given by the set of 186 // For each term matching within the bookmark's title (as given by the set of
187 // Snippet::MatchPositions) calculate a 'factor', sum up those factors, then 187 // Snippet::MatchPositions) calculate a 'factor', sum up those factors, then
188 // use the sum to figure out a value between the base score and the maximum 188 // use the sum to figure out a value between the base score and the maximum
189 // score. 189 // score.
190 // 190 //
191 // The factor for each term is calculated based on: 191 // The factor for each term is the product of:
192 // 192 //
193 // 1) how much of the bookmark's title has been matched by the term: 193 // 1) how much of the bookmark's title has been matched by the term:
194 // (term length / title length). 194 // (term length / title length).
195 // 195 //
196 // Example: Given a bookmark title 'abcde fghijklm', with a title length 196 // Example: Given a bookmark title 'abcde fghijklm', with a title length
197 // of 14, and two different search terms, 'abcde' and 'fghijklm', with 197 // of 14, and two different search terms, 'abcde' and 'fghijklm', with
198 // term lengths of 5 and 8, respectively, 'fghijklm' will score higher 198 // term lengths of 5 and 8, respectively, 'fghijklm' will score higher
199 // (with a partial factor of 8/14 = 0.571) than 'abcde' (5/14 = 0.357). 199 // (with a partial factor of 8/14 = 0.571) than 'abcde' (5/14 = 0.357).
200 // 200 //
201 // 2) where the term match occurs within the bookmark's title, giving more 201 // 2) where the term match occurs within the bookmark's title, giving more
202 // points for matches that appear earlier in the title: 202 // points for matches that appear earlier in the title:
203 // ((title length - position of match start) / title_length). 203 // ((title length - position of match start) / title_length).
204 // 204 //
205 // Example: Given a bookmark title of 'abcde fghijklm', with a title length 205 // Example: Given a bookmark title of 'abcde fghijklm', with a title length
206 // of 14, and two different search terms, 'abcde' and 'fghij', with 206 // of 14, and two different search terms, 'abcde' and 'fghij', with
207 // start positions of 0 and 6, respectively, 'abcde' will score higher 207 // start positions of 0 and 6, respectively, 'abcde' will score higher
208 // (with a a partial factor of (14-0)/14 = 1.000 ) than 'fghij' (with 208 // (with a a partial factor of (14-0)/14 = 1.000 ) than 'fghij' (with
209 // a partial factor of (14-6)/14 = 0.571 ). 209 // a partial factor of (14-6)/14 = 0.571 ).
210 // 210 //
211 // Once all term factors have been calculated they are summed. The resulting 211 // Once all term factors have been calculated they are summed. The resulting
212 // sum will never be greater than 1.0. This sum is then multiplied against 212 // sum will never be greater than 1.0 because of the way the bookmark model
213 // the scoring range available, which is 299. The 299 is calculated by 213 // matches and removes overlaps. (In particular, the bookmark model only
214 // matches terms to the beginning of words and it removes all overlapping
215 // matches, keeping only the longest. Together these mean that each
216 // character is included in at most one match. This property ensures the
217 // sum of factors is at most 1.) This sum is then multiplied against the
Peter Kasting 2013/06/28 22:44:14 Super nit: "sum" will fit on the previous line, wh
Mark P 2013/06/28 22:55:05 It looks ugly like that because the line above is
Peter Kasting 2013/06/28 22:57:17 We are wrapping our lines based on aesthetics of m
218 // scoring range available, which is 299. The 299 is calculated by
214 // subtracting the minimum possible score, 900, from the maximum possible 219 // subtracting the minimum possible score, 900, from the maximum possible
215 // score, 1199. This product, ranging from 0 to 299, is added to the minimum 220 // score, 1199. This product, ranging from 0 to 299, is added to the minimum
216 // possible score, 900, giving the preliminary score. 221 // possible score, 900, giving the preliminary score.
217 // 222 //
218 // If the preliminary score is less than the maximum possible score, 1199, 223 // If the preliminary score is less than the maximum possible score, 1199,
219 // it can be boosted up to that maximum possible score if the URL referenced 224 // it can be boosted up to that maximum possible score if the URL referenced
220 // by the bookmark is also referenced by any of the user's other bookmarks. 225 // by the bookmark is also referenced by any of the user's other bookmarks.
221 // A count of how many times the bookmark's URL is referenced is determined 226 // A count of how many times the bookmark's URL is referenced is determined
222 // and, for each additional reference beyond the one for the bookmark being 227 // and, for each additional reference beyond the one for the bookmark being
223 // scored up to a maximum of three, the score is boosted by a fixed amount 228 // scored up to a maximum of three, the score is boosted by a fixed amount
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 for (Snippet::MatchPositions::const_iterator i = positions.begin(); 269 for (Snippet::MatchPositions::const_iterator i = positions.begin();
265 i != positions.end(); ++i) { 270 i != positions.end(); ++i) {
266 AutocompleteMatch::ACMatchClassifications new_class; 271 AutocompleteMatch::ACMatchClassifications new_class;
267 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, 272 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first,
268 text_length, 0, &new_class); 273 text_length, 0, &new_class);
269 classifications = AutocompleteMatch::MergeClassifications( 274 classifications = AutocompleteMatch::MergeClassifications(
270 classifications, new_class); 275 classifications, new_class);
271 } 276 }
272 return classifications; 277 return classifications;
273 } 278 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698