match capitalised pronouns in bio

This commit is contained in:
ItsVipra 2023-07-18 12:24:08 +02:00
parent 380a865c84
commit f37c767fbc
No known key found for this signature in database
2 changed files with 5 additions and 1 deletions

View file

@ -284,7 +284,10 @@ const knownPronouns = [
function extractFromBio(bio) { function extractFromBio(bio) {
const exactMatches = bio.matchAll(/(\w+) ?\/ ?(\w+)/gi); const exactMatches = bio.matchAll(/(\w+) ?\/ ?(\w+)/gi);
for (const [match, subjective, objective] of exactMatches) { for (const [match, subjective, objective] of exactMatches) {
if (knownPronouns.includes(subjective) && knownPronouns.includes(objective)) { if (
knownPronouns.includes(subjective.toLowerCase()) &&
knownPronouns.includes(objective.toLowerCase())
) {
return match.replaceAll(" ", ""); return match.replaceAll(" ", "");
} }
} }

View file

@ -104,6 +104,7 @@ const bioExtractTests = [
["I'm cute af (she / they)", "she/they"], // with whitespace between pronouns ["I'm cute af (she / they)", "she/they"], // with whitespace between pronouns
["pronouns: any/all", "any/all"], // any pronouns ["pronouns: any/all", "any/all"], // any pronouns
["any pronouns", "any pronouns"], // any pronouns ["any pronouns", "any pronouns"], // any pronouns
["He/Him", "He/Him"], //capitalised pronouns
]; ];
for (const [input, expects] of bioExtractTests) { for (const [input, expects] of bioExtractTests) {
bioExtractSuite(input, async () => { bioExtractSuite(input, async () => {