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


Python Question.add_dimension方法代码示例

本文整理汇总了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'])
开发者ID:mdrouhard,项目名称:textvisdrg,代码行数:20,代码来源:tests.py

示例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()
开发者ID:mdrouhard,项目名称:textvisdrg,代码行数:21,代码来源:tests.py


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