Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMPSCI 2034b / DIGIHUM 2144b

Data Analytics: Principles and Tools

Assignment #2

Youtube Comment Analytics

Posted  March 4th 2024

Due:   March 18th 2023 11:55PM

Total:   100 Points

Learning Outcomes

By completing this assignment, you will gain and demonstrate skills relating to: 

❼ Data Munging.

❼ Using Regular Expressions.

❼ Textual Analysis.

❼ VBA String Functions.

❼ Using Nested Loops.

Instructions

In this assignment, you will follow the directions given in each task in this document precisely and produce a Word file named  userid assign2.docx,  an Excel Macro Enabled Workbook named userid assign2.xlsm (where userid is your UWO user id), and a Tab-separated Values (.tsv) file named vidname.tsv  (where  vidname is the name of the dataset you used).  You must  assume  that  the  data  in  your  sheet  can  change  (i.e.  you  may  not  hardcode  your answers).  Each step must be followed precisely including the file naming convention given in the Submission Section.

It is expected that you will document your code using comments in sufficient detail that the purpose and function of each line is clear to the TA marking your assignment. You should have at least one comment before each VBA function documenting what the function does, what arguments it takes and what value it returns.  You should also have comments inside your functions documenting any complex lines of code.

You will be assessed on the following:

❼ Using the correct files.

❼ Properly cleaning and importing the comments into Excel.

❼ Your Excel formulas and operations.

❼ Your VBA code.

❼ Completion of each task correctly.

❼ Coding each function as described.

❼ Using the given function headers without modification.

❼ Commenting your code in sufficient detail.

❼ Indenting your code appropriately.

❼ Assignment submission via OWL.

Problem Description

In this assignment, you will pre-process, analyze, and present data relating to individual’s current opinion on  a  given Youtube video.   You  will  be  given  the  option  to  select  one Youtube video to perform your analysis on from a small set of preexisting comment datasets.

Regardless of the video you choose, the dataset will contain between 1,000 to 3,500 comments made on the video.

You will act as a data analyst and perform a textual analysis on this data to attempt to derive some meaning.  In this case, the current sentiment or opinion Youtube users have of your chosen video. This sort of sentiment analysis can be valuable for business and organizations to judge the general public’s response to recent announcements or product launches.

To derive this sentiment you will be required to perform the following tasks (described in detail in the subsequent sections of this document):

❼ Obtain Data:  Obtain the dataset.

❼ Data Munging:  Clean the dataset using regular expression.

❼ Importing:   Import  the  data  into  Excel,  sort  it  and  use  Excel’s  built  in  remove duplicate tool.

❼ Remove Duplicates:  Use VBA to create our own duplicate removal tool to further clean the data.

❼ Calculate Sentiment:  Use VBA to calculate the sentiment of each comment.

❼ Analysis:  Use Excel formulas to analyze the result and present your findings.

Tasks

Task 0:  Obtain The Dataset

Disclaimer

These datasets contain real comments from videos that have been posted to Youtube.   They  are unfiltered and can contain offensive and/or inappropriate language.  The inclusion of a particular comment is in no way an endorsement of the comment’s contents.

You will select one and only one video described in this section to perform your analysis on. Once your have decided on the video you would like to use in your analysis, download the corresponding dataset from OWL (should be attached to the assignment on the Assignments tab) and continue with Task 1.

Video 1:  Barbie Trailer

Video Title: Barbie — Main Trailer

URLhttps://www.youtube.com/watch?v=pBk4NYhWNMM

Dataset Name: Barbie.txt

Background:  The Barbie movie was released in theatres on July 21st, 2023 and had significant boxoffice success. But what did Youtuber’s think of the trailer, and did this view change depending on the country of the commenter?

Video 2:  Dune Part 2 Trailer

Video Title: Dune: Part Two — Official Trailer

URLhttps://www.youtube.com/watch?v=Way9Dexny3w

Dataset Name: DunePart2.txt

Background: The highly anticipated movie Dune: Part 2 is releasing in theatres on March 15th, 2024. How hyped (excited) are Youtubers for it’s upcoming release?

Video 3: Youtube Rewind 2019

Video Title: YouTube Rewind 2019: For the Record

URL: https://www.youtube.com/watch?v=2lAe1cqCOXo

Dataset Name: Rewind2019.txt

Background: From 2010 to 2019 each year YouTube would produce a video highlighting the viral videos, events, trends, and music of the last year.  This trend ended in 2019.  Could youtuber’s reactions to the last rewind video give us some clues into why it was discontinued?

Video 4:  Google Stadia

Video Title: Stadia GDC 2019 Gaming Announcement

URL: https://www.youtube.com/watch?v=nUih5C5rOrA

Dataset Name: Stadia.txt

Background:  Google Stadia was a failed cloud gaming service offered by Google from 2019 to 2023.  Stadia users were ultimately unimpressed with the the quality of the service, but what did Youtubers think about the launch announcement at the time?

Video 5:  CyberTruck

Video Title: CYBERTRUCK

URL: https://www.youtube.com/watch?v=DsonSEllPmU

Dataset Name: CyberTruck.txt

Background: Recently Tesla launched the Tesla Cybertruck, a fully electric full-size pickup truck. Tesla has faced some controversy about the safety and build quality of the truck, but what do Youtuber’s who commented on this Cyberturck advertisement think?

Video 6:  Apple Vision Pro

Video Title: Using Apple Vision Pro: What It’s Actually Like!

URL: https://www.youtube.com/watch?v=dtp6b76pMak

Dataset Name: AppleVisionPro.txt

Background:  Apple recently launched the Apple Vision Pro, a high end mixed-reality headset. Unfortunately, Apple does not allow comments on their Apple Vision Pro videos, so we will instead perform our analysis on a video by the Youtuber Marques Brownlee giving his initial impressions. What do Marques fans think of the Vision Pro?

Video 7:  Cyberpunk 2077

Video Title: Cyberpunk 2077 — Our Commitment to Quality

URLhttps://www.youtube.com/watch?v=O3V4UBZmC9o

Dataset Name: CyberpunkApology.txt

Background:  The video game  Cyberpunk 2077 developed by CD Projekt Red was released on December 10th, 2020.  Technical issues and a lack of promised content and features lead to significant criticism from gamers,  leading to CD Projekt issuing an apology video and reconfirming their commitment to quality. But how did Youtuber’s react to this apology?

Video 8:  Avatar:  The Last Airbender

Video Title: Avatar: The Last Airbender — Official Teaser — Netflix

URLhttps://www.youtube.com/watch?v=waJKJW_XU90

Dataset Name: LastAirbender.txt

Background: On February 22, 2024 Netflix released the first episodes of their live action adaptation

of Avatar:  The Last Airbender based on a beloved 2005 animated television series of the same name. Fans had significant concerns after previous attempts at live adaptations had been critically condemned. Did the trailer for the new series manage to win over fans?

Video 9:  GameStop Hearing

Video Title: Keith Gill delivers his testimony at GameStop hearing: ’I like the stock’

URLhttps://www.youtube.com/watch?v=ukXQGBpXaVM

Dataset Name: GameStopHearing.txt

Background:   During  the  2021  GameStop  short  squeeze  hearing,  Keith  Gill,  also  known  as “Roaring Kitty”, defended his role in the stock market frenzy that caused GameStop’s stock price to surge.  Gill, a retail investor and YouTube personality, argued that he was simply sharing his investment thesis on the stock and did not manipulate the market.  But what did Youtubers think of Gill and his comments at the hearing?

Task 1: Data Munging

For each Step in this Task (except Steps 1.1 and 1.8), record the regular expression pattern you used for the find field in Notepad++  and the pattern (if any) you used for the replace field.  You will be required to submit a Word document of your answers when submitting your assignment.

For example, if you used the following fields for doing a substitution:

 

you should record the following in your Word document:

Find:  [cC]at

Replace: Dog

Match Case: Yes

Mode: Regular Expression

If you do not include Match  Case or Mode, it will be assumed that Match  Case  is on (Yes) and that the Mode is Regular Expression.  If you wish to replace the text with nothing, simply put:

Replace:

That is, “Replace:” followed by no text.

If your regular expression includes a space that might be hard to see (e.g. at the end or start of the pattern or multiple spaces in a row), make sure it is clear to the reader that the space is there. For example, you might use the   character to denote a space in your pattern.  If you do this leave a note stating something to the effect of   = space so that your intent is clear to the reader.

Step 1.1:  Understanding the Data

Open your dataset in Notepad++ (or equivalent program). This file should contain at least 1,500 comments (likely more) about a publicly traded company as described in the problem description.  Unfortunately for us, the format of this file is a bit unusual and can not be imported into Excel directly.

Each comment in this file is separated by a row of dashes (e.g. -------------------------)

and contains both the comment text as well as metadata about the comment and it’s author.

Each data value is listed as a value name (e.g.  “Comment by” for username of the comment’s author) followed by a colon (:), a space character, then a data value (e.g. @joebloggs5), and finally a line feed character (\n).  That is to say that each data value is prefixed with the name of that value. For example, the number of likes the comment has is prefixed with the text  “Likes:   ”  and the user’s country with the text  “Country:  ” .  If a value could not be determined, it will be listed as  “None” .

The following table describes each data value in the file:


The data values will always be in the same order as shown in the above table and the data value name is followed by a colon (:)  and then  a single space before the data value.   For example:

Comment  by:  @jbloggs5\n

where Comment by is the name of the data value, a   is a single space, and \n is the line feed character that starts a new line in the file. The data value name is followed by a colon and single space (: ) and then the data value, @jbloggs5 .

The best way to fully understand this format is to take a look at the data yourself using a program like Notepad++.  If you are using Notepad++ you may display the invisible tab and space characters via the View menu:

 

This will display tab characters as orange arrows, space characters as orange dots, and end of line characters as a LF.

It may also be helpful to ensure that “Word wrap” is disabled in NotePad++ to ensure that the comment text is displayed on one line.

Note that these datasets are formatted with Unix style end of line characters.  That is to say end line ends with one \n character (shown in Notepad++ as a LF when All Symbols are shown).

It is highly recommended to save your work to a new file after each step.   For example, after step 1.2, save your text file as vidname step1 2.txt where vidname is the name of your dataset. You do not need to submit each of these files (see the last section of this document for what to submit) but it is important to save different copies of the dataset as we go so we can easily come back to this step if we make an error later.  Also make sure you are recording all of the regular expressions and settings you used in your word document as described at the start of this task.

Step 1.2:  Remove @ From the User Handles

The @ character in front of the user handle’s in the Comment by:  value are not very useful to us. Remove all of the @ characters from the file but only if they occur in the value listed after Comment by:.  Do not remove them from the  Channel  URL,  Comment  Text, or anywhere else in the file.

For example lines such as:

Comment by:   @jbloggs5

Comment by:   @dr. servos

Comment by:   @d-serv os.5

should all have the @ removed and no other changes:

Comment by:  jbloggs5

Comment by:  dr. servos

Comment by:  d-serv os.5

where the   character represents a normal space.

Hint 1:  Remember the @ we want to remove always happens after the text “Comment by:  ” at the start of a line.

Hint 2: If you have to match text you don’t want to remove, such as  “Comment by:  ”, you can always put it back in the replace field.

Step 1.3 Reformat the Dates

The dates in the dataset are in the format  day/month/year hour:minute:second-timezone AM/PM for example 28/02/2024 08:52:28-0500 PM. The day, month, hour, minute, and second values will always be two digits and the timezone always four digits with a leading plus or minus sign.  For example, if the timezone was +0400 then the date might look like this: 28/02/2024 08:52:28+0400 PM.

We would like to transform these dates to follow the Canadian standard and be easier to important into Excel. Write a regular expression find and replace pattern to convert the dates to the format year-month-day hour:minute:second AM/PM such as 2024-02-28 08:52:28 PM for 28/02/2024 08:52:28-0500 PM. The timezone should be removed completely.

For example, the following dates:

26/02/2024  07:58:39-0500  AM

03/08/2023  08:25:05-0400  AM

02/12/2023  03:20:19+0200  PM

should become:

2024-02-26  07:58:39  AM

2023-08-03  08:25:05  AM

2023-12-02  03:20:19  PM

For full marks, this must be done in one Find/Replace for all dates in the file and not impact any characters in the file that are not part of a date.

Hint 3: This will require the use of groupings in your find pattern and recalling their values in the replace field.

Step 1.4 Remove Extra Characters at the Start of Comment Text

In some cases the comment text starts with a character that could cause issues once we important the data into Excel.  We need to remove any -, =, ?, !, ”, ’, or space (i.e. the minus sign, equals sign, question mark, double quote, single quote, or the space character) but only at the start of the comment text.

Create a regular expression based Find and Replace pattern to remove any number of -, =, ?, !, ”, ’, or space if they occur at the start of the comment’s text.  You should only remove these characters if they are the first characters of a comment’s text and not everywhere in the file. After the replacement there should still be a single space between “Comment Text:”

and the first letter of the comment’s text.

For example, the following lines:

Comment  Text:    !!!!I  LOVE  THIS  MOVIE!!!!

Comment  Text:           I   think    there   is    something wrong      with my      s pa ce b   ar .

Comment  Text:    -10  is my  rating .

Comment  Text:    -=?!"’     hello world

should become:

Comment  Text:    I  LOVE  THIS  MOVIE!!!!

Comment  Text:    I   think    there   is    something wrong      with my      s pa ce b   ar . Comment  Text:    10  is  my  rating .

Comment  Text:   hello world