[Markov chain] I tried to read negative emotions into Python.

Hello. This is Pyloc. This time, I would like to make the original data of the Markov chain program using Pyhon and Janome negative emotions and see the results of each.

Program preparation

The program is [here](http://zipmonkey.wp.xdomain.jp/2020/09/18/%e3%80%90%e3%82%b3%e3%83%94%e3%83%9a%e3 % 81% a7ok% e3% 80% 91-python% e3% 81% a7% e3% 83% 9e% e3% 83% ab% e3% 82% b3% e3% 83% 95% e9% 80% a3% e9 Take from% 8e% 96% e3% 82% 92% e3% 82% 84% e3% 81% a3% e3% 81% a6% e3% 81% bf% e3% 82% 8b /). I will post it here as well.

Markov.py


# -*- coding: utf-8 -*-
 
import random
from janome.tokenizer import Tokenizer
  
#Split text data into words using Janome
def wakati(text):
    text = text.replace('\n','') #Remove line breaks
    text = text.replace('\r','') #Remove space
    t = Tokenizer()
    result =t.tokenize(text, wakati=True)
    return result
 
#The default number of sentences is 30
def generate_text(num_sentence=30):
    src = open(r"Text.Full path of txt", "r", encoding="utf-8").read() #Text.Use the absolute path of txt(If you follow the procedure, C:\Users\username\Desktop\Markov\Text.txt )
    wordlist = wakati(src)
  
    #Create a table for Markov chains
    markov = {}
    w1 = ""
    w2 = ""
    for word in wordlist:
        if w1 and w2:
            if (w1, w2) not in markov:
                markov[(w1, w2)] = []
            markov[(w1, w2)].append(word)
        w1, w2 = w2, word
  
    #Automatic sentence generation
    count_kuten = 0 #Number of Kuten "."
    num_sentence= num_sentence
    sentence = ""
    w1, w2  = random.choice(list(markov.keys()))
    while count_kuten < num_sentence:
        tmp = random.choice(markov[(w1, w2)])
        sentence += tmp
        if(tmp=='。'):
            count_kuten += 1
            sentence += '\n' #Line breaks for each sentence
        w1, w2 = w2, tmp
     
    print(sentence)
     
if __name__ == "__main__":
    generate_text()

Put this in the Markov folder you created on your desktop. Then, create a file called Text.txt in the Markov folder. Change the full path of Text.txt on the 16th line to suit your environment.

Contents of Text.txt

Text.txt is the original file of Markov. This time, it's a negative emotion, so I'll make each one.

Preparing for negative emotions

This time, I have extracted only negative emotions with Yahoo Answers. I thought it was better not to put it here, so if you want to do it, please collect it yourself.

Execution result

Run it first.

python Markov full path

After a while, you will get results. What kind of sentence is it?

First time

It will be a factor to have a failure.
What is the psychology of hatred? Even if you cut the edge, you will be overwhelmed enough to earn plastic surgery costs.
I'm in trouble because there are too many people I hate.
I can't forgive myself for being a dirty part, a sly part, a sly part, or a person.
I'm uploading a photo of the person I'm married to.
But why don't I like it mentally?
I hate ugly, dirty and sloppy and scream.
It's scary that some people stick to hatred and hatred.
I'm scared to die.
Blatant appearance discrimination against beautiful women and ugly, I have to go to work from a man like a sexual processing tool for women ... But at that time, when I become a happy human being, a crap adult, I feel this feeling How can I avoid it? Where should I go I want to die I want to die and I'm crazy about myself, and when I'm later, how do I want to feel this way? ︎ I hate myself, it's just Zubora, I wonder if it's a lump of complex! "︎" is full of my head, and I can't help but feel embarrassed and angry.
You may want to take a look at your face.
I really hate myself because I hate being ugly, dirty and sloppy, and maybe I really like myself in the mirror.
I wonder if this is a feeling of being raised by a poison parent! That's why I can't change forever ... "I hate myself so much," Why can't I stand alone, but I know that I can't make any photos online, so I can do it. My self-hatred is terrible, and I continue to be troubled every day, but I am always depressed because of my strong self-hatred.
I only care about my position.
Various emotions swirl, and I wonder if it's a bad person, a waste that I can no longer go to my favorite work, hobbies, friends and lovers! ︎Apologize sincerely! I managed to live with the feeling that I was embarrassed and didn't want to get angry.
At 30, I happened to be advised by an industrial physician to see a psychiatrist, and after spending five years interviewing a psychiatrist, I'm already in a good year.
I want to die.
However, I have a desire to do so, but I have already been suffering from self-loathing over and over again.
The child who was my best friend who married a person, nationality, nationality, religion, etc ... I can't stop hatring my parents ... I can only see repeating meso meso meso meso, but I'm betrayed by that now. But it's been a lot of pain.
"Again, my usual self-pity, I'm sorry for my poor self, I'm dying, it's a lump of complex, it's a lump of complex‼ ︎ Apologize sincerely‼ ︎ Apologize sincerely‼ I've lived a life! It doesn't go to crime.
I've managed to live for decades with the desire not to make my parents sad.
First of all, I keep harassing people even if they say "I'm a human face".
Take your mistakes straight from the front! That's why I can't change forever ... But when I'm a happy person, when I'm a junk adult, or when I'm driven by a suicide urge, how do I take a selfie of this mood?
I hate myself so much, "I think I'm feeling uncomfortable, I think I'm going to repeat suicide attempts because of my parents' ego, the absolute thoughts of the madman. You may think.
This was NG up to 30 without parental permission.
I feel uncomfortable because of such a childhood! ︎ I scream and scream.
But I don't feel like I've come into contact with it.
I can't see the person's face in the marriage partner, and there is a male clerk, but I've been a good old man, but there are a lot of strict ones ...
I wanted to get some advice from my seniors in my life, not my work.
I've only been concerned about my position because I think it's impossible.

I wonder what it is, even if Japanese is strange, only negative emotions are transmitted ...

Second time

This time, I removed all the symbols.

It is often the case that it just atrophies.
After all, if you're going to make any constructive effort.
Do you really like those values, your self-esteem, and even the children who might appear in the newspaper?
I'm sorry, I'm not sure what I want to hear.
I can't allow you to come out at 30.
When I changed my job and got involved with people, I happened to be advised by an industrial physician to see a psychiatrist even though I didn't even know how to stand, and after spending five years interviewing a psychiatrist, many people hated me. There are people who can talk, but there are a lot of strict ones.
。
I'm not sure if it's better to go in a direction that doesn't involve people.
In the end, I feel lazy and just not trying, but on the other hand, "I have to abandon my 35 years due to the wrong education of my parents, and I don't think I have the opportunity.
I also do a wrist cut.
It's not about getting married to someone, it's just that.
Is it impossible to get married or have children in particular?
thank you everybody.
What is the psychology of hatred? If you cry, you will be beaten and attempted suicide repeatedly.
I want to die.
But should I avoid it that way? Where should I go? When I feel like that, even if I'm urged to commit suicide, I know that my parents will talk even when I'm working with a company.
It's not a crime that has lived an "impossible" life.
I want you to hear my story, which I hate ugly, dirty and sloppy, and I just can't control it, so are you a waste?
Should I tell you that I have lived a decent age?
Even if my friends and parents want to die, I think it's a good year for me to be crazy enough to earn shaping costs.
I think I'm absolutely right, but I want to be forgiven for nausea, sadness, and death if I change jobs many times when I'm old and have good pictures. I think I'm just doing something like a selfish desire, but I've been involved in it on a daily basis during adolescence.
But why do I think I have a weak spirit?
I want to talk to people and get involved, but I think I want to die, take the failure straight from the front, apologize seriously, even if I think seriously, my head is full enough to earn shaping costs, but my parents are depressed I can't go without medicine, and my dad is blamed for violence. If you cry, I want to die even if I'm beaten. I'm bullied by my parents and I'm introduced to my parents. ..
Maybe I wanted some advice from my marriage partner.
I want to change my job and talk to people and get involved, but if I go to such a meeting place, I think it's unpleasant for men to take a cold attitude.
Anyway, what kind of feelings do I have, such as the part where my friends and parents desperately look good to die?
I have a strong desire to be compensated for 1.02 billion.
But humans can't allow it to appear at such times.
I think it's a good year, not just about changing jobs and getting married to someone.
I want to die.

The last sentence is a mass of negative emotions.

third time

This time I tried it without changing anything. It's about time my heart hurts ...

I don't feel like being taken an attitude or being real and not entwined.
In the end, I think it's a good year to live with the feeling of being embarrassed and not wanting to get angry, no matter what constructive efforts I make.
The inside out of love about the deep psychology of hatred is said to be indifferent, but there is no way out.
This trauma doesn't try.
It is full of sincere, kind and lovely people.
For example, a child I used to love, a nationality, a nationality, my daughter's ex-husband, and so on.
I'll make any constructive effort from hatred, I can't say that I'm embarrassed, I'm alive with the feeling that I don't want to get angry, and I don't want that person to break again So here.
First of all, I became a factor with developmental disabilities.
I feel like I really want to die.
I want to be liked I want to die.
The part that desperately looks good to die painfully, anyway, I'm dying for myself, it's a lump of complex, so I can't change forever. " ..
I'm not sure if it's better to go in a direction that doesn't involve people.
I've taken and processed dozens of photos, but during puberty, I've been in an unstable state on a daily basis.
Immediately on the spot, I don't think it will fit in with reflection.
"Again, it's my usual self-pity, I want you to hear my poor story after all, and I can't always go to a store where there is a person in my senior life. I wonder where people and children can't go. I want to die I want to die and I have no head. I'm always depressed because I really hate myself.
Maybe he said something like "grandchildren's face".
It would be helpful if you could take dozens of photos, process them, and remarriage.
35 years when young.
This is the feeling of being raised by a poison parent.
Should I tell you about myself? As long as I've taken and processed dozens of male disgust, it's just a part.
Be sure to introduce money, girlfriend, marriage, family, favorite work, hobbies, friends and lovers to your parents (I hate all of them, so here.
First of all, I'm a child with developmental disabilities, a cute child is a partner who always has a boyfriend and is married, or may be born someday), interacting with a few friends, socializing with the company.
Introducing all such things to parents who are absolutely strong (I hate all of them, so of course I can not do it.
Parents may always find a store that has that person in their marriage partner in the newspaper.
My self-hatred is terrible and I continue to be troubled every day, but I say that I am indifferent to the deep psychology of hatred, but it is much more painful.
How can I get stronger? Where should I go? I want to die I was bullied because I wanted to die, and even my parents and even the company's relationship were NG up to 30 without my parents' permission.
Since I was a child, I have lived with my mother because of overprotection and overinterference (which is crazy when I think about it now).
According to him, he is the happiest.
However, at that time, an industrial physician accidentally recommended me to see a psychiatrist, and I spent five years interviewing a psychiatrist, and I think it's a good year.
When I interact with people, I can't help thinking that the reason for harassment is "hate."

Strong negative emotions ...

Summary

It turns out that with Markov chains, even a personal computer can be made to look like a human being. Next time, let's read the quote and see ...

Recommended Posts

[Markov chain] I tried to read negative emotions into Python.
[Markov chain] I tried to read quotes and negative emotions into Python.
[Markov chain] I tried to read a quote into Python.
I tried to touch Python (installation)
I tried to automatically create a report with Markov chain
I tried to divide the file into folders with Python
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to implement permutation in Python
I tried to implement PLSA in Python 2
Python3 standard input I tried to summarize
I tried to implement ADALINE in Python
I tried to implement PPO in Python
[Python] I tried to calculate TF-IDF steadily
I tried to touch Python (basic syntax)
Markov Chain Chatbot with Python + Janome (1) Introduction to Janome
Markov Chain Chatbot with Python + Janome (2) Introduction to Markov Chain
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
I tried to implement TOPIC MODEL in Python
I tried to automate sushi making with python
I tried to implement selection sort in python
I tried Python> autopep8
I tried to debug.
I tried to paste
I tried Python> decorator
I tried to graph the packages installed in Python
When I tried to introduce python3 to atom, I got stuck
I tried to read and save automatically with VOICEROID2 2
I tried to summarize how to use matplotlib of python
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to implement a pseudo pachislot in Python
Continuation ・ I tried to make Slackbot after studying Python3
I tried to automatically read and save with VOICEROID2
I tried to get started with blender python script_Part 02
I tried to implement Dragon Quest poker in Python
I tried to implement an artificial perceptron with python
I tried to implement GA (genetic algorithm) in Python
I tried to put pytest into the actual battle
[Python] I tried to graph the top 10 eyeshadow rankings
I tried to automatically generate a password with Python3
I tried to summarize how to use pandas in python
I tried to erase the negative part of Meros
I tried to solve the problem with Python Vol.1
I tried to analyze J League data with Python
[Python] I tried to get Json of squid ring 2
I tried to access Google Spread Sheets using Python
I tried to summarize the string operations of Python
I tried to solve AOJ's number theory with Python
I tried to make an automatic character dialogue generator by N floor Markov chain
I tried to find the entropy of the image with python
I tried fp-growth with python
I tried scraping with Python
I tried to simulate how the infection spreads with Python
I tried to create API list.csv in Python from swagger.yaml
I tried to learn PredNet
I tried to make various "dummy data" with Python faker
I tried various methods to send Japanese mail with Python