Open Fdawgs opened 6 days ago
Node version: 22.2.0 Compromise version: 14.13.0
Using replaceWith, with the keep.keepTags param property set to true, I would expect it to retain tags as documented.
replaceWith
keep.keepTags
Example:
'use strict' /** @type {import('compromise').default} */ const nlp = require('compromise') const text = 'Worst-case Ontario, you get caught.' const doc = nlp(text) console.log(doc.out('tags')) /* Prints: [ { worst: [ 'Adjective', 'Superlative', 'Hyphenated' ], case: [ 'Noun', 'Singular', 'Hyphenated' ], ontario: [ 'Noun', 'Singular', 'Place', 'ProperNoun', 'Region' ], you: [ 'Noun', 'Pronoun' ], get: [ 'Verb', 'PresentTense', 'Infinitive' ], caught: [ 'Verb', 'PastTense' ] } ] */ doc.match('Ontario').replaceWith('scenario', { keepTags: true }) console.log(doc.out('tags')) /* Prints: [ { worst: [ 'Adjective', 'Superlative', 'Hyphenated' ], case: [ 'Noun', 'Singular', 'Hyphenated' ], scenario: [ 'Noun', 'Singular' ], you: [ 'Noun', 'Pronoun' ], get: [ 'Verb', 'PresentTense', 'Infinitive' ], caught: [ 'Verb', 'PastTense' ] } ] Expected: [ { worst: [ 'Adjective', 'Superlative', 'Hyphenated' ], case: [ 'Noun', 'Singular', 'Hyphenated' ], scenario: [ 'Noun', 'Singular', 'Place', 'ProperNoun', 'Region' ], you: [ 'Noun', 'Pronoun' ], get: [ 'Verb', 'PresentTense', 'Infinitive' ], caught: [ 'Verb', 'PastTense' ] } ] */
Node version: 22.2.0 Compromise version: 14.13.0
Using
replaceWith
, with thekeep.keepTags
param property set to true, I would expect it to retain tags as documented.Example: