keyword_sentence(file, word)

Arguments

file

word

Details

Value

References

Author

Note

See also

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--  or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (file, word)
{
    text <- read_lines(here::here(file)) %>% str_c(collapse = " ") %>%
        str_squish()
    if (str_detect(text, regex(word, ignore_case = T))) {
        text %<>% enframe(name = NULL, value = "text") %>% unnest_tokens(sentence,
            text, token = "sentences") %>% filter(str_detect(sentence,
            word)) %>% .$sentence %>% str_c(collapse = "...")
    }
    else {
        text <- NA
    }
  }
#> function (file, word)
#> {
#>     text <- read_lines(here::here(file)) %>% str_c(collapse = " ") %>%
#>         str_squish()
#>     if (str_detect(text, regex(word, ignore_case = T))) {
#>         text %<>% enframe(name = NULL, value = "text") %>% unnest_tokens(sentence,
#>             text, token = "sentences") %>% filter(str_detect(sentence,
#>             word)) %>% .$sentence %>% str_c(collapse = "...")
#>     }
#>     else {
#>         text <- NA
#>     }
#>   }
#> <environment: 0x127257548>