get_sentences: Get Sentences

Description Usage Arguments Value Examples

View source: R/get_sentences.R

Description

get_sentences - Get sentences from a character vector, sentiment, or sentiment_by object.

Usage

1

Arguments

x

A character vector, sentiment, or sentiment_by object.

...

Other arguments passed to split_sentence.

Value

Returns a list of vectors of sentences.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dat <- data.frame(
    w = c('Person 1', 'Person 2'),
    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"
    ), "One more thought for the road! I am going now.  Good day."),
    y = state.name[c(32, 38)], 
    z = c(.456, .124),
    stringsAsFactors = FALSE
)
get_sentences(dat$x)
get_sentences(dat)

Example output

[[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] "One more thought for the road!" "I am going now."               
[3] "Good day."                     

attr(,"class")
[1] "get_sentences"           "get_sentences_character"
[3] "list"                   
          w                                 x            y     z element_id
1: Person 1                  Mr. Brown comes!     New York 0.456          1
2: Person 1                    He says hello.     New York 0.456          1
3: Person 1                i give him coffee.     New York 0.456          1
4: Person 1 i will go at 5 p.m. eastern time.     New York 0.456          1
5: Person 1          Or somewhere in between!     New York 0.456          1
6: Person 1                          go there     New York 0.456          1
7: Person 2    One more thought for the road! Pennsylvania 0.124          2
8: Person 2                   I am going now. Pennsylvania 0.124          2
9: Person 2                         Good day. Pennsylvania 0.124          2
   sentence_id
1:           1
2:           2
3:           3
4:           4
5:           5
6:           6
7:           1
8:           2
9:           3

sentimentr documentation built on Oct. 12, 2021, 9:06 a.m.