samedi 29 mai 2021

What is quickest way to turn my python philosophical 'personality' like quiz into a web app with minimal knowledge outside of python?

Recently I wrote a fifty-seven question philosophical quiz with the hopes of aiding people in realizing their philosophical views and then proceed to match them with a like-minded philosopher. After having friends do the quiz on my laptop, I wish for there to be an easier way to allow all my friends to take the quiz. Does anyone have a method in mind in which I could easily make it accessible to everyone on their own devices? I would greatly appreciate any points in the right direction and useful tips. Thank you very much! The program relies on dictionaries and text files to accomplish the goal. Here is the code:

import wikipedia
import time
catdict = {
    "theism": 0,
    "pantheism": 0,
    "deism": 0,
    "antiRealist": 0,
    "moralRealist": 0,
    "divinecommand": 0,
    "egoism": 0,
    "altruism": 0,
    "deontology": 0,
    "consequentialism": 0,
    "sentimentalism": 0,
    "empiricalIdealism": 0,
    "transcendentalIdealism": 0,
    "realism": 0,
    "skepticism": 0,
    "empiricism": 0,
    "rationalism": 0,
    "foundationalism": 0,
}
print('Welcome to the philosophical personality quiz, where you can learn more about yourself and great thinkers in '
      'the past and present.')
time.sleep(5)
print('This quiz will take approximately 10-15 minutes. You will receive your match at the end.')
time.sleep(3.5)
print("For each of the following statements:")
print("Enter 1 for strongly agree.\nEnter 2 for Agree\nEnter 3 for "
                                                 "Disagree\nEnter 4 for Strongly Disagree. ")
time.sleep(3)
def question():
    with open("questions.txt", "r") as txt:
        for line in txt:
            question = line.split(",")
            user_input = int(input(question[0]))
            if user_input == 1:
                catdict[question[1]] += 20
            elif user_input == 2:
                catdict[question[1]] += 12
            elif user_input == 3:
                catdict[question[1]] -= 12
                if catdict[question[1]] <= 0:
                    catdict[question[1]] += 12
            elif user_input == 4:
                catdict[question[1]] -= 20
                if catdict[question[1]] <= 0:
                    catdict[question[1]] += 20
            else:
                print(user_input, type(user_input))


def analysis():
    p = open('philosophers.txt').read()

    pDict = {}
    pFile = open("philosophers.txt").read()

    pList = pFile.split(';')

    for entry in pList:
        spDict = {}
        for line in entry.split('\n'):
            key, value = line.split()
            spDict[key] = value
        name = spDict['name']
        pDict[name] = spDict

    total = 0
    for key in pDict:
        del pDict[key]['name']
    output ={}
    for philosopher, their_categories in pDict.items():
        total_difference = 0
        for i in range(len(catdict) - 1):
            my_values = list(catdict.values())
            their_values = list(their_categories.values())
            difference = int(their_values[i]) - int(my_values[i])
            total_difference += abs(difference)
        output[philosopher] = total_difference
    global match
    print(output)
    match = (min(output.values()), list(output.keys())[list(output.values()).index(min(output.values()))])
    print(match)


def wikipediaSummary():
    print('Thank you for completing the quiz, here are your values:\n')
    print(catdict, '\n')
    print('\nAnalyzing your results...')
    time.sleep(3)
    print('Here is a brief summary of the philosopher you are closest to:')
    time.sleep(0.7)
    d = wikipedia.summary(match[1], auto_suggest=False)
    print(d)


question()
analysis()
wikipediaSummary()

for the text files, the first one named 'philosophers.txt'

name Kant
theism 36
pantheism 0
deism 0
antiRealist 0
moralRealist 80
divinecommand 0
egoism 23
altruism 35
deontology 80
consequentialism 0
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 80
realism 0
skepticism 0
empiricism 20
rationalism 30
foundationalism 45;name AynRand
theism 0
pantheism 0
deism 0
antiRealist 0
moralRealist 80
divinecommand 0
egoism 80
altruism 0
deontology 60
consequentialism 40
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 0
realism 60
skepticism 0
empiricism 55
rationalism 15
foundationalism 55;name Descartes
theism 58
pantheism 0
deism 0
antiRealist 0
moralRealist 65
divinecommand 40
egoism 0
altruism 25
deontology 0
consequentialism 0
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 0
realism 0
skepticism 40
empiricism 0
rationalism 80
foundationalism 100;name Hegel
theism 42
pantheism 23
deism 0
antiRealist 0
moralRealist 60
divinecommand 0
egoism 0
altruism 0
deontology 0
consequentialism 15
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 76
realism 0
skepticism 0
empiricism 0
rationalism 80
foundationalism 27;name Maimonides
theism 85
pantheism 0
deism 0
antiRealist 0
moralRealist 70
divinecommand 80
egoism 0
altruism 35
deontology 25
consequentialism 10
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 0
realism 30
skepticism 18
empiricism 0
rationalism 80
foundationalism 80;name JohnStuartMill
theism 0
pantheism 0
deism 0
antiRealist 0
moralRealist 80
divinecommand 0
egoism 0
altruism 60
deontology 0
consequentialism 80
sentimentalism 0
empiricalIdealism 55
transcendentalIdealism 0
realism 10
skepticism 25
empiricism 80
rationalism 0
foundationalism 35;name Locke
theism 60
pantheism 0
deism 0
antiRealist 0
moralRealist 70
divinecommand 0
egoism 30
altruism 15
deontology 50
consequentialism 0
empiricalIdealism 0
transcendentalIdealism 0
realism 60
skepticism 0
empiricism 80
rationalism 0
foundationalism 30;name DavidHume
theism 18
pantheism 10
deism 5
antiRealist 40
moralRealist 10
divinecommand 0
egoism 20
altruism 20
deontology 0
consequentialism 0
sentimentalism 60
empiricalIdealism 30
transcendentalIdealism 0
realism 10
skepticism 65
empiricism 80
rationalism 0
foundationalism 30;name plato
theism 29
pantheism 10
deism 5
antiRealist 0
moralRealist 30
divinecommand 0
egoism 55
altruism 20
deontology 0
consequentialism 15
sentimentalism 0
empiricalIdealism 20
transcendentalIdealism 0
realism 40
skepticism 0
empiricism 0
rationalism 45
foundationalism 30;name Aristotle
theism 20
pantheism 0
deism 0
antiRealist 0
moralRealist 45
divinecommand 0
egoism 0
altruism 20
deontology 30
consequentialism 0
sentimentalism 0
empiricalIdealism 0
transcendentalIdealism 0
realism 50
skepticism 0
empiricism 80
rationalism 30
foundationalism 30;name GeorgeBerkeley
theism 70
pantheism 0
deism 0
antiRealist 0
moralRealist 45
divinecommand 0
egoism 0
altruism 10
deontology 20
consequentialism 55
sentimentalism 0
empiricalIdealism 80
transcendentalIdealism 0
realism 0
skepticism 0
empiricism 80
rationalism 0
foundationalism 30;name Leibniz
theism 35
pantheism 0
deism 0
antiRealist 0
moralRealist 45
divinecommand 0
egoism 0
altruism 35
deontology 30
consequentialism 10
sentimentalism 0
empiricalIdealism 35
transcendentalIdealism 0
realism 20
skepticism 0
empiricism 0
rationalism 84
foundationalism 30;name FriedrichNietzsche
theism 0
pantheism 0
deism 0
antiRealist 36
moralRealist 0
divinecommand 0
egoism 24
altruism 0
deontology 0
consequentialism 0
sentimentalism 48
empiricalIdealism 36
transcendentalIdealism 0
realism 24
skepticism 0
empiricism 36
rationalism 0
foundationalism 0;name Spinoza
theism 24
pantheism 24
deism 0
antiRealist 42
moralRealist 0
divinecommand 0
egoism 24
altruism 0
deontology 0
consequentialism 0
sentimentalism 0
empiricalIdealism 24
transcendentalIdealism 0
realism 24
skepticism 0
empiricism 0
rationalism 80
foundationalism 24;name Schopenhauer
theism 12
pantheism 0
deism 0
antiRealist 24
moralRealist 12
divinecommand 0
egoism 0
altruism 36
deontology 12
consequentialism 0
sentimentalism 12
empiricalIdealism 0
transcendentalIdealism 60
realism 0
skepticism 0
empiricism 0
rationalism 0
foundationalism 12;name Aquinas
theism 80
pantheism 0
deism 0
antiRealist 0
moralRealist 48
divinecommand 12
egoism 0
altruism 36
deontology 24
consequentialism 0
sentimentalism 0
empiricalIdealism 24
transcendentalIdealism 12
realism 12
skepticism 0
empiricism 40
rationalism 0
foundationalism 24

and lastly 'questions.txt':

God is real.,theism,
I am a faithful person.,theism,
I am a spiritual person.,theism,
The Abrahamic God is the only God.,theism,
God is the universe.,pantheism,
God is synonymous with nature.,pantheism,
God is strictly a creator of the universe.,deism,
Moral statements are simply an opinion.,antiRealist,
Nothing is good or bad independent of human beliefs or desires.,antiRealist,
The validity of moral statements can change with the times.,antiRealist,
Morals vary from culture to culture.,antiRealist,
Morals are personal judgments so we should not pretend them to be objective.,antiRealist,
Moral statements are objectively true or objectively false.,moralRealist,
I can confidently condemn certain acts as immoral.,moralRealist,
Morals should be debated.,moralRealist,
There are no 'my morals' and 'your morals'. There are only correct morals.,moralRealist,
Moral facts come from God.,divinecommand,
Only God can know what is moral.,divinecommand,
We should not question what God decrees as moral.,divinecommand,
One's self is most important when considering moral decisions.,egoism,
All of our actions come from a psychologically selfish place.,egoism,
Sometimes you have to use the heads of others to achieve success.,egoism,
We should put others before ourselves.,altruism,
We have a duty to others.,altruism,
Mankind will naturaly develop sympathy for each other.,altruism,
The intent of the action matters more for morality than the consequence.,deontology,
You should do the right thing purely because it is your duty to do the right thing.,deontology,
A good will and good heart is all one needs to be moral.,deontology,
To be free is to be moral.,deontology,
Society's goal should be to maximize happiness for everyone possible at whatever cost.,consequentialism,
Even if the action was done for poor reaons - a good outcome is all that matters.,consequentialism,
Morality is about achieving the most amount of happiness for the most amount of people.,consequentialism,
I would pull the lever in the trolley car scenario.,consequentialism,
Emotion is the driving force behind morality.,sentimentalism,
Morality is based off the emotions of the victims.,sentimentalism,
Emotion tells us the most about morality.,sentimentalism,
Reality is entirely in the mind.,empiricalIdealism,
Once we stop perceiving something - it ceases.,empiricalIdealism,
We experience distorted versions of an objective reality.,transcendentalIdealism,
Space and time are intuitions of the mind and not attatched to objects themselves.,transcendentalIdealism,
We live in a simulation.,transcendentalIdealism,
We experience reality directly.,realism,
Natural sciences will uncover the answers to Philosophical questions.,realism,
We are unable to truly know most things exterior to ourselves.,skepticism,
I cannot know more than simply that I exist.,skepticism,
Chances are: You do not exist.,skepticism,
Knowledge is primarily gained through experiences.,empiricism,
Knowledge is better gained through experience.,empiricism,
Only experience can ground and verify abstract ideas.,empiricism,
The human baby is born tabula rasa (blank slate).,empiricism,
Knowledge is primarily gained through reason.,rationalism,
We are able to know something purely by reason.,rationalism,
Babies are born with the innate capacity for certain things.,rationalism,
It is far easier to be certain of our thought-out reason than our experiences.,rationalism,
We can reduce all knowledge down to a few starting premises which are undoubtedly true.,foundationalism,
Man can know some things for certain.,foundationalism,
Math is certain.,foundationalism,



Aucun commentaire:

Enregistrer un commentaire