You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As title states, when a capture group is trailing an optional negative (? or {0,x}) it fails to capture the group.
If the negative is not optional it's fine (see doc8 example below).
Hopefully it's just down to me not understanding match syntax, otherwise it may be related to #1139?
'use strict'/** @type {import('compromise').default} */constnlp=require('compromise')consttext='To be reviewed urgently'constdoc=nlp(text)constdoc2=doc.clone()constdoc3=doc.clone()constdoc4=doc.clone()constdoc5=doc.clone()constdoc6=doc.clone()constdoc7=doc.clone()// Tags #PastTense and #Urgent as #SuperSeriousconsole.log('negative tag range, no group access')doc2.match('#PastTense !#Conjunction{0,10} [#Adverb]').tag('SuperSerious')doc2.debug()// Does not tag #Adverb as #SuperSeriousdoc3.match('#PastTense !#Conjunction{0,10} [#Adverb]',0).tag('SuperSerious')doc3.debug()// Tags #Adverb as #SuperSeriousconsole.log('positive tag optional')doc4.match('#PastTense #Conjunction{0,10} [#Adverb]',0).tag('SuperSerious')doc4.debug()// Does not tag #Adverb as #SuperSeriousconsole.log('negative tag optional')doc5.match('#PastTense !#Conjunction? [#Adverb]',0).tag('SuperSerious')doc5.debug()// Does not tag #Adverb as #SuperSeriousconsole.log('negative non-tag optional')doc6.match('#PastTense !and{0,10} [#Adverb]',0).tag('SuperSerious')doc6.debug()console.log('negative tag range, no tagging')consttest=doc7.match('#PastTense !#Conjunction{0,10} [#Adverb]',0)console.log(test.out('text')||'no match')console.log('negative tag range')constnewDoc=nlp('To be reviewed super urgently')constdoc8=newDoc.match('#PastTense !#Conjunction [#Adverb]',0).tag('SuperSerious')doc8.debug()
The text was updated successfully, but these errors were encountered:
Fdawgs
changed the title
Capture group tagging does not work when trailing a negative
Capture group tagging does not work when trailing an optional negative
Oct 3, 2024
Node version: 20.17.0
Compromise version: 14.14.0
Compromise-dates version: 3.6.0
As title states, when a capture group is trailing an optional negative (
?
or{0,x}
) it fails to capture the group.If the negative is not optional it's fine (see
doc8
example below).Hopefully it's just down to me not understanding match syntax, otherwise it may be related to #1139?
The text was updated successfully, but these errors were encountered: