Skip to content

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

@Fdawgs

Description

@Fdawgs

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:

'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
 */

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions