Question: Task 1 : Extra song title Each line contains a track id , song id , artist name, and the song title, such as: TRWRJSX

Task 1: Extra song title Each line contains a track id, song id, artist name, and the song title, such as: TRWRJSX12903CD8446SOBSFBU12AB018DBE1Frank SinatraEverything Happens To Me You are only concerned with the last field, the song title. As your first task, you will write a regular expression that extracts the song title and discards all other information. In the code, find the function extract_title. In the if statement, edit the regular expression to capture only the song title. The print command is useful to print out the tracks as you develop your regular expressions. The print command takes an optional integer argument which restricts printing to only the first n tracks. For example, print 10, prints only the first ten tracks. On completion of Task 1, you can check yourself with test t02. Task 2: Eliminate superfluous text The song title, however, is quite noisy, often containing additional information beyond the song title. Consider this example. Strangers In The Night (Remastered Album Version)[The Frank Sinatra Collection] You need to preform some pre-processing in order to clean up the song titles. You will write a series of regular expressions that match a block of text and replace it with nothing. Use a substitution regex that matches one string and replaces it with another. Begin by writing a regular expression that matches a left parenthesis and any text that follows it. You need not match the right parenthesis explicitly. Replace the parenthesis and all text that follow it with nothing. In the above Sinatra example, the modified title becomes: Strangers In The Night Repeat this for patterns beginning with the left bracket, the left curly brace, and all the other characters listed below. ([{\/_- : "`+= feat. Most of the these are single symbols. The last is the abbreviation feat. which is short for featuring. Make sure to remove the literal period which follows the t. For example, Sunbeam feat. Vishal Vaid becomes Sunbeam. Also take note that the above list shows the backtick `(on the tilde key above tab) and not the apostrophe (located left of the enter key). This is a very important distinction. We do not want to omit the apostrophe as it allows contractions. Many of these characters have special meanings in Raku. Make sure you properly escape symbols when necessary with a \. Alternately, you can put characters to escape in quotations, such as "#". Failing to escape characters properly will be the most common mistake made in this lab. This resourceLinks to an external site. lists the escape characters in Perl, which are the same in Raku. In most cases, these symbols indicate additional information that need not concern us for this exercise. The above steps will very occasionally corrupt a valid song title that actually contains, for example, parentheses in the song title. Do not worry about these infrequent cases and uniformly carry out the procedure listed above. These steps will catch and fix the vast majority of irregularities in the song titles. In the code, find the incomplete function comments. Add a series of regex substitutions to remove the superfluous information. You can now use the command filter_comments. On completion of Task 2, you can check yourself with test t03. Task 3: Eliminate punctuation Next, find and delete the following typical punctuation marks. ?!. ; : & $ * @ % # | Unlike before, delete only the symbol itself and leave all of the text the follows. Be sure to do a 'global' match in order to replace all instances of the punctuation mark. Be careful to match the period itself as the symbol . has a special meaning in regular expressions. This is true for many of the symbols above. Again, refer to the list of escape charactersLinks to an external site.. For the symbols and , use the Unicode representations, which are \x[00BF]\x[00A1] respectively. Note the colon is intentionally repeated from Task 2. In the code, find the incomplete function punctuation. Add a series of regex substitutions to remove the punctuation. You can now use the command filter punctuation filter punctuation. On completion of Task 3, you can check yourself with test t04. Task 4: Trim whitespace All our replacements have left some blank titles or mangled titles. First, identify any titles that begin or end with an apostrophe(s). Replace those apostrophes with nothing. Be careful not to disturb the apostrophes in the interior of the sentence. Next, trim leading and trailing whitespace from each title. Be careful not to replace all whitespace as we need whitespace between word boundaries. To match the tests and simplify debugging, do not combine the above two operations into one, but rather (1) handle apostrophes first and then (2) handle whitespace as a second line of code. In the code, find the incomplete function clean and complete the instructions to achieve the above goal.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!