本文整理汇总了Python中scinet3.model.Document.load_all_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python Document.load_all_from_db方法的具体用法?Python Document.load_all_from_db怎么用?Python Document.load_all_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scinet3.model.Document
的用法示例。
在下文中一共展示了Document.load_all_from_db方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scinet3.model import Document [as 别名]
# 或者: from scinet3.model.Document import load_all_from_db [as 别名]
def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
if not Document.all_docs_loaded:
print "loading docs from db..."
Document.load_all_from_db()
示例2: setUp
# 需要导入模块: from scinet3.model import Document [as 别名]
# 或者: from scinet3.model.Document import load_all_from_db [as 别名]
def setUp(self):
#load all first
self.docs = Document.load_all_from_db()
示例3: import
# 需要导入模块: from scinet3.model import Document [as 别名]
# 或者: from scinet3.model.Document import load_all_from_db [as 别名]
##########################
# Test the evaluation module
##########################
from util import (config_doc_kw_model, NumericTestCase)
from scinet3.util.ir_eval import GoalBasedEvaluator
from scinet3.model import (Document, Keyword)
config_doc_kw_model()
Document.load_all_from_db()
class GoalBasedEvaluationTest(NumericTestCase):
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)
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])
示例4: import
# 需要导入模块: from scinet3.model import Document [as 别名]
# 或者: from scinet3.model.Document import load_all_from_db [as 别名]
# Test for document feedback receiver
##############################
import unittest
import torndb
import redis
from scinet3.model import Document, Keyword
from util import (config_doc_kw_model, get_session)
#config model,
#only done once
config_doc_kw_model()
docs = Document.load_all_from_db()
class DocumentFeedbackTest(unittest.TestCase):
def setUp(self):
#session
self.session = get_session()
def test_rec_from_doc(self):
"""
getter/setting for receiving feedback from document
"""
doc = Document.get(1)
doc.rec_fb_from_doc(doc, 1, self.session)
self.assertEqual(1, doc.fb_from_doc(self.session))