Skip to content

Instantly share code, notes, and snippets.

@jjesusfilho
Last active June 1, 2022 22:44
Show Gist options
  • Save jjesusfilho/3fdacd7f69ed44f4f73193121e95f53f to your computer and use it in GitHub Desktop.
Save jjesusfilho/3fdacd7f69ed44f4f73193121e95f53f to your computer and use it in GitHub Desktop.
classificador de partes
partes <- partes %>%
mutate(pessoa = case_when(
str_detect(parte, "(?i)(t[ée]rio p[úu]blico|justi[cç]a\\s+p[uú]blica|\\bmp\\b)") ~ "MP",
str_detect(parte, "(?i)defensoria") ~ "Defensoria",
str_detect(parte,"(?i)fazenda") ~ "poder_executivo",
str_detect(parte,"(?i)partido") ~ "partido",
str_detect(parte,"(?i)(assoc|direitos|defesa|sociedade|federa[cç][ãa]o|estudant|acad.mico|ocupante|funcion[áa]rio|prote[cç]|sindicato|\\bsind\\.?\\b|sint|morador|funda[çc][ãa]o|instituto|movimento|organiza|consumidor|cons\\.|ong|usu[áa]rio|conselho)") ~ "TS",
str_detect(parte,"(?i)(munic|prefeit|\\estad\\w+)") ~ "poder_executivo",
str_detect(parte,"(?i)\\bcentro\\b") ~ "centro",
soma > 3 ~ "PF",
str_detect(parte,"(?i)(\\bs[./]?a\\.?$|ltda\\.?|\\bME\\.?\\b|\\bMEI\\.?\\b|\\bEPP\\.?\\b|eirel[ei]|\\bs/?c\\b)") ~ "PJ",
TRUE ~ "D"))
partes <- partes |>
mutate(pessoa = case_when(
str_detect(parte, "(?i)(banco|financeira|cr[ée]dito|financ|bank|\\bpag|cred)") ~ "financeira",
str_detect(parte,"(?i)(\\bs[./]?a\\.?$|\\bs\\.\\a\\.|\\bs/a.?\\b|ltda\\.?|\\b[aá]gua\\b|usina|empreend|com[ée]rci|representa|\\bME\\.?\\b|\\bMEI\\.?\\b|\\bEPP\\.?\\b|eirel[ei]|\\bs/?c\\b|companhia|\\bcia\\b)") ~ "PJ",
TRUE ~"PF"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment