It is always said that I will return to my parents' house. : man_tone3: Father "When are you getting married?" : woman_tone3: Mother "Not married yet?" : girl_tone3: Sister "When will you get married?" : baby_tone3: Niece "Won't you get married?" : baby_tone1: Niece 2 "Won't you get married?" : boy_tone3: My sister's husband "You should get married" : cat: "..."
: boy_tone5: Myself "Noisy! It's not that I'm bad that I can't get married, but the world is bad!"
Do you feel that the world is full of negative articles after marriage? I think there are many people who don't feel like getting married because of negative articles about marriage. Let's prove it with data!
: point_down_tone1: That's why I made a positive / negative judgment tool by referring to the following code (Python) that makes a positive / negative judgment. https://news.mynavi.jp/article/zeropython-58/
: stopwatch :: desktop: rattling: stopwatch ::
: point_down_tone1: Chain. Yes, it's done. First, when I tried it with "Run, Melos!" Introduced in Mynavi News, the score was exactly the same.
https://www.aozora.gr.jp/cards/000035/files/1567_14913.html
Positive 0.29 0.20 {'p': 118,'n': 83,'e': 208}
With this condition, I would like to make a negative / positive judgment for articles about marriage.
As for the dictionary used for judgment, the same as the article in Mynavi News, "Nouns of" Japanese Evaluation Polar Dictionary "of Tohoku University's Inui-Okazaki Laboratory" is used. .. .. But····
http://www.cl.ecei.tohoku.ac.jp/index.php?Open%20Resources%2FJapanese%20Sentiment%20Polarity%20Dictionary
In this dictionary, "marriage" has a positive (p) setting and "divorce" has a negative (n) setting.
Since this is not an evaluation for marriage, the following words (words including marriage) are ignored.
Ceremonial occasion e ~ exists / enhances (existence / nature) Marriage p ~ (act) Marriage partner e ~ becomes / becomes (state) objective Wedding reception p ~ There is / enhances (existence / nature) Engagement p ~ (act) Go to honeymoon e ~ (place) Marriage of convenience n ~ (act) Divorce n ~ (act)
It's not sly ...?
Then, the articles are rated on a 5-point scale according to the score, and the results are listed. (Code below)
The formula is " score "=" positive score "-" negative score "
"Super positive (0.3 or more)" "Positive (0.1 or more)" "Neither (-0.1 or more)" "Negative (-0.3 or more)" "Super negative (less than -0.3)"
: point_down_tone1: The following is the part with the arrangement.
python
with open("list.txt", "a", encoding="utf8", errors="replace") as file:
if posi >= 0.3:
judge = "Super positive"
elif posi >= 0.1:
judge = "positive"
elif posi >= -0.1:
judge = "Neither"
elif posi >= -0.3:
judge = "Negative"
elif posi < -0.3:
judge = "Super negative"
else:
judge = "Undecidable"
print("Judgment", judge)
file.write('{0}\t{1}\t{2}\t{3}\t{4:.2f}\t{5:.2f}\t{6}\n'.format(theme,title,judge,posi,res["p"] / cnt,res["n"] / cnt,res))
file.close()
Enter the search word in the argument theme and the title of the article in title.
First of all, I tried to judge the result of searching for "before marriage" ...
https://wedding.mynavi.jp/contents/press/detail/post-63/
Positive 0.11801242236024845 0.23 0.11 {'p': 37,'n': 18,'e': 106}
"Positive" judgment ...
: boy_tone5: "Well, it's like this before marriage."
Next, I searched for "couple" and judged the URL that came out. https://wedding.mynavi.jp/contents/news/2016/09/ng1/ "Negative" judgment ... : boy_tone5: "Did you see it! I became negative as soon as I got married !!" (I'm happy for some reason)
For the time being, I tried 4 cases and got the following data.
How to read the text (tab delimited): Search word, article title, judgment result, score (positive-negative), positive (ratio), negative (ratio), all words
Let's graph this once. : part_alternation_mark: Create band graph in Python: part_alternation_mark:
It seems that few people create band graphs on the net, and I feel that the reference method is not so popular on the net.
"List.txt" created above How to read the text (tab delimited): Search word, article title, judgment result, score (positive-negative), positive (ratio), negative (ratio), all words
, Use only search word, judgment result
.
python
import numpy as np
import matplotlib.pyplot as plt
jtypes=['Super positive','positive','Neither','Negative','超Negative']
color = ['#e41a1c','#ff7f00','#40cf40','#779ed8','#377eb8']
list_file = open('list.txt', 'r', encoding="utf-8")
data ={}
for line in list_file:
channel,title,j_type,point,per1,per2,allword = line.split("\t")
if channel not in data:
data[channel]= np.zeros(len(jtypes))
for kk in range(len(jtypes)):
if j_type == jtypes[kk] :
data[channel][kk] += 1
list_file.close()
values_arr=[]
tick_labels = []
np.array([])
for key,value in data.items():
values_arr.append(value)
tick_labels.append(key)
xx, yy = len(values_arr), len(jtypes)
data_arr = np.array(values_arr)
normalized = data_arr / data_arr.sum(axis=1, keepdims=True)
cumulative = np.zeros(xx)
tick = np.arange(xx,0,-1)
for y in range(yy):
plt.barh(tick, normalized[:, y], left=cumulative, color=color[y], label=jtypes[y])
cumulative += normalized[:, y]
plt.xlim((0, 1))
plt.yticks(tick, tick_labels, fontname="meiryo")
lg = plt.legend(bbox_to_anchor=(1.0, 1.0), loc='upper left', prop={"family":"meiryo"})
plt.title("Positive / negative judgment distribution", fontname="meiryo")
plt.show()
This is the graph obtained from the 4 data.
Since the number of data is small, let's judge 10 articles for each search word. Also, try search results that appear in various words other than marriage. "Single" "Coronavirus" "After corona" "Monday" "Saturday" (10 articles for each word)
: stopwatch :: desktop: rattling: stopwatch ::
: point_down_tone1: Chain. Yes, it came out!
70% of "before marriage" and "after marriage" were "super positive" and "positive". Compared to other items, it is clear that there are many articles that are positive about "marriage." There are more positive articles than I thought "single"! (I'm happy for some reason)
Regarding "coronavirus", 60% were judged to be "super negative" or "negative", whereas It is interesting that there are few negative articles in "After Corona". It is interesting that "Saturday" is positive while "Monday" is relatively negative for many articles.
I found that there are few negative factors for "marriage" before and after marriage ...
"The world wasn't flooded with negative articles after marriage!" I'll look for another excuse orz
Among married and single people, it seems that married people are overwhelmingly happy. https://comemo.nikkei.com/n/nac91dd2ea623
: boy_tone5: By the way, I'm happy (not crying)
Recommended Posts