Fix and a test to title classification

This commit is contained in:
Maxim Zhilyaev 2014-05-01 15:44:02 -07:00 коммит произвёл Ed Lee
Родитель 4f62341faa
Коммит 1ec86241a2
2 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -74,7 +74,7 @@ UrlClassifier.prototype = {
}
},
classifyPage: function I__ClassifyPage(url,title) {
classifyPage: function I__ClassifyPage(url, title) {
if (this._deferred) {
return this._deferred.promise;
}
@ -83,13 +83,12 @@ UrlClassifier.prototype = {
this._results = {};
try {
// submit url+title to workers
let title = title || "";
let uri = NetUtil.newURI(url);
let host = getPlacesHostForURI(uri);
let message = {};
message.message = "getInterestsForDocument";
message.url = url;
message.title = title;
message.title = title || "";
message.host = host;
message.path = uri["path"];
message.tld = getBaseDomain(host);

Просмотреть файл

@ -41,6 +41,14 @@ exports["test url classifier"] = function test_UrlClassifier(assert, done) {
assert.ok(true);
});
// classify only the text
results = yield urlClassifier.classifyPage("http://www.xyz.com", "iphone, ipad, apple, product, phone");
testUtils.isIdentical(assert, results["edrules"].results,
[{"type":"rules","interests":[]},
{"type":"keywords","interests":["Apple"]},
{"type":"combined","interests":["Apple"]}
]);
}).then(done);
}