Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/translate/core/browser/translate_ranker.h" | 5 #include "components/translate/core/browser/translate_ranker.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 173 |
| 174 double score = CalculateScore(accept_ratio, decline_ratio, ignore_ratio, | 174 double score = CalculateScore(accept_ratio, decline_ratio, ignore_ratio, |
| 175 src_lang, dst_lang, app_locale, country); | 175 src_lang, dst_lang, app_locale, country); |
| 176 | 176 |
| 177 DVLOG(2) << "TranslateRanker Score: " << score; | 177 DVLOG(2) << "TranslateRanker Score: " << score; |
| 178 | 178 |
| 179 bool result = (score >= kTranslationOfferThreshold); | 179 bool result = (score >= kTranslationOfferThreshold); |
| 180 | 180 |
| 181 UMA_HISTOGRAM_BOOLEAN("Translate.Ranker.QueryResult", result); | 181 UMA_HISTOGRAM_BOOLEAN("Translate.Ranker.QueryResult", result); |
| 182 | 182 |
| 183 // If enforcement is enabled, return the real result; otherwise, return the | 183 return result; |
| 184 // default. | |
| 185 return IsEnforcementEnabled() ? result : kDefaultResponse; | |
|
Roger McFarlane (Chromium)
2016/11/29 18:43:30
The TranslateManager code where this is enforced i
groby1
2016/11/29 19:03:43
The behavior in translate manager is subtly differ
hamelphi
2016/11/29 19:37:06
It is intentional. We want to log the response the
Roger McFarlane (Chromium)
2016/11/29 20:01:00
Precisely. :)
| |
| 186 } | 184 } |
| 187 | 185 |
| 188 TranslateRanker::TranslateRanker() {} | 186 TranslateRanker::TranslateRanker() {} |
| 189 | 187 |
| 190 double TranslateRanker::CalculateScore(double accept_ratio, | 188 double TranslateRanker::CalculateScore(double accept_ratio, |
| 191 double decline_ratio, | 189 double decline_ratio, |
| 192 double ignore_ratio, | 190 double ignore_ratio, |
| 193 const std::string& src_lang, | 191 const std::string& src_lang, |
| 194 const std::string& dst_lang, | 192 const std::string& dst_lang, |
| 195 const std::string& locale, | 193 const std::string& locale, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 } | 299 } |
| 302 } | 300 } |
| 303 | 301 |
| 304 void TranslateRanker::RecordTranslateEvent( | 302 void TranslateRanker::RecordTranslateEvent( |
| 305 const metrics::TranslateEventProto& translate_event) { | 303 const metrics::TranslateEventProto& translate_event) { |
| 306 if (IsLoggingEnabled()) | 304 if (IsLoggingEnabled()) |
| 307 translate_events_cache_.push_back(translate_event); | 305 translate_events_cache_.push_back(translate_event); |
| 308 } | 306 } |
| 309 | 307 |
| 310 } // namespace translate | 308 } // namespace translate |
| OLD | NEW |