| import gradio as gr | |
| def get_input(): | |
| return gr.components.Textbox(lines=20, placeholder="MBTI 진단을 위한 질문에 답변하세요.") | |
| input_ui = get_input() | |
| def diagnose_mbti(input): | |
| extroverted = "E" in input | |
| intuitive = "N" in input | |
| thinking = "T" in input | |
| judging = "J" in input | |
| if extroverted and intuitive and thinking and judging: | |
| return "INTJ" | |
| elif extroverted and intuitive and thinking and not judging: | |
| return "ENTP" | |
| elif extroverted and intuitive and not thinking and judging: | |
| return "ENFJ" | |
| elif extroverted and intuitive and not thinking and not judging: | |
| return "ENTP" | |
| elif extroverted and not intuitive and thinking and judging: | |
| return "ESTJ" | |
| elif extroverted and not intuitive and thinking and not judging: | |
| return "ESTP" | |
| elif extroverted and not intuitive and not thinking and judging: | |
| return "ESFJ" | |
| elif extroverted and not intuitive and not thinking and not judging: | |
| return "ESFP" | |
| elif not extroverted and intuitive and thinking and judging: | |
| return "INTJ" | |
| elif not extroverted and intuitive and thinking and not judging: | |
| return "INTP" | |
| elif not extroverted and intuitive and not thinking and judging: | |
| return "INFJ" | |
| elif not extroverted and intuitive and not thinking and not judging: | |
| return "INFP" | |
| elif not extroverted and not intuitive and thinking and judging: | |
| return "ISTJ" | |
| elif not extroverted and not intuitive and thinking and not judging: | |
| return "ISTP" | |
| elif not extroverted and not intuitive and not thinking and judging: | |
| return "ISFJ" | |
| elif not extroverted and not intuitive and not thinking and not judging: | |
| return "ISFP" | |
| diagnose_ui = gr.Function(fn=diagnose_mbti, inputs=input_ui, outputs="text", name="MBTI 유형 진단") | |
| def print_result(mbti): | |
| return f" tada! Your MBTI type is {mbti}." | |
| output_ui = gr.Function(fn=print_result, inputs=diagnose_ui, outputs="text", name="결과 출력") | |
| gr.Interface(fn=output_ui, inputs=input_ui, outputs="text").launch() |