Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More precision and added Brigitte #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions js/correct.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
var textNode, walk=document.createTreeWalker(document,NodeFilter.SHOW_TEXT,null,false);
var rManu = new RegExp('Emmanuel( |)Macron|'+
'le Pr[eé]sident de la R[eé]publique fran[cç]aise|'+
'Pr[eé]sident de la R[eé]publique fran[cç]aise|'+
'le Pr[eé]sident de la R[eé]publique|'+
'du Pr[eé]sident de la R[eé]publique|'+
'M. le Pr[eé]sident de la R[eé]publique|'+
'Monsieur le Pr[eé]sident de la R[eé]publique|'+
'Monsieur le Pr[eé]sident|'+
'Emmanuel Jean-Michel Frédéric Macron|'+
'M. Macron', 'gi')

var rBoth = new RegExp('Emmanuel et Brigitte Macron|'+
'Brigitte et Emmanuel Macron|'+
'Emmanuel Macron et Brigitte Macron|'+
'M. et Mme Macron|'+
'Mme et M. Macron', 'gi')

while(textNode=walk.nextNode()) {
var rExp = new RegExp('Emmanuel Macron|'+
'M. le Président de la République|'+ // Keep the dot in case of "Mr" or "M."
'le Président de la République|'+ // Put this one after, so that the one above matches first
'Monsieur le Président de la République|'+
'Monsieur le Président|'+
'Président de la République française|'+
'Président de la République|' +
'Emmanuel Jean-Michel Frédéric Macron|',
'M. Macron', 'gi');

textNode.nodeValue = textNode.nodeValue.replace(rExp, 'Manu')
textNode.nodeValue = textNode.nodeValue.replace(rManu, 'Manu')
textNode.nodeValue = textNode.nodeValue.replace(rBoth, 'Manu et Brigitte')
}