import streamlit as st from process import process_choice,process_other, generate_image, analyze_post # 定义问题列表 QUESTIONS = [ "Question1: Are you usually?", "Question2: Among your friends, you are?", "Question3: In doing something that many other people do, you would rather?", "Question4: Do you admire the people who are?", "Question5: Do you more often let?", "Question6: Do you usually?", "Question7: When you go somewhere for the day, you would rather", "Question8: When you have a special job to do, you like to" ] OPTIONS = { QUESTIONS[0]: ["A 'Good Mixer with groups of people", "Rather quiet and reserved"], # Extrovert (E) vs. Introvert (I) QUESTIONS[1]: ["Full of news about everybody", "One of the last to hear what is going on"], #Extrovert (E) vs. Introvert (I) QUESTIONS[2]: ["Invent a way of your own", "Do it in the accepted way "], #Intuition, Sensing QUESTIONS[3]: ["Normal-acting to never make themselves the center of attention", "Too original and individual to care whether they are the center of attention or not"],# Sensing, Intuition QUESTIONS[4]: ["Your heart rule your head", "Your head rule your heart"], ## Feeling, Thinking QUESTIONS[5]: ["Value emotion more than logic", "Value logic more than feelings"], # Thinking, Feeling QUESTIONS[6]: ["Plan what you will do and when", "Just go"], # Judging, Perceiving QUESTIONS[7]: ["Organize it carefully before you start", "Find out what is necessary as you go along"] # Judging, Perceiving } def main(): # 页面选择 page = st.sidebar.radio("Choose Test Method", ["Questionnaire", "Post upload"]) if page == "Questionnaire": questionnaire() elif page == "Post upload": post() def questionnaire(): custom_css = """ """ st.markdown(custom_css, unsafe_allow_html=True) st.title("MBTI Personality Insight") st.markdown("""
Discover deeper insights about your Myers-Briggs Type Indicator (MBTI) personality through this interactive questionnaire. If the options couldn't describe you, customize your answers.
""", unsafe_allow_html=True) # 使用session_state来跟踪当前的问题索引 if "current_question_index" not in st.session_state: st.session_state.current_question_index = 0 # 初始化两个答案字典 if "answers_choices" not in st.session_state: st.session_state.answers_choices = {} if "answers_other" not in st.session_state: st.session_state.answers_other = {} # 显示当前问题,使用Markdown增大字体并添加额外的空间' cols = st.columns([4, 1]) # 在左侧列显示问题 current_question = QUESTIONS[st.session_state.current_question_index] cols[0].markdown(f'Upload posts to get insights about MBTI personality analysis.
""", unsafe_allow_html=True) # 创建文本输入框 user_input = st.text_area("Enter your post here:") # 创建提交按钮 if st.button("Submit"): # 在这里调用你的文本分析函数 final = analyze_post(user_input) # 假设你有一个analyze_text函数来进行文本分析 st.subheader("Analysis Result:") generate_image(final) if __name__ == "__main__": main()