Add something that changes from a to an based on the following word #39

Closed
opened 2025-07-20 10:18:00 -04:00 by jean · 3 comments
Owner

a/an (word)/

e.g.
a/an Earl/ -> an Earl
a/an Queen/ -> a Queen

a/an (word)/ e.g. a/an Earl/ -> an Earl a/an Queen/ -> a Queen
Author
Owner
  • Would it be better to remove the final slash? The final slash is meant to distinguish it from using "a/an" regularly, but it'd be better to have than not.
  • Is a/an too common? Yes.

aan/word? Too cryptic!
a/an word? Maybe best, but still common outside of this. :/

Let's go with a/an.

- Would it be better to remove the final slash? The final slash is meant to distinguish it from using "a/an" regularly, but it'd be better to have than not. - Is a/an too common? Yes. aan/word? Too cryptic! a/an word? Maybe best, but still common outside of this. :/ Let's go with a/an.
Author
Owner

Big issue: vowels don't necessarily indicate how a word is pronounced and, as a result, whether it should be prefaced with a/an.

Big issue: vowels don't necessarily indicate how a word is pronounced and, as a result, whether it should be prefaced with a/an.
Author
Owner

Okay. I've found a library that does this. In cases where the library doesn't work, the user can add an also replacement of "a/an also/(word)" -> "a (word)" or "an (word)" depending on what sounds right.

It doesn't work for plurals, but I don't think it needs to. In case I ever want to check for plurals, this library does that.

Some specifics on how it does work:

  • Acronyms .e.g. UFO are treated as having their letters pronounced. This could cause some unfortunate edge cases when used in conjunction with the capitalize function, but capitalize really shouldn't be used on strings of words. It may be good to specify as much in the wiki.
  • Numbers can be treated colloquially (a/an 1900 -> nineteen-hundred) or not (a/an 1900 -> a one-thousand nine-hundred) and I'm only going to treat numbers as colloquial, since dates are much more commonly when something like this would be written.
Okay. I've found [a library]( https://www.npmjs.com/package/indefinite) that does this. In cases where the library doesn't work, the user can add an also replacement of "a/an also/(word)" -> "a (word)" or "an (word)" depending on what sounds right. It doesn't work for plurals, but I don't think it needs to. In case I ever want to check for plurals, [this library](https://www.npmjs.com/package/is-plural) does that. Some specifics on how it does work: - Acronyms .e.g. UFO are treated as having their letters pronounced. This could cause some unfortunate edge cases when used in conjunction with the capitalize function, but capitalize really shouldn't be used on strings of words. It may be good to specify as much in the wiki. - Numbers can be treated colloquially (a/an 1900 -> nineteen-hundred) or not (a/an 1900 -> a one-thousand nine-hundred) and I'm only going to treat numbers as colloquial, since dates are much more commonly when something like this would be written.
jean referenced this issue from a commit 2025-07-20 13:21:33 -04:00
jean closed this issue 2025-07-20 13:21:33 -04:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jean/metamorpov#39
No description provided.