question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apostrophe in custom word prevents matching

See original GitHub issue

I’m developing a custom lexicon of plant names, which include “Queen Anne’s lace” and “baby’s breath”, however when a word in my custom lexicon includes an apostrophe, it doesn’t seem to match. Is there something I need to do to force it to use the custom lexicon?

Additionally, I was looking through compromise’s default lexicon and it seems like words in there with apostrophes aren’t matching, either:

nlp("Starbucks is a great restaurant.").match("#Organization").out("array") // ✅ nlp("Applebee's is a great restaurant.").match("#Organization").out("array") // ❌ https://github.com/spencermountain/compromise/blob/52fb03e7a26e8caed08bf04d893b0044aab4c538/data/lexicon/nouns/organizations.js#L275

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
spencermountaincommented, Jul 2, 2022

hey @msjonker this is tagging now in 14.4.0 it just throws-away the apostrophe, when creating the lexicon. if you want to ensure it’s a Possessive, you can do something like:

doc.match('queen (anne && #Possessive) lace').tag('Flower')

cheers

0reactions
msjonkercommented, Jul 10, 2022

Sorry, for the late reply; I was on vacation last week.

This solution looks great! I was working on a PR that evaluated matching the normal form of the term first, then falling back to the machine form of the term, but this seems like a much better solution.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

regex - How can I allow or ignore apostrophes? - Stack Overflow
I need an expression that will allow (or ignore) the apostrophe so that all words that end in "ria" are matched independent of...
Read more >
How to stop getting e accent when I hit apostrophe - Super User
I hit something that now makes accented vowels come up whenever I hit the apostrophe key. I don't know how to fix it....
Read more >
How to get MS Word to stop marking contractions without an ...
I think I can partially do this by deleting every autocorrect entry dealing with apostrophes, but I'm wondering if there is an option...
Read more >
Is it possible to search for words with an apostrophe, like ...
After the latest search changes, we'll search any term in quotes as an exact match, including symbols such as apostrophes.
Read more >
Regex Boundaries and Delimiters—Standard and Advanced
Word boundaries are useful when you want to match a sequence of letters (or digits) on their own, or to ensure that they...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found