#1170·compromise

Compromise-dates plugin: Trailing dash retained as part of date

Author: FdawgsCreated Feb 11, 2025Updated Feb 16, 2025
Labelsbughmmm

Node version: 20.18.1 Compromise version: 14.14.4 Compromise-dates version: 3.7.1

When a date is trailed by a dash, it is retained as part of the date. I assume this is because compromise-dates considers it part of an (incomplete) dash date-range (i.e. 2024-01-01 - 2024-01-02)?

Example:

javascript
'use strict'

const nlp = require('compromise')
const nlpDates = require('compromise-dates')
nlp.plugin(nlpDates)

const text = '2025-05-11 - They have taken the bridge and the Second Hall'

const doc = nlp(text)
console.log(doc.dates().out())
/**
 * Output: 2025-05-11 -
 * Expected: 2025-05-11
 */

Source: spencermountain/compromise