OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This class loads a client-side model and lets you compute a phishing score | 5 // This class loads a client-side model and lets you compute a phishing score |
6 // for a set of previously extracted features. The phishing score corresponds | 6 // for a set of previously extracted features. The phishing score corresponds |
7 // to the probability that the features are indicative of a phishing site. | 7 // to the probability that the features are indicative of a phishing site. |
8 // | 8 // |
9 // For more details on how the score is actually computed for a given model | 9 // For more details on how the score is actually computed for a given model |
10 // and a given set of features read the comments in client_model.proto file. | 10 // and a given set of features read the comments in client_model.proto file. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 int model_version() const; | 43 int model_version() const; |
44 | 44 |
45 // -- Accessors used by the page feature extractor --------------------------- | 45 // -- Accessors used by the page feature extractor --------------------------- |
46 | 46 |
47 // Returns a set of hashed page terms that appear in the model in binary | 47 // Returns a set of hashed page terms that appear in the model in binary |
48 // format. | 48 // format. |
49 const base::hash_set<std::string>& page_terms() const; | 49 const base::hash_set<std::string>& page_terms() const; |
50 | 50 |
51 // Returns a set of hashed page words that appear in the model in binary | 51 // Returns a set of hashed page words that appear in the model in binary |
52 // format. | 52 // format. |
53 const base::hash_set<std::string>& page_words() const; | 53 const base::hash_set<uint32>& page_words() const; |
54 | 54 |
55 // Return the maximum number of words per term for the loaded model. | 55 // Return the maximum number of words per term for the loaded model. |
56 size_t max_words_per_term() const; | 56 size_t max_words_per_term() const; |
57 | 57 |
| 58 // Returns the murmurhash3 seed for the loaded model. |
| 59 uint32 murmurhash3_seed() const; |
| 60 |
58 protected: | 61 protected: |
59 // Most clients should use the factory method. This constructor is public | 62 // Most clients should use the factory method. This constructor is public |
60 // to allow for mock implementations. | 63 // to allow for mock implementations. |
61 Scorer(); | 64 Scorer(); |
62 | 65 |
63 private: | 66 private: |
64 friend class PhishingScorerTest; | 67 friend class PhishingScorerTest; |
65 | 68 |
66 // Computes the score for a given rule and feature map. The score is computed | 69 // Computes the score for a given rule and feature map. The score is computed |
67 // by multiplying the rule weight with the product of feature weights for the | 70 // by multiplying the rule weight with the product of feature weights for the |
68 // given rule. The feature weights are stored in the feature map. If a | 71 // given rule. The feature weights are stored in the feature map. If a |
69 // particular feature does not exist in the feature map we set its weight to | 72 // particular feature does not exist in the feature map we set its weight to |
70 // zero. | 73 // zero. |
71 double ComputeRuleScore(const ClientSideModel::Rule& rule, | 74 double ComputeRuleScore(const ClientSideModel::Rule& rule, |
72 const FeatureMap& features) const; | 75 const FeatureMap& features) const; |
73 | 76 |
74 ClientSideModel model_; | 77 ClientSideModel model_; |
75 base::hash_set<std::string> page_terms_; | 78 base::hash_set<std::string> page_terms_; |
76 base::hash_set<std::string> page_words_; | 79 base::hash_set<uint32> page_words_; |
77 | 80 |
78 DISALLOW_COPY_AND_ASSIGN(Scorer); | 81 DISALLOW_COPY_AND_ASSIGN(Scorer); |
79 }; | 82 }; |
80 } // namepsace safe_browsing | 83 } // namepsace safe_browsing |
81 | 84 |
82 #endif // CHROME_RENDERER_SAFE_BROWSING_SCORER_H_ | 85 #endif // CHROME_RENDERER_SAFE_BROWSING_SCORER_H_ |
OLD | NEW |