OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 goog.provide('image.collections.extension.DocumentFeature'); | 5 goog.provide('image.collections.extension.domextractor.DocumentFeature'); |
6 | 6 |
7 goog.scope(function() { | 7 goog.scope(function() { |
8 | 8 |
9 | 9 |
10 | 10 |
11 /** | 11 /** |
12 * This is a base class for all document features (e.g. title, snippet, image). | 12 * This is a base class for all document features (e.g. title, snippet, image). |
13 * @param {number} relevance Relevance of this feature to the document. | 13 * @param {number} relevance Relevance of this feature to the document. |
14 * @constructor | 14 * @constructor |
15 */ | 15 */ |
16 image.collections.extension.DocumentFeature = function(relevance) { | 16 image.collections.extension.domextractor.DocumentFeature = function(relevance) { |
17 /** @private {number} */ | 17 /** @private {number} */ |
18 this.relevance_ = relevance; | 18 this.relevance_ = relevance; |
19 }; | 19 }; |
20 var DocumentFeature = image.collections.extension.DocumentFeature; | 20 var DocumentFeature = image.collections.extension.domextractor.DocumentFeature; |
21 | 21 |
22 | 22 |
23 /** | 23 /** |
24 * Returns the feature relevance. | 24 * Returns the feature relevance. |
25 * @return {number} | 25 * @return {number} |
26 */ | 26 */ |
27 DocumentFeature.prototype.getRelevance = function() { | 27 DocumentFeature.prototype.getRelevance = function() { |
28 return this.relevance_; | 28 return this.relevance_; |
29 }; | 29 }; |
30 | 30 |
31 | 31 |
32 /** | 32 /** |
33 * Compares two document features by their relevance. | 33 * Compares two document features by their relevance. |
34 * @param {!DocumentFeature} feature1 | 34 * @param {!DocumentFeature} feature1 |
35 * @param {!DocumentFeature} feature2 | 35 * @param {!DocumentFeature} feature2 |
36 * @return {number} | 36 * @return {number} |
37 */ | 37 */ |
38 DocumentFeature.compare = function(feature1, feature2) { | 38 DocumentFeature.compare = function(feature1, feature2) { |
39 if (feature1 == feature2) { | 39 if (feature1 == feature2) { |
40 return 0; | 40 return 0; |
41 } | 41 } |
42 return feature1.getRelevance() - feature2.getRelevance(); | 42 return feature1.getRelevance() - feature2.getRelevance(); |
43 }; | 43 }; |
44 }); // goog.scope | 44 }); // goog.scope |
OLD | NEW |