1
00:00:00,490 --> 00:00:01,030
Hello.

2
00:00:01,030 --> 00:00:10,750
In this video, I'll give you my solution to the Diary Tone project where you visualize the moods.

3
00:00:11,570 --> 00:00:13,970
Based on your diary entries.

4
00:00:15,080 --> 00:00:16,820
And this is my code.

5
00:00:18,090 --> 00:00:20,370
So let me explain you how I did this.

6
00:00:22,050 --> 00:00:23,850
I have some import statements in here.

7
00:00:24,030 --> 00:00:29,220
And then first of all, I created a file paths list.

8
00:00:31,150 --> 00:00:34,000
So this will look something.

9
00:00:38,690 --> 00:00:39,590
Like this.

10
00:00:41,290 --> 00:00:43,440
So that's a list of five paths.

11
00:00:43,450 --> 00:00:48,130
And then I instantiated the sentiment Intensity Analyzer class.

12
00:00:48,280 --> 00:00:54,850
I prepared two empty lists, so this will be the place where I will store.

13
00:00:55,990 --> 00:00:59,200
The negativity and the positivity coefficients.

14
00:01:00,530 --> 00:01:07,240
So in order to store all those coefficients in these two lists, I am looping over the file paths list.

15
00:01:07,250 --> 00:01:09,650
So this list that I showed you here.

16
00:01:09,650 --> 00:01:15,500
So I'm going to so I'm going to each file and for each file.

17
00:01:16,580 --> 00:01:23,810
I'm creating a file object and then reading the content, storing that content in the content variable.

18
00:01:24,740 --> 00:01:27,440
Then I'll calculate the scores.

19
00:01:28,240 --> 00:01:30,130
For each content.

20
00:01:30,220 --> 00:01:37,150
So in the first loop, I'll get a dictionary with the scores representing the negativity and positive

21
00:01:37,780 --> 00:01:42,040
scores for that first file that's in the first loop.

22
00:01:42,220 --> 00:01:51,670
And so then what I do is I access this list, which is currently empty, and I append the positivity

23
00:01:51,670 --> 00:01:58,440
score to the positivity list, and I do the same for the negativity list which is created in here.

24
00:01:58,450 --> 00:02:02,470
So in the first iteration, I'll have one value here, one value here.

25
00:02:02,470 --> 00:02:08,500
Then in the second iteration we go through the second file and we will store the second value here and

26
00:02:08,500 --> 00:02:13,510
the second value here and so on and so forth until the seventh file.

27
00:02:13,600 --> 00:02:17,740
And we will end up with two lists, with seven items each.

28
00:02:18,520 --> 00:02:22,930
Then I'm extracting the dates using this list comprehension.

29
00:02:24,100 --> 00:02:33,940
So I'm iterating over five paths, four name in five paths, and for each name, basically this will

30
00:02:33,940 --> 00:02:35,890
be the name variables.

31
00:02:35,890 --> 00:02:46,840
So for that, for example, I remove the first part, this part and I also remove the diary slash part.

32
00:02:47,320 --> 00:02:53,590
This part here you might have done this differently, so don't expect that we have the same codes.

33
00:02:53,590 --> 00:02:55,900
I usually mention that.

34
00:02:57,100 --> 00:03:02,130
So that's where the part of getting the data ends.

35
00:03:02,130 --> 00:03:04,600
And then we work on streamlined.

36
00:03:06,330 --> 00:03:08,340
So perhaps you put this in a function.

37
00:03:08,340 --> 00:03:09,210
That's great.

38
00:03:10,410 --> 00:03:12,870
And so this is a streamlined part.

39
00:03:14,160 --> 00:03:19,350
We create a diary tone title which corresponds to this.

40
00:03:31,230 --> 00:03:39,090
We create a subheading for the first graph and then create a plot figure using p x, which I'll put

41
00:03:39,090 --> 00:03:40,200
it in here.

42
00:03:40,320 --> 00:03:45,900
And so that's the plot figure for the first plot.

43
00:03:45,900 --> 00:03:53,550
So we're plotting dates in the x axis and positivity of the list in the Y axis, and we render the charts

44
00:03:53,590 --> 00:03:58,950
on the web page and we do exactly the same with the other plots in here.

45
00:03:58,950 --> 00:04:05,070
We look difference that negativity is the list that is plotted against the y axis here.

46
00:04:05,930 --> 00:04:07,670
And that's my solution.

47
00:04:09,260 --> 00:04:10,160
And that's about this video.

48
00:04:10,190 --> 00:04:10,820
Thanks a lot.

