当前位置: 首页>>代码示例>>Python>>正文


Python Keyword.get_many方法代码示例

本文整理汇总了Python中scinet3.model.Keyword.get_many方法的典型用法代码示例。如果您正苦于以下问题:Python Keyword.get_many方法的具体用法?Python Keyword.get_many怎么用?Python Keyword.get_many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scinet3.model.Keyword的用法示例。


在下文中一共展示了Keyword.get_many方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_one

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_one(self):
        docs = [Document.get_many([1,2]), Document.get_many([1,2]), Document.get_many([2,1])]
        kws = [Keyword.get_many(["redis", "database"]), Keyword.get_many(["redis", "database"]), Keyword.get_many(["redis", "database"])]

        scores = self.e.evaluate(docs, kws)
        expected = ([1,1,1], [1,1,1])
        
        self.assertArrayAlmostEqual(expected[0], scores[0])
        self.assertArrayAlmostEqual(expected[1], scores[1])
开发者ID:samim23,项目名称:rl-search,代码行数:11,代码来源:ir_eval_test.py

示例2: test_get_many

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_get_many(self):
        doc_ids = [1,2]
        kw_ids = ["a", "the"]
        
        self.assertEqual(Document.get_many([1,2]), 
                         Document.get_many(doc_ids))

        self.assertEqual(Keyword.get_many(["a", "the"]), 
                         Keyword.get_many(kw_ids))
开发者ID:samim23,项目名称:rl-search,代码行数:11,代码来源:model_test.py

示例3: test_add_kws

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_add_kws(self):
        iter1 = Keyword.get_many(["redis", "database", "mysql"])
        iter2 = Keyword.get_many(["redis", "database", "python"])
        
        self.session.add_kw_recom_list(iter1)        
        self.assertEqual([iter1], self.session.recom_kws)

        self.session.add_kw_recom_list(iter2)        
        self.assertEqual([iter1, iter2], self.session.recom_kws)
开发者ID:samim23,项目名称:rl-search,代码行数:11,代码来源:session_test.py

示例4: test_associated_keywords_from_documents

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
 def test_associated_keywords_from_documents(self):
     kws = self.r.associated_keywords_from_docs(Document.get_many([1,2]))
     self.assertEqual(set(Keyword.get_many(["a", "database", "redis", "the"])),
                      set(kws))
     
     exclude_kws = [Keyword.get("redis")]
     kws = self.r.associated_keywords_from_docs(Document.get_many([1,2]), exclude_kws)
     
     self.assertEqual(set(Keyword.get_many(["a", "database", "the"])), 
                      set(kws))
开发者ID:samim23,项目名称:rl-search,代码行数:12,代码来源:linrel_recommender_test.py

示例5: test_two

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_two(self):
        docs = [Document.get_many([8,10]), Document.get_many([3,4]), Document.get_many([2,1])]
        kws = [Keyword.get_many(["a", "the"]), Keyword.get_many(["python", "database"]), Keyword.get_many(["database", "redis"])]

        scores = self.e.evaluate(docs, kws)
        expected = ([0.34491169135422844, 0.1726882003112921, 1.0],
                    [0.4834283906452939, 0.759679156743632, 0.9999999999999999])

        self.assertArrayAlmostEqual(expected[0], scores[0])
        self.assertArrayAlmostEqual(expected[1], scores[1])
开发者ID:samim23,项目名称:rl-search,代码行数:12,代码来源:ir_eval_test.py

示例6: test_kw_hashable

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_kw_hashable(self):
        d = {}
        kwlist1 = Keyword.get_many(["redis", "a", "the"])
        kwlist2 = Keyword.get_many(["a", "the", "redis"])
        kwlist3 = Keyword.get_many(["redis", "a", "python"])

        d[kwlist1] = 1
        d[kwlist2] = 2 #override
        d[kwlist3] = 3 

        self.assertEqual({kwlist1:2, kwlist3: 3}, d)
开发者ID:samim23,项目名称:rl-search,代码行数:13,代码来源:modellist_test.py

示例7: test_modellist2modellist_similarity

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_modellist2modellist_similarity(self):
        #for keywords
        kwlist1 = Keyword.get_many(["redis", "a"])
        kwlist2 = Keyword.get_many(["database", "the"])

        self.assertAlmostEqual(0.42205423035497763, kwlist1.similarity_to(kwlist2))
        
        #for documents
        doclist1 = Document.get_many([3,5])
        doclist2 = Document.get_many([4,6])
        
        self.assertAlmostEqual(0.6990609119502719, doclist1.similarity_to(doclist2))
开发者ID:samim23,项目名称:rl-search,代码行数:14,代码来源:modellist_test.py

示例8: test_equality_same_type

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_equality_same_type(self):
        kwlist1 = Keyword.get_many(["redis", "a", "the"])
        kwlist2 = Keyword.get_many(["a", "the", "redis"])
        kwlist3 = Keyword.get_many(["a", "the", "python"])

        self.assertEqual(kwlist1, kwlist2)
        self.assertNotEqual(kwlist3, kwlist2)

        doclist1 = Document.get_many([1,2,3])
        doclist2 = Document.get_many([2,3,1])
        doclist3 = Document.get_many([4,5,6])

        self.assertEqual(doclist1, doclist2)
        self.assertNotEqual(doclist3, doclist2)
开发者ID:samim23,项目名称:rl-search,代码行数:16,代码来源:modellist_test.py

示例9: setUp

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def setUp(self):
        doc_goal = Document.get_many([1,2])
        kw_goal = Keyword.get_many(["redis", "database"])
        
        self.e = GoalBasedEvaluator()

        self.e.setGoal(doc_goal, kw_goal)
开发者ID:samim23,项目名称:rl-search,代码行数:9,代码来源:ir_eval_test.py

示例10: recommend_keywords

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
 def recommend_keywords(self, fmim,
                        session, top_n, mu, c, 
                        sampler=None):
     """
     fmim: FeatureMatrixAndIndexMapping, the fmim for the sub-matrix        
     session: Session,
     top_n: how many kws are returned
     mu,c: float, the parameters for LinRel algorithm
     
     Return
     KeywordList: a list of keyword ids as well as their scores
     """        
     kws = Keyword.get_many(fmim.kw_ind.keys())
     fbs = dict([(kw.id, kw.fb(session)) for kw in kws])
     
     id_with_scores, id_with_explt_scores, id_with_explr_scores = self.generic_rank(fmim.kw2doc_m, fbs, 
                                                                                    fmim.kw_ind, fmim.kw_ind_r,
                                                                                    mu, c)
     
     kws = []
     for kw_id, score in id_with_scores.items()[:top_n]:
         kw = Keyword.get(kw_id)
         kw['score'] = score
         kw['recommended'] = True
         kws.append(kw)
         
     return kws
开发者ID:samim23,项目名称:rl-search,代码行数:29,代码来源:linrel.py

示例11: setUp

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def setUp(self):
        init_recommender = QueryBasedRecommender(3, 2, 
                                                 3, 2, 
                                                 **fmim.__dict__)
        main_recommender = LinRelRecommender(3, 3, 
                                             1., .5, 
                                             1., .5, 
                                             None,None,
                                             None,None,
                                             **fmim.__dict__)

        self.app = CmdApp(OnePassPropagator, OverrideUpdater, 
                          init_recommender, main_recommender)        
        
        self.session = get_session()
        
        #add recommended list
        self.session.add_doc_recom_list(Document.get_many([1,2,3]))
        self.session.add_kw_recom_list(Keyword.get_many(["a", "redis", "database"]))
        
        self.fb = {
            "docs": [[1, .5]],
            "kws": [["redis", .5]],
            "dockws": [["redis", 1, .5]]
        }
        
        random.seed(123456)
开发者ID:samim23,项目名称:rl-search,代码行数:29,代码来源:cmdapp_test.py

示例12: test_recommend

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
    def test_recommend(self):
        docs, kws = self.r.recommend(self.session, 
                                     4, 4, 
                                     1, .5,
                                     1., .5)

        self.assertEqual(Document.get_many([1,8,2,6]), docs)
        self.assertEqual(Keyword.get_many(["redis", "database", "the", "mysql", "a", "python"]), kws)
开发者ID:samim23,项目名称:rl-search,代码行数:10,代码来源:linrel_recommender_test.py

示例13: test_recommend_keywords

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
 def test_recommend_keywords(self):
     kws = self.r.recommend_keywords(Document.get_many([6, 1]), 5, 3, 
                                     query_keywords = Keyword.get_many(["python", "redis", 
                                                                        "non-existing"]))
     kw_from_recom_docs = kws[:3]
     kw_from_assoc_docs = kws[3:]
     
     self.assertEqual(5, len(kws))
     self.assertEqual(list(Keyword.get_many(["python", "redis"])), kw_from_recom_docs[:2]) #the first two should be python and redis
     
     for kw in kw_from_recom_docs:
         self.assertTrue(kw["recommended"])
     for kw in kw_from_assoc_docs:
         self.assertFalse(kw["recommended"])
         
     #no easy way to further test the elements of the kws
     pass
开发者ID:samim23,项目名称:rl-search,代码行数:19,代码来源:query_recommender_test.py

示例14: test_recommend_documents_sensible_query

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
 def test_recommend_documents_sensible_query(self):
     """
     query that has keywords existing in the documents' keyword list
     """
     query = "database, python, redis"
     matched_docs, query_keywords = self.r.recommend_documents(query, 4)
     
     self.assertEqual(Document.get_many([6,1,2,5]), matched_docs)
     self.assertEqual(Keyword.get_many(["database", "python", "redis"]), query_keywords)
开发者ID:samim23,项目名称:rl-search,代码行数:11,代码来源:query_recommender_test.py

示例15: test_recommend_main

# 需要导入模块: from scinet3.model import Keyword [as 别名]
# 或者: from scinet3.model.Keyword import get_many [as 别名]
 def test_recommend_main(self):
     #receive the feedback first
     self.app.receive_feedbacks(self.session, self.fb)
     
     docs , kws = self.app.recommend(start = False, session = self.session)
     self.assertEqual(Document.get_many([1,2,6]), 
                      docs)
     self.assertEqual(Keyword.get_many(["redis", "database", "a", "python", "the"]), 
                      kws)
开发者ID:samim23,项目名称:rl-search,代码行数:11,代码来源:cmdapp_test.py


注:本文中的scinet3.model.Keyword.get_many方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。