Ejemplo n.º 1
0
 def test_word_exists_in_category_features(self):
     c = Classify()
     w = "crazyjackson"
     cat = "gossip"
     c.add_feature_to_category(category=cat, feature=w, weight=1)
     r = c.word_exists_in_category_features(category=cat, w=w)
     self.assertGreater(r, 0)
Ejemplo n.º 2
0
 def test_get_category_for_text(self):
     c = Classify()
     ct = 'gossip'
     f = 'lol'
     ct1 = 'other'
     f1 = 'random'
     text = 'this guy is crazy ' + f
     self.test_add_feature_to_category(category=ct, feature=f)
     self.test_add_feature_to_category(category=ct1, feature=f1)
     c.refresh_feature_set()
     cat = c.get_category_for_text(text=text)
     self.assertEqual(cat, ct)
Ejemplo n.º 3
0
 def get(self):
     try:
         email = tornado.escape.xhtml_escape(self.current_user["email"])
         if email not in settings.ADMIN_EMAILS:
             self.render('denied.html')
         c = Classify()
         result = c.get_feature_set()
         #self.write(json.dumps(result))
         self.render("bo_category_features.html", categories=result)
     except Exception,e:
         logging.exception(e)
         self.render("404.html")
Ejemplo n.º 4
0
 def test_evaluate_category(self):
     c = Classify()
     cs = {"gossip":1, "science":3, "concert": 2}
     res = c.evaluate_category(category_score=cs)
     self.assertEqual(res, 'science')
Ejemplo n.º 5
0
 def test_add_feature_to_category(self, category = 'gossip', feature='lol'):
     c = Classify()
     c.add_feature_to_category(category=category, feature=feature, weight=1)
     r = c.get_feature_set()
     self.assertNotEqual(r, {})
Ejemplo n.º 6
0
 def test_get_feature_set(self):
     c = Classify()
     r = c.get_feature_set()
     self.assertEqual(r, {})