library(tidyr)
> bi_sep <- bi_grams %>%
+ separate (bigram, c ("first_part","sec_part"), sep = " ")
> bi_sep
# A tibble: 725,049 x 3
   book                first_part  sec_part   
   <fct>               <chr>       <chr>      
 1 Sense & Sensibility sense       and        
 2 Sense & Sensibility and         sensibility
 3 Sense & Sensibility sensibility by         
 4 Sense & Sensibility by          jane       
 5 Sense & Sensibility jane        austen     
 6 Sense & Sensibility austen      1811       
 7 Sense & Sensibility 1811        chapter    
 8 Sense & Sensibility chapter     1          
 9 Sense & Sensibility 1           the        
10 Sense & Sensibility the         family     
# ... with 725,039 more rows
> bi_swrem <- bi_sep %>%
+ filter (!first_part %in% stop_words$word)%>%
+ filter (!sec_part %in% stop_words$word)
> bi_swrem
# A tibble: 44,784 x 3
   book                first_part  sec_part    
   <fct>               <chr>       <chr>       
 1 Sense & Sensibility jane        austen      
 2 Sense & Sensibility austen      1811        
 3 Sense & Sensibility 1811        chapter     
 4 Sense & Sensibility chapter     1           
 5 Sense & Sensibility norland     park        
 6 Sense & Sensibility surrounding acquaintance
 7 Sense & Sensibility late        owner       
 8 Sense & Sensibility advanced    age         
 9 Sense & Sensibility constant    companion   
10 Sense & Sensibility happened    ten         
# ... with 44,774 more rows
> new_bi_grams <- bi_swrem %>%
+ count (first_part, sec_part, sort = TRUE)
> new_bi_grams
# A tibble: 33,421 x 3
   first_part sec_part      n
   <chr>      <chr>     <int>
 1 sir        thomas      287
 2 miss       crawford    215
 3 captain    wentworth   170
 4 miss       woodhouse   162
 5 frank      churchill   132
 6 lady       russell     118
 7 lady       bertram     114
 8 sir        walter      113
 9 miss       fairfax     109
10 colonel    brandon     108
# ... with 33,411 more rows
> bi_grams_c <- new_bi_grams %>%
+ unite (bigram, first_part, sec_part, sep = " ")
> bi_grams_c
# A tibble: 33,421 x 2
   bigram                n
   <chr>             <int>
 1 sir thomas          287
 2 miss crawford       215
 3 captain wentworth   170
 4 miss woodhouse      162
 5 frank churchill     132
 6 lady russell        118
 7 lady bertram        114
 8 sir walter          113
 9 miss fairfax        109
10 colonel brandon     108
# ... with 33,411 more rows
> 
