Created
November 17, 2017 13:22
-
-
Save romainfrancois/0db06fb7f5d0f6543600de9c43ed56be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rvest) | |
library(glue) | |
inclusivise <- function( mot = "étudiant" ){ | |
url <- glue( "http://www.larousse.fr/dictionnaires/rechercher/?q={mot}&l=francais&culture=" ) | |
mots <- url %>% | |
read_html() %>% | |
html_node(".AdresseDefinition") %>% | |
html_text() %>% | |
str_split(",") %>% | |
flatten_chr() %>% | |
str_trim() | |
len <- min( nchar(mots) ) | |
ncommon <- str_split( mots, "") %>% | |
map( head, len ) %>% | |
pmap(~.x==.y) %>% | |
flatten_lgl() %>% | |
sum() | |
glue( "{prefixe}{m}·{f}", | |
prefixe = substr(mots[1], 1, ncommon), | |
m = substr(mots[1], ncommon + 1, nchar(mots[1]) ), | |
f = substr(mots[2], ncommon + 1, nchar(mots[2]) ) | |
) | |
} | |
inclusivise( "étudiant") | |
inclusivise( "acteur") |
Author
romainfrancois
commented
Nov 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment