{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "https://ipip.ori.org/New_IPIP-50-item-scale.htm" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# gradio" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#os.system('pip install openpyxl') #works for huggingface-spaces\n", "#score of each latent variable ranges in [10, 50]\n", "def correct_score(score, big_5_indicator):\n", " big_5_sign = big_5_indicator[0]\n", " big_5_num = int(big_5_indicator[1])\n", " dict1 = {\n", " 1 : 'Extraversion',\n", " 2 : 'Agreeableness',\n", " 3 : 'Conscientiousness',\n", " 4 : 'Neuroticism',\n", " 5 : 'Openness'\n", " }\n", " if big_5_sign=='+':\n", " return [dict1[big_5_num], score]\n", " elif big_5_sign =='-':\n", " return [dict1[big_5_num], 6-score]\n", "# correct_score(3, big_5_indicator='-2')\n", "\n", "def make_question(q):\n", " q = gr.Radio(choices=[1, 2, 3, 4, 5], label=q, value=1) #, value=5\n", " return q\n", "\n", "def calculate_personality_score(questions, list_questions):\n", " personality = {\n", " 'Extraversion': 0,\n", " 'Agreeableness': 0,\n", " 'Conscientiousness': 0,\n", " 'Neuroticism': 0,\n", " 'Openness': 0\n", " }\n", " for question in list_questions:\n", " big_5_indicator = questions[question[0]]\n", " score = correct_score(question[1], big_5_indicator=big_5_indicator)\n", " personality[score[0]] += score[1]\n", " return personality" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7862\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "