Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging words containing hyphen does not work #977

Closed
thegoatherder opened this issue Oct 31, 2022 · 3 comments
Closed

Tagging words containing hyphen does not work #977

thegoatherder opened this issue Oct 31, 2022 · 3 comments

Comments

@thegoatherder
Copy link
Contributor

Found another issue with hyphens...

const nlp = require('compromise')
nlp.verbose('tagger')

nlp.plugin({
  words: {
    'x-ray': 'Diagnostic',
  },
})

nlp(`x-ray`).debug()

The term x-ray seems to get tagged as 2 separate terms, and so never gets the #Diagnostic tag:

 ray         → #Noun                    1-lexicon
 x           → #Noun                    3-[fallback]
 x           → #Singular                3-singular-guess
 ray         → #Singular                3-singular-guess
        ↓ - 'x' (#Noun)  
 ray         → #Singular                3-[switch] (Person|Noun)
 ray         → #Noun                     -inferred by #Singular

  ┌─────────
  │ 'x'        - Noun, Singular
  │ 'ray'      - Noun, Singular
spencermountain added a commit that referenced this issue Oct 31, 2022
@thegoatherder
Copy link
Contributor Author

@spencermountain - thanks for this fix.

I was interested to see the fix is to define the word x-ray in data/lexicon/nouns/singulars.js

Does this imply that all words containing hyphen are seen as two-words in Compromise unless they are hard-coded into the singulars lexicon?

What would be the plugin syntax for this update if we wanted to fix via plugin? (for future ref) I tried the following but got the same output as reported above:

const nlp = require('compromise')
nlp.verbose('tagger')

nlp.plugin({
  words: {
    'x-ray': 'Diagnostic',
  },
  tags: {
    'x ray': { isA: 'Singular' },   // <-- Is this the correct fix? Does not seem to work
  },
})

nlp(`x-ray`).debug()

Outputs:

ray         → #Noun                    1-lexicon
 x           → #Noun                    3-[fallback]
 x           → #Singular                3-singular-guess
 ray         → #Singular                3-singular-guess
        ↓ - 'x' (#Noun)  
 ray         → #Singular                3-[switch] (Person|Noun)
 ray         → #Noun                     -inferred by #Singular

  ┌─────────
  │ 'x'        - Noun, Singular
  │ 'ray'      - Noun, Singular

spencermountain added a commit that referenced this issue Nov 4, 2022
@spencermountain spencermountain mentioned this issue Nov 4, 2022
Merged
@spencermountain
Copy link
Owner

fixed in 14.7.0
cheers

@thegoatherder
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants