How unique are the messages she is sending out in her 2016 campaign speeches compared to her husband’s? First we will clean and then train and test the NB on a dataset that contains both Hillary’s and Bill’s speeches. How different is her speech content from Bill Clinton’s. # Clinton 2016 speeches from : library ( xml2 ) library ( rvest ) library ( dplyr ) library ( tidyr ) url1 % html_nodes ( ".o-post-no-img" ) %>% html_attr ( "href" ) return ( paste0 ( "", speech, sep = "" )) } df_clinton_2016 % html_nodes ( ".s-wysiwyg" ) %>% html_text () as.character ( speech1 ) wann % html_node ( "time" ) %>% html_text () as.character ( wann ) dataframs % html_nodes () %>% html_text () wann % html_nodes () %>% html_text () wo % html_nodes () %>% html_text () bingins <- cbind ( as.ame ( speech ), as.ame ( wann ), as.ame ( wo )) } Is Hillary only a new Bill? We fetch it from Hillary’s campaign website. To train a Naive Bayes model, we need text data.
0 Comments
Leave a Reply. |