本文整理汇总了Python中models.Question.add_dimension方法的典型用法代码示例。如果您正苦于以下问题:Python Question.add_dimension方法的具体用法?Python Question.add_dimension怎么用?Python Question.add_dimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Question
的用法示例。
在下文中一共展示了Question.add_dimension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_question_with_dup_dimensions
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import add_dimension [as 别名]
def test_question_with_dup_dimensions(self):
"""Questions can be linked to dimensions twice"""
question = Question(source=self.article, text="This is a another question")
question.save()
question.add_dimension("hashtags")
question.add_dimension("time")
question.add_dimension("hashtags")
question.save()
dimensions = question.ordered_dimensions
# retrieves the proper number of dimensions
self.assertEquals(dimensions.count(), 3)
# they are in the proper order
keys = [d.key for d in dimensions]
self.assertEquals(keys, ['hashtags', 'time', 'hashtags'])
示例2: setUp
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import add_dimension [as 别名]
def setUp(self):
article = Article.objects.create(year=2014, authors="Lalal, Lala", link="http://doi.org/xDrz", title="this is a mock paper", venue="A mock conference")
self.article = article
question = Question(source=article, text="This is a question")
question.save()
question.add_dimension("hashtags")
question.add_dimension("time")
question.save()
question = Question(source=article, text="This is another question")
question.save()
question.add_dimension("urls")
question.add_dimension("language")
question.save()
question = Question(source=article, text="This is the 3rd question")
question.save()
question.add_dimension("sentiment")
question.add_dimension("language")
question.save()