예제 #1
0
def test_sample_dream_two():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "Hi Siggy", "I am Hannah",
        "she had a dream about going on a journey with a friend. As we left, a really bad storm hit.",
        "It was supposed to be fun but took a dark turn", "new dream",
        "I took a trip to the beach with my family. Mum and dad had a big argument",
        "Everything was good until then", "nope", "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Hannah"

    assert therapist.client.get_dream().get_subject() == Subject.SOMEONE
    assert therapist.client.get_dream().get_topics() == [
        Topic.DEATH, Topic.PSYCHE
    ]
    assert therapist.client.get_dream().get_ratings() == [
        Rating.VERY_NEGATIVE, Rating.NEGATIVE
    ]
    assert therapist.client.get_dream().get_direct_object() == "Storm"

    assert therapist.client.get_dream(1).get_subject() == Subject.CLIENT
    assert therapist.client.get_dream(1).get_topics() == [
        Topic.DEATH, Topic.PSYCHE, Topic.OEDIPUS_COMPLEX
    ]
    assert therapist.client.get_dream(1).get_ratings() == [Rating.POSITIVE]
    assert therapist.client.get_dream(1).get_direct_object() == "Dad"
예제 #2
0
def test_therapist_get_2_dreams():

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()
예제 #3
0
def test_therapist_get_dream():

    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "This is Alex here. How are you?",
        "I rode through the dessert on a horse with no name",
        "It felt good to be out of the rain", "no", "new dream",
        "In the dessert, you can't remember your car",
        "Because there aint no one to give you no shame.", "nothing",
        "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Alex"

    assert therapist.client.get_dream() is not None

    assert therapist.client.get_dream().get_subject() == Subject.CLIENT

    assert therapist.client.get_dream().get_topics() == [Topic.PARENTS]

    assert therapist.client.get_dream().get_ratings() == [Rating.POSITIVE]

    assert therapist.client.get_dream().get_direct_object() == "Horse"
예제 #4
0
def test_sample_dream_five():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "Hi. My name is blah", "It's actually Sarah",
        "Someone broke into my house. They were dressed in black. I chased him and he ran into the darkness.",
        "It was scary and spooky", "no", "nope", "new dream",
        "I am sitting in a train and it goes through all these beautiful places, from mountains to fields",
        "very good", "no", "All good Siggy", "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Sarah"

    assert therapist.client.get_dream().get_subject() == Subject.SOMEONE
    assert therapist.client.get_dream().get_topics() == [
        Topic.BODY, Topic.PSYCHE
    ]
    assert therapist.client.get_dream().get_ratings() == [
        Rating.VERY_NEGATIVE, Rating.NEGATIVE
    ]
    assert therapist.client.get_dream().get_direct_object() == "Chase"

    assert therapist.client.get_dream(1).get_subject() == Subject.CLIENT
    assert therapist.client.get_dream(1).get_topics() == [
        Topic.SEX_SYMBOL, Topic.PSYCHE
    ]
    assert therapist.client.get_dream(1).get_ratings() == [Rating.POSITIVE]
    assert therapist.client.get_dream(1).get_direct_object() == "Field"
예제 #5
0
def test_sample_dream_four():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "I am Warrick. How are you?",
        "She is standing in front of the drawer of her writing table, with which she is so familiar that she knows immediately if anybody has been through it",
        "It was comforting", "no", "no", "new dream",
        "I was walking through the street and a load of naked people started chasing me.",
        "It was a weird. Ultimately fun, I guess", "That does it"
        "F**k off!", "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Warrick"

    assert therapist.client.get_dream().get_subject() == Subject.SOMEONE
    assert therapist.client.get_dream().get_topics() == [Topic.OEDIPUS_COMPLEX]
    assert therapist.client.get_dream().get_ratings() == [Rating.POSITIVE]
    assert therapist.client.get_dream().get_direct_object() == "Table"

    assert therapist.client.get_dream(1).get_subject() == Subject.CLIENT
    assert therapist.client.get_dream(1).get_topics() == [
        Topic.BODY, Topic.PSYCHE
    ]
    assert therapist.client.get_dream(1).get_ratings() == [Rating.POSITIVE]
    assert therapist.client.get_dream(1).get_direct_object() == "Chase"
예제 #6
0
def test_sample_dream_three():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "Hi", "It's Chris here",
        "She is going through the hall of her house and strikes her head against the low-hanging chandelier, so that her head bleeds",
        "It was my friends house", "It was darker than usual",
        "not much else i remember", "no", "new dream",
        "I was walking past a mansion and a naked person was lying in the sun.",
        "I remember the weather being nice. She was rather beautiful",
        "not really", "no!", "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Chris"

    assert therapist.client.get_dream().get_subject() == Subject.SOMEONE
    assert therapist.client.get_dream().get_topics() == [Topic.BODY]
    assert therapist.client.get_dream().get_ratings() == [Rating.NEGATIVE]
    assert therapist.client.get_dream().get_direct_object() == "House"

    assert therapist.client.get_dream(1).get_subject() == Subject.CLIENT
    assert therapist.client.get_dream(1).get_topics() == [Topic.BODY]
    assert therapist.client.get_dream(1).get_ratings() == [
        Rating.POSITIVE, Rating.POSITIVE
    ]
    assert therapist.client.get_dream(1).get_direct_object() == "Naked"
예제 #7
0
def main(argv=None):
    """
	> python -m Fralysis.GUI
	> pytest

	Main method to run terminal interface

	:param argv:
	:return:
	"""
    #class StartTherapySession:

    #def __init__(self):
    if DEBUG_ENABLED:
        print("0 - Program starts")

    in_out = InputOutput(interface_type=InputOutput.INTERFACE_TYPE_SIMPLE)
    #in_out = InputOutput(interface_type=InputOutput.INTERFACE_TYPE_KIVY)
    therapist = Therapist(in_out=in_out)

    success = therapist.start_therapy()

    if DEBUG_ENABLED:
        if success:
            print("Therapy was successful")
        else:
            print("Therapy was not successful")

    if DEBUG_ENABLED:
        print("END - Program exits")
예제 #8
0
    def __init__(self, input_widget, output_widget):
        super(InputOutputGui, self).__init__()
        self.input_widget = input_widget
        self.output_widget = output_widget
        self.msg = ""
        self.finish = False

        self.therapist = Therapist(in_out=self)
예제 #9
0
def test_therapist_get_name():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = "******"

    in_out = InputOutput(interface_type=InputOutput.DEFAULT_PROMPT)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Alex"
def test_smoking():
    """
    > pytest -s

    :return:
    """
    #DEBUG_ENABLED = True
    InputOutput.CACHE_MODE = True
    in_out = InputOutput(interface_type=InputOutput.INTERFACE_TYPE_SIMPLE)

    InputOutput.INPUT_CACHE_DATA_USER = "******"

    therapist = Therapist(in_out=in_out)

    assert therapist.interview.ask_for_name()

    print("name: {}".format(therapist.client.get_name()))

    assert therapist.client.get_name() == "Alex"

    InputOutput.INPUT_CACHE_DATA_USER = "******"
    #InputOutput.INPUT_CACHE_DATA_USER = "******"

    message_for_dream = MessageTypeAnalysis(
        InputOutput.INPUT_CACHE_DATA_USER).is_dream(Request.SUBJECT)
    a_dream = Dream(message_for_dream)
    AnalyseDream(a_dream)

    assert a_dream.get_subject() == Subject.SOMEONE
    assert a_dream.get_direct_object() == "Car"
    assert a_dream.get_ratings() == [Rating.NEGATIVE]
예제 #11
0
def test_sample_dream_one():
    InputOutput.CACHE_MODE = True
    InputOutput.INPUT_CACHE_DATA_USER = [
        "Hi", "My name is Sam",
        "I was cycling around Brighton. A red car started chasing me. It hit me. A man got out. It turned out to be my father.",
        "our current relationship is not great",
        "It was dark when this happened", "get analysis"
    ]

    in_out = InputOutput(interface_type=InputOutput.CACHE_MODE)

    therapist = Therapist(in_out=in_out)

    therapist.start_therapy()

    assert therapist.client.get_name() == "Sam"

    assert therapist.client.get_dream().get_subject() == Subject.CLIENT
    assert therapist.client.get_dream().get_topics() == [
        Topic.PSYCHE, Topic.SEX_SYMBOL, Topic.OEDIPUS_COMPLEX
    ]
    assert therapist.client.get_dream().get_ratings() == [Rating.NEGATIVE]
    assert therapist.client.get_dream().get_direct_object() == "Father"
def test_ask_for_name():
    """
    > pytest -s

    :return:
    """

    InputOutput.CACHE_MODE = True
    in_out = InputOutput(interface_type=InputOutput.INTERFACE_TYPE_SIMPLE)

    InputOutput.INPUT_CACHE_DATA_USER = [
        "This is Alex here. How are you?",
    ]

    therapist = Therapist(in_out=in_out)

    assert therapist.interview.ask_for_name()

    print("name: {}".format(therapist.client.get_name()))

    assert therapist.client.get_name() == "Alex"
예제 #13
0
class InputOutputGui(threading.Thread):
    """
    Thread to parse data between view and controller
    """

    DEFAULT_PROMPT = "action"

    def __init__(self, input_widget, output_widget):
        super(InputOutputGui, self).__init__()
        self.input_widget = input_widget
        self.output_widget = output_widget
        self.msg = ""
        self.finish = False

        self.therapist = Therapist(in_out=self)

    def stop(self):
        sys.exit()
        #raise Exception("thread stopping...")

    def run(self):
        print("InputOutputGui is Running!")
        self.therapist.start_therapy()

    def callback_read(self, instance=None):
        if instance is None:
            raise Exception("callback invoked but instance is None!")

        self.msg = instance.text
        #self.msg = instance
        self.output_widget.add_widget(
            DreamDict("User {}".format(instance.text)))
        instance.text = ""

        if "bye" in self.msg.lower():
            self.finish = True

        print("callback_read> {}".format(self.msg))

    def read_message(self, prompt=DEFAULT_PROMPT):
        if self.finish:
            self.stop()

        print("read_message.{}> {}".format(prompt, self.msg))
        count = 0
        while self.msg is None or self.msg == "":
            count += 1
            print("read_message.sleeping")
            sleep(2)
            if count > 500:
                self.stop()

        message = self.msg
        self.msg = ""
        return (message)

    def write_message(self, message, prompt=DEFAULT_PROMPT):
        print("write_message.{}> {}".format(prompt, message))
        self.output_widget.add_widget(DreamDict(
            "Therapist {}".format(message)))
        sleep(3)