23 lines
516 B
JavaScript
23 lines
516 B
JavaScript
|
|
const articlesApostrophes = {
|
|
'de' : 'd\'',
|
|
'le' : 'l\'',
|
|
'la' : 'l\''
|
|
}
|
|
export class Grammar {
|
|
|
|
static apostrophe(article, word) {
|
|
if (articlesApostrophes[article] && Grammar.startsWithVoyel(word)) {
|
|
return articlesApostrophes[article] + word
|
|
}
|
|
return article + ' ' + word;
|
|
}
|
|
|
|
static startsWithVoyel(word) {
|
|
return word.match(/^[aeiouy]/i)
|
|
}
|
|
|
|
static toLowerCaseNoAccent(words) {
|
|
return words?.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") ?? words;
|
|
}
|
|
} |