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

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: 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
Peter Kasting 2013/06/28 22:18:22 How come you rewrapped this to have such shorter l
Mark P 2013/06/28 22:38:58 Re-wrapped by hand.
212 // sum will never be greater than 1.0. This sum is then multiplied against 212 // resulting sum will never be greater than 1.0 because of the way
213 // the scoring range available, which is 299. The 299 is calculated by 213 // the bookmark model matches and removes overlaps. (In particular,
214 // subtracting the minimum possible score, 900, from the maximum possible 214 // the bookmarks models only matches terms to the beginning of words
Peter Kasting 2013/06/28 22:18:22 Nit: bookmarks models -> bookmark model
Mark P 2013/06/28 22:38:58 Done.
215 // score, 1199. This product, ranging from 0 to 299, is added to the minimum 215 // and it removes all overlapping matches, keeping only the longest.
216 // possible score, 900, giving the preliminary score. 216 // Together these mean that each character is included in at most
217 // one match. This property ensures the sum of factors is at most 1.)
218 // This sum is then multiplied against the scoring range available,
219 // which is 299. The 299 is calculated by subtracting the minimum
220 // possible score, 900, from the maximum possible score, 1199. This
221 // product, ranging from 0 to 299, is added to the minimum possible
222 // score, 900, giving the preliminary score.
217 // 223 //
218 // If the preliminary score is less than the maximum possible score, 1199, 224 // 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 225 // 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. 226 // 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 227 // 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 228 // 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 229 // scored up to a maximum of three, the score is boosted by a fixed amount
224 // given by |kURLCountBoost|, below. 230 // given by |kURLCountBoost|, below.
225 // 231 //
226 ScoringFunctor position_functor = 232 ScoringFunctor position_functor =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 for (Snippet::MatchPositions::const_iterator i = positions.begin(); 270 for (Snippet::MatchPositions::const_iterator i = positions.begin();
265 i != positions.end(); ++i) { 271 i != positions.end(); ++i) {
266 AutocompleteMatch::ACMatchClassifications new_class; 272 AutocompleteMatch::ACMatchClassifications new_class;
267 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, 273 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first,
268 text_length, 0, &new_class); 274 text_length, 0, &new_class);
269 classifications = AutocompleteMatch::MergeClassifications( 275 classifications = AutocompleteMatch::MergeClassifications(
270 classifications, new_class); 276 classifications, new_class);
271 } 277 }
272 return classifications; 278 return classifications;
273 } 279 }
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