Live data from Hacker News

JavaScript library that converts a string to gender-neutral language?

news.ycombinator.com

11–13 of 13 posts

Re: JavaScript library that converts a string to gender-neutral language?

#11

https://alexjs.com/ You can either integrate it with external tooling (common use is in a build pipeline for docs), or use the JS API directly: https://github.com/get-alex/alex#api .

Thanks for sharing this!

I've had a quick look and it looks great for identifying where improvements can be made to content in your codebase.

I don't think it's suitable for my use case as the content will be in a database or localStorage, and it seems to only be able to recommend changes rather than dynamically make them. Unless I have misinterpreted things.

Re: JavaScript library that converts a string to gender-neutral language?

#12

https://alexjs.com/ You can either integrate it with external tooling (common use is in a build pipeline for docs), or use the JS API directly: https://github.com/get-alex/alex#api .

Thanks for sharing this! I've had a quick look and it looks great for identifying where improvements can be made to content in your codebase. I don't think it's suitable for my use case as the content will be in a database or localStorage, and it seems to only be able to recommend changes rather than dynamically make them. Unless I have misinterpreted things.

When using it as a lib you can pass a markdown string (https://github.com/get-alex/alex#markdownvalue-config) or raw text string (https://github.com/get-alex/alex#textvalue-config). This will return an object that should contain everything you need to perform a naive replacement.

Re: JavaScript library that converts a string to gender-neutral language?

#13

Would it work if you replaced “he” or “she” with “candidate” and “his” or “her” with “candidate’s” or with “their”? That will prevent errors of concord (everything remains singular so you don’t have to change the verbs) and the sentences will mostly flow fine. Your example would become: “Candidate is an esteemed archaeologist and writer based in Greece. Candidates’s (or “their”) primary residence is Athens, but they…

Hmm this could work. I would prefer "they"/"their", but I quite like the "the candidate"/"their" option! That seems to work. I will have a play around with this to see if it reads well with a few more examples.

I’m not sure how much my suggestions answer your original question, but in the pursuit of proper grammatical structure when trying to rewrite speech, compromise [0] might be of use to you. I’ve only played around with it for a few hours at most, but from my limited experience it is a very effective (if verbose and/or a little bloated in it’s API) tool for language analysis. With some tomfoolery I’m confident you could combine it with the GP’s recommendation of alexjs to replace strings slightly-less-naively.

[0] https://github.com/spencermountain/compromise

Post reply on HN