from otree.api import * import pandas as pd doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Label_Survey_Manual' PLAYERS_PER_GROUP = None NUM_ROUNDS = 4 file=pd.read_excel("./Senti_Weibo/情感分析_20220724.xlsx") answer_1 = [[0, '反对'], [1, '支持'], [2, '中立'],[3, '无关']] answer_2 = [[0, '积极'], [1, '消极'], [2, '中立'],[3, '无关']] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): c=C() # answer = c.answer answer_2 = c.answer_2 answer_1 = c.answer_1 df=c.file sen_result = models.IntegerField() sen_result_changed = models.IntegerField( initial=0 ) on_demand = models.IntegerField( initial=0 ) age = models.IntegerField( label='1、您的年龄段是?', choices=[['1', '18岁以下'], ['2', '18-25岁'], ['3', '26-30岁'], ['4', '31-35岁'], ['5', '35岁以上']], ) gender = models.StringField( choices=[['1', '男性'], ['2', '女性']], label='2、您的性别是?', ) education = models.StringField( choices=[['1', '高中'], ['2', '大专'], ['3', '本科'], ['4', '硕士'], ['5', '博士及以上']], label='3、您的教育程度是?', ) Q1 = models.IntegerField( label='4、我觉得这项任务需要集中精神:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q2 = models.IntegerField( label='5、我觉得成功地完成了我所需要完成的任务:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q3 = models.IntegerField( label='6、在标注过程中,我会感到有压力、不安全、气馁、易怒和生气:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q4 = models.IntegerField( label='7、我相信AI能够根据微博内容做出正确的分类:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q5 = models.IntegerField( label='8、我相信我的标注显着提高了 AI 在文本分类方面的准确性:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q6 = models.IntegerField( label='9、我觉得我对人工智能的工作原理有了很好的理解:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) Q7 = models.IntegerField( label='10、我觉得我很好地理解了 AI 将微博分类的理由:', choices=[['1', '非常反对'], ['2', '反对'], ['3', '一般'], ['4', '赞同'], ['5', '非常赞同']] ) advice = models.StringField(label="11、您是否有其它的建议或意见,或者谈谈您对实验的感受?") # PAGES class MyPage(Page): form_model = 'player' form_fields = ['sen_result'] @staticmethod def vars_for_template(player): r_num = player.round_number r_data_0 = player.df.loc[r_num-1] r_data = r_data_0.tolist() return dict( ID=r_data[0], content_weibo=r_data[3], ID_weibo=r_data[1], time_weibo=r_data[4], sort_weibo=r_data[5], method_weibo=r_data[7], predict_weibo_att=r_data[8], predict_weibo_sen = r_data[9] ) class exit_survey(Page): form_model = 'player' form_fields = ['age','gender','education','Q1','Q2','Q3','Q4','Q5','Q6','Q7','advice'] @staticmethod def vars_for_template(player): return dict( num=player.round_number ) @staticmethod def is_displayed(player): return player.round_number == 4 class introduction(Page): def is_displayed(player): return player.round_number == 1 class Display_predict(Page): form_model = 'player' form_fields = ['sen_result_changed'] @staticmethod def vars_for_template(player): r_num = player.round_number r_data_0 = player.df.loc[r_num - 1] r_data = r_data_0.tolist() return dict( ID=r_data[0], content_weibo=r_data[3], ID_weibo=r_data[1], time_weibo=r_data[4], sort_weibo=r_data[5], method_weibo=r_data[7], predict_weibo_att=r_data[8], predict_weibo_sen=r_data[9], num=player.round_number) @staticmethod def is_displayed(player): return player.round_number > 250 or player.round_number < 150 page_sequence = [introduction,MyPage,Display_predict,exit_survey]