<jupyter_start><jupyter_text>Checking for null values:<jupyter_code>briefings_df[briefings_df['text'].isnull()]<jupyter_output><empty_output><jupyter_text>Manually comparing with the full transcripts and videos we can see these correspond to the speaker being cut off or uttering something inaudible. Let's simply drop these three rows.<jupyter_code>briefings_df = briefings_df.dropna(subset=['text']).reset_index(drop=True)<jupyter_output><empty_output><jupyter_text>Cleaning up speaker names<jupyter_code># how many paragraphs of text for the top speakers?
briefings_df['speaker'].value_counts()[:50]<jupyter_output><empty_output><jupyter_text>Looking at the output above and inspecting the data in more detail we can see there's opportunity to:- Consolidate numbered unnamed speakers and reporters, since numbering is not consisent across briefings- Note specific recurring reports who are referred to by first name- Standardize the name used for other important speakers who have multiple spellings/titles/variations present<jupyter_code># replace speaker names using basic regex
briefings_df['speaker'].replace(regex={r'.*Trump.*': '<NAME>', 
                                       r'.*Pence.*': '<NAME>',
                                       r'.*Fauci.*': 'Dr. <NAME>',
                                       r'.*Birx.*': 'Dr. Deb<NAME>',
                                       r'.*Berks.*': 'Dr. Deborah Birx',
                                       r'.*Pompeo.*': '<NAME>',
                                       r'.*Report.*': 'Unnamed (Reporter)',
                                       r'.*Audience Member.*': 'Unnamed',
                                       r'.*Speaker .*': 'Unnamed', 
                                       r'.*Jeff\Z': 'Jeff (Reporter)',
                                       r'.*John\Z': 'John (Reporter)',
                                       r'.*Peter\Z': 'Peter (Reporter)',
                                       r'.*Jim\Z': 'Jim (Reporter)',
                                       r'.*Steve\Z': 'Steve (Reporter)',
                                       r'.*Pete\Z': '<NAME>',
                                       r'.*Novarro.*': '<NAME>',
                                       r'.*Surgeon General.*': '<NAME>',
                                       r'.*Giroir.*': '<NAME>',
                                       r'.*Polowczyk.*': '<NAME>',
                                       r'.*Verma.*': '<NAME>',
                                       r'.*Azar.*': '<NAME>',
                                       r'.*Hahn.*': 'Dr. <NAME>',
                                       r'.*Mnuchin.*': '<NAME>'},
                                inplace = True)
# how many paragraphs of text per speaker?
top_speaker_counts = briefings_df['speaker'].value_counts()[:25]
top_speaker_counts
# save cleaned df to csv
briefings_df.to_csv("../data/cleaned_briefings.csv",index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13124787487249234, 'fraction_numerical': 0.0013600816048962938, 'mean_word_length': 1.5582608695652174, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '62973', 'license': 'MIT', 'n_tokens_mistral': 804, 'n_tokens_neox': 762, 'n_words': 183, 'path': 'src/archive/eda_cleaning.ipynb', 'repo_name': 'brendoncampbell/corona-briefing-tones', 'size': '3018'}