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

Multiple unTag for a match using sweep() #1009

Open
thegoatherder opened this issue Apr 5, 2023 · 0 comments
Open

Multiple unTag for a match using sweep() #1009

thegoatherder opened this issue Apr 5, 2023 · 0 comments

Comments

@thegoatherder
Copy link
Contributor

Is it possible to unTag multiple tags when using a match object and sweep()?

You can see in the example below that unTag works the first time it's used but is ignored for the same match when used on subsequent tags

I want the months and clinic to unTag: 'Person' but it's ignored.

I have tried variants:

unTag: ['ProperNoun', 'Person'] // throws error
unTag: 'ProperNoun,Person' // unTags nothing
unTag: 'ProperNoun|Person' // unTags nothing
unTag: '#ProperNoun #Person' // unTags nothing
unTag: 'ProperNoun Person' // unTags Person

Reproduce Issue:

const nlp = require('compromise')

const text = 'There are Thirty days in the January Clinic'
const doc = nlp(text)
doc.debug()

const matchObjects = [
  {
    match:
      '(One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten|Eleven|Twelve|Thirteen|Fourteen|Fifteen|Sixteen|Seventeen|Eighteen|Nineteen|Twenty|Thirty|Forty|Fifty|Sixty|Seventy|Eighty|Ninety|Hundred)',
    reason: 'Capitalisation',
    tag: 'Value',
  },
  {
    match: '(January|February|March|April|May|June|July|August|September|October|November|December)',
    reason: '',
    tag: 'Month',
    unTag: 'ProperNoun',
  },
  {
    match: 'Clinic',
    reason: '',
    unTag: 'ProperNoun',
  },
  // ❌ these rules get ignored?
  {
    match: 'Clinic',
    reason: '',
    unTag: 'Person',
  },
  {
    match: '(January|February|March|April|May|June|July|August|September|October|November|December)',
    reason: '',
    unTag: 'Person',
  },
]
const net = nlp.buildNet(matchObjects)
doc.sweep(net)

doc.debug()

Output:

┌─────────
  │ 'There'    - There
  │ 'are'      - Verb, Copula, PresentTense
  │ 'Thirty'   - ProperNoun, Noun
  │ 'days'     - Date, Noun, Duration, Plural
  │ 'in'       - Preposition
  │ 'the'      - Determiner
  │ 'January'  - Noun, Singular, ProperNoun, Person
  │ 'Clinic'   - ProperNoun, Noun, Singular, Person



  ┌─────────
  │ 'There'    - There
  │ 'are'      - Verb, Copula, PresentTense
  │ 'Thirty'   - Value
  │ 'days'     - Date, Noun, Duration, Plural
  │ 'in'       - Preposition
  │ 'the'      - Determiner
  │ 'January'  - Noun, Singular, Date, Month
  │ 'Clinic'   - Noun, Singular, Person
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

1 participant