В R как разделить текст / абзац в конце выражения (точка останова), но не в точке (точка) между предложениями

В R:- Например: -

text_data<-" I have been a Gig subscriber for a decent amount of time.  When the service was originally installed I would observe 900+Mbps speeds.  I have deployed to Kosovo and since then (about 8 months ago) my wife has told me that the internet has become Slow.I consistently avg less than 286 Mbps when utilizing both speedtest.xfinity.com and fast.com as well as speedtest.net Current hardware: 1) Motorola MB8600 Modem 2) Linksys EA9500 I have not had a technician out to the site.Troubleshooting:I have replaced the Coax cable from wall to modem with 2 different new coax cables. I have replaced the ethernet from Modem to Router with 2 different new ethernet cables I have rebooted my Modem as well as attempted a factory reset. I have connected my home PC directly to the Modem (bypass router) with 2 different ethernet cables*NOTE*Wether I use the EA9500 or go directly to the PC I get the same slow speeds.*NOTE 2*I do not have a cable subscrption. No splitters on the line. It goes from Pole ---> Wall Jack --> Modem.There is always significant Uncorrected errors.  Attached are the Upstream and Downstream information and error logs.  These are 4 days after a modem reset."

> textdata<- as.String(text_data)

> a<-strsplit(text_data,".", fixed = TRUE)

Выход: -

> a
[[1]]
 [1] " I have been a Gig subscriber for a decent amount of time"                                                                                                                           
 [2] "  When the service was originally installed I would observe 900+Mbps speeds"                                                                                                         
 [3] "  I have deployed to Kosovo and since then (about 8 months ago) my wife has told me that the internet has become Slow"                                                               
 [4] "I consistently avg less than 286 Mbps when utilizing both speedtest"                                                                                                                 
 [5] "xfinity"                                                                                                                                                                             
 [6] "com and fast"                                                                                                                                                                        
 [7] "com as well as speedtest"                                                                                                                                                            
 [8] "net Current hardware: 1) Motorola MB8600 Modem 2) Linksys EA9500 I have not had a technician out to the site"                                                                        
 [9] "Troubleshooting:I have replaced the Coax cable from wall to modem with 2 different new coax cables"                                                                                  
[10] " I have replaced the ethernet from Modem to Router with 2 different new ethernet cables I have rebooted my Modem as well as attempted a factory reset"                               
[11] " I have connected my home PC directly to the Modem (bypass router) with 2 different ethernet cables*NOTE*Wether I use the EA9500 or go directly to the PC I get the same slow speeds"
[12] "*NOTE 2*I do not have a cable subscrption"                                                                                                                                           
[13] " No splitters on the line"                                                                                                                                                           
[14] " It goes from Pole ---> Wall Jack --> Modem"                                                                                                                                         
[15] "There is always significant Uncorrected errors"                                                                                                                                      
[16] "  Attached are the Upstream and Downstream information and error logs"                                                                                                               
[17] "  These are 4 days after a modem reset"   

Желаемый результат в R:-Текст должен разделяться в конце выражения (точка останова), а не в точке (точка) между предложениями.)

1)I have been a Gig subscriber for a decent amount of time.  
When the service was originally installed I would observe 900+Mbps speeds.  
2)I have deployed to Kosovo and since then (about 8 months ago) my wife has told me that the internet has become Slow.
3)I consistently avg less than 286 Mbps when utilizing both speedtest.xfinity.com and fast.com as well as speedtest.net Current hardware: 1) Motorola MB8600 Modem 2) Linksys EA9500 I have not had a technician out to the site.
4)Troubleshooting:I have replaced the Coax cable from wall to modem with 2 different new coax cables. 
5) I have replaced the ethernet from Modem to Router with 2 different new ethernet cables I have rebooted my Modem as well as attempted a factory reset. 
6)I have connected my home PC directly to the Modem (bypass router) with 2 different ethernet cables*NOTE*Wether I use the EA9500 or go directly to the PC I get the same slow speeds.
7)*NOTE 2*I do not have a cable subscrption. 
8)No splitters on the line. 
9)It goes from Pole ---> Wall Jack --> Modem.
10)There is always significant Uncorrected errors.  
11)Attached are the Upstream and Downstream information and error logs.  
12)These are 4 days after a modem reset.

Пожалуйста помогите.

1 ответ

Решение

Редактировать с рабочим шаблоном для этих конкретных данных; Вы можете разделить на . сопровождаемый пробелом или заглавной буквой с рисунком \\.(?=( |[A-Z])),

Вы должны быть осторожны, потому что у вас есть предложения, которые не имеют правильного пробела после них. Это делает невозможным их надежное различение (см. Третье разделенное предложение в выходных данных). Это по крайней мере не будет делиться на случаи .com как твоя первая попытка Здесь мы используем разность заглавных букв, чтобы различать speedtest.xfinity.com а также Slow.I или же site.Troubleshooting, но это не сработает, если кто-то забудет пробел и забудет использовать заглавную букву в следующем предложении.

library(stringr)
text_data <- " I have been a Gig subscriber for a decent amount of time. When the service was originally installed I would observe 900+Mbps speeds. I have deployed to Kosovo and since then (about 8 months ago) my wife has told me that the internet has become Slow.I consistently avg less than 286 Mbps when utilizing both speedtest.xfinity.com and fast.com as well as speedtest.net Current hardware: 1) Motorola MB8600 Modem 2) Linksys EA9500 I have not had a technician out to the site.Troubleshooting:I have replaced the Coax cable from wall to modem with 2 different new coax cables. I have replaced the ethernet from Modem to Router with 2 different new ethernet cables I have rebooted my Modem as well as attempted a factory reset. I have connected my home PC directly to the Modem (bypass router) with 2 different ethernet cablesNOTEWether I use the EA9500 or go directly to the PC I get the same slow speeds.*NOTE 2*I do not have a cable subscrption. No splitters on the line. It goes from Pole ---> Wall Jack --> Modem.There is always significant Uncorrected errors. Attached are the Upstream and Downstream information and error logs. These are 4 days after a modem reset."
text_data %>%
  str_split("\\.(?=( |[A-Z]))")
#> [[1]]
#>  [1] " I have been a Gig subscriber for a decent amount of time"                                                                                                                                                                     
#>  [2] " When the service was originally installed I would observe 900+Mbps speeds"                                                                                                                                                    
#>  [3] " I have deployed to Kosovo and since then (about 8 months ago) my wife has told me that the internet has become Slow"                                                                                                          
#>  [4] "I consistently avg less than 286 Mbps when utilizing both speedtest.xfinity.com and fast.com as well as speedtest.net Current hardware: 1) Motorola MB8600 Modem 2) Linksys EA9500 I have not had a technician out to the site"
#>  [5] "Troubleshooting:I have replaced the Coax cable from wall to modem with 2 different new coax cables"                                                                                                                            
#>  [6] " I have replaced the ethernet from Modem to Router with 2 different new ethernet cables I have rebooted my Modem as well as attempted a factory reset"                                                                         
#>  [7] " I have connected my home PC directly to the Modem (bypass router) with 2 different ethernet cablesNOTEWether I use the EA9500 or go directly to the PC I get the same slow speeds.*NOTE 2*I do not have a cable subscrption"  
#>  [8] " No splitters on the line"                                                                                                                                                                                                     
#>  [9] " It goes from Pole ---> Wall Jack --> Modem"                                                                                                                                                                                   
#> [10] "There is always significant Uncorrected errors"                                                                                                                                                                                
#> [11] " Attached are the Upstream and Downstream information and error logs"                                                                                                                                                          
#> [12] " These are 4 days after a modem reset."

Создано 2018-08-12 пакетом представлением (v0.2.0).

Другие вопросы по тегам