Fuzzy matching personalizzato

Espressioni regolari intermedie in R

Angelo Zehr

Data Journalist

Combinare due fuzzy match

tabelle dei film

Espressioni regolari intermedie in R

Combinare due fuzzy match

colonne evidenziate

Espressioni regolari intermedie in R

Fuzzy match: funzioni helper

Per il confronto tra stringhe:

small_str_distance <- function(left, right) {
  stringdist(left, right) <= 5
}

Per il confronto numerico:

close_to_each_other <- function(left, right) {
  abs(left - right) <= 3
}
Espressioni regolari intermedie in R

Il fuzzy join

fuzzy_left_join(
  a, b,
  by = c(
    "title" = "prod_title",
    "year" = "prod_year"
  ),
  match_fun = c(
    "title" = small_str_distance,
    "year" = close_to_each_other
  )
)
Espressioni regolari intermedie in R

Il fuzzy join: risultato

tabella unita

Espressioni regolari intermedie in R

Passiamo alla pratica!

Espressioni regolari intermedie in R

Preparing Video For Download...