replace_names: Replace First/Last Names

Description Usage Arguments Value Examples

View source: R/replace_names.R

Description

Replaces first/last names.

Usage

1
2
3
4
replace_names(x, names = textclean::drop_element(gsub("(^.)(.*)",
  "\\U\\1\\L\\2", c(lexicon::freq_last_names[[1]],
  lexicon::common_names), perl = TRUE), "^([AIU]n|[TSD]o|H[ea]Pa|Oh)$"),
  replacement = "", ...)

Arguments

x

The text variable.

names

A vector of names to replace. This may be made more custom through a vector provided from a named entity extractor.

replacement

A string to replace names with.

...

Other arguments passed to replace_tokens.

Value

Returns a vector with names replaced.

Examples

1
2
3
4
5
6
7
8
9
x <- c(
    "Mary Smith is not here",
    "Karen is not a nice person",
    "Will will do it",
    NA
) 

replace_names(x)
replace_names(x, replacement = '<<NAME>>')

Example output

[1] "  is not here"         " is not a nice person" " will do it"          
[4] NA                     
[1] "<<NAME>> <<NAME>> is not here" "<<NAME>> is not a nice person"
[3] "<<NAME>> will do it"           NA                             

textclean documentation built on May 2, 2019, 7:22 a.m.