split_sentence: Split Sentences

Description Usage Arguments Value Examples

View source: R/split_sentence.R

Description

Split sentences.

Usage

1
2
3
4
5
6
7
split_sentence(x, ...)

## Default S3 method:
split_sentence(x, ...)

## S3 method for class 'data.frame'
split_sentence(x, text.var = TRUE, ...)

Arguments

x

A data.frame or character vector with sentences.

text.var

The name of the text variable. If TRUE split_sentence tries to detect the column with sentences.

...

Ignored.

Value

Returns a list of vectors of sentences or a expanded data.frame with sentences split apart.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(x <- c(paste0(
    "Mr. Brown comes! He says hello. i give him coffee.  i will ",
    "go at 5 p. m. eastern time.  Or somewhere in between!go there"
),
paste0(
    "Marvin K. Mooney Will You Please Go Now!", "The time has come.",
    "The time has come. The time is now. Just go. Go. GO!",
    "I don't care how."
)))
split_sentence(x)

data(DATA)
split_sentence(DATA)

## Not run: 
## Kevin S. Dias' sentence boundary disambiguation test set
data(golden_rules)
library(magrittr)

golden_rules %$%
    split_sentence(Text)

## End(Not run)

Example output

[1] "Mr. Brown comes! He says hello. i give him coffee.  i will go at 5 p. m. eastern time.  Or somewhere in between!go there"       
[2] "Marvin K. Mooney Will You Please Go Now!The time has come.The time has come. The time is now. Just go. Go. GO!I don't care how."
[[1]]
[1] "Mr. Brown comes!"                  "He says hello."                   
[3] "i give him coffee."                "i will go at 5 p.m. eastern time."
[5] "Or somewhere in between!"          "go there"                         

[[2]]
[1] "Marvin K. Mooney Will You Please Go Now!"
[2] "The time has come."                      
[3] "The time has come."                      
[4] "The time is now."                        
[5] "Just go."                                
[6] "Go."                                     
[7] "GO!"                                     
[8] "I don't care how."                       

        person sex adult                       state code element_id
 1:        sam   m     0            Computer is fun.   K1          1
 2:        sam   m     0                Not too fun.   K1          1
 3:       greg   m     0     No it's not, it's dumb.   K2          2
 4:    teacher   m     1          What should we do?   K3          3
 5:        sam   m     0        You liar, it stinks!   K4          4
 6:       greg   m     0     I am telling the truth!   K5          5
 7:      sally   f     0      How can we be certain?   K6          6
 8:       greg   m     0            There is no way.   K7          7
 9:        sam   m     0             I distrust you.   K8          8
10:      sally   f     0 What are you talking about?   K9          9
11: researcher   f     1           Shall we move on?  K10         10
12: researcher   f     1                  Good then.  K10         10
13:       greg   m     0                 I'm hungry.  K11         11
14:       greg   m     0                  Let's eat.  K11         11
15:       greg   m     0                You already?  K11         11
    sentence_id
 1:           1
 2:           2
 3:           1
 4:           1
 5:           1
 6:           1
 7:           1
 8:           1
 9:           1
10:           1
11:           1
12:           2
13:           1
14:           2
15:           3
[[1]]
[1] "Hello World."      "My name is Jonas."

[[2]]
[1] "What is your name?" "My name is Jonas." 

[[3]]
[1] "There it is!" "I found it." 

[[4]]
[1] "My name is Jonas E. Smith."

[[5]]
[1] "Please turn to p. 55."

[[6]]
[1] "Were Jane and co. at the party?"

[[7]]
[1] "They closed the deal with Pitt, Briggs & Co. at noon."

[[8]]
[1] "Let's ask Jane and co." "They should know."     

[[9]]
[1] "They closed the deal with Pitt, Briggs & Co."
[2] "It closed yesterday."                        

[[10]]
[1] "I can see Mt. Fuji from here."

[[11]]
[1] "St. Michael's Church is on 5th st. near the light."

[[12]]
[1] "That is JFK Jr.'s book."

[[13]]
[1] "I visited the U.S.A. last year."

[[14]]
[1] "I live in the E.U." "How about you?"    

[[15]]
[1] "I live in the U.S." "How about you?"    

[[16]]
[1] "I work for the U.S."     "Government in Virginia."

[[17]]
[1] "I have lived in the U.S. for 20 years."

[[18]]
[1] "At 5 a.m."                         "Mr. Smith went to the bank."      
[3] "He left the bank at 6 P.M."        "Mr. Smith then went to the store."

[[19]]
[1] "She has $100.00 in her bag."

[[20]]
[1] "She has $100.00."  "It is in her bag."

[[21]]
[1] "He teaches science (He previously worked for 5 years as an engineer.) at the local University."

[[22]]
[1] "Her email is Jane.Doe@example.com." "I sent her an email."              

[[23]]
[1] "The site is: https://www.example.50.com/new-site/awesome_content.html."
[2] "Please check it out."                                                  

[[24]]
[1] "She turned to him, 'This is great.'" "she said."                          

[[25]]
[1] "She turned to him, \"This is great.\""
[2] "she said."                            

[[26]]
[1] "She turned to him, \"This is great.\""
[2] "She held the book out to show him."   

[[27]]
[1] "Hello!!"           "Long time no see."

[[28]]
[1] "Hello??"       "Who is there?"

[[29]]
[1] "Hello!?"      "Is that you?"

[[30]]
[1] "Hello?!"      "Is that you?"

[[31]]
[1] "1.) The first item 2.) The second item"

[[32]]
[1] "1.) The first item."  "2.) The second item."

[[33]]
[1] "1) The first item 2) The second item"

[[34]]
[1] "1) The first item."  "2) The second item."

[[35]]
[1] "1."                "The first item 2." "The second item"  

[[36]]
[1] "1."               "The first item."  "2."               "The second item."

[[37]]
[1] "a."                  "The first item b."   "The second item c." 
[4] "The third list item"

[[38]]
[1] "This is a sentence\\ncut off in the middle because pdf."

[[39]]
[1] "It was a cold \\nnight in the city."

[[40]]
[1] "features\\ncontact manager\\nevents, activities\\n"

[[41]]
[1] "She works at Yahoo!"           "in the accounting department."

[[42]]
[1] "We make a good team, you and I."       
[2] "Did you see Albert I. Jones yesterday?"

[[43]]
[1] "\"Bohr [...] used the analogy of parallel stairways [...]\" (Smith 55)."

[[44]]
[1] "If words are left off at the end of a sentence, and that is all that is omitted, indicate the omission with ellipsis marks (preceded and followed by a space) and then indicate the end of the sentence with a period ."
[2] "."                                                                                                                                                                                                                      
[3] "."                                                                                                                                                                                                                      
[4] "."                                                                                                                                                                                                                      
[5] "Next sentence."                                                                                                                                                                                                         

[[45]]
[1] "I never meant that...." "She left the store."   

textshape documentation built on May 29, 2021, 1:07 a.m.