Small NER model for dates?

I’m looking for a small NER model that’s specialized in recognizing dates, in English.
If necessary, the model may not need to know to recognize other entities besides dates.

Hello :wave:

This rule-based library from Meta called duckling works like a charm. You will write “last monday” and it will even parse it and you can use it to send the date to backend and automate calendar actions (just one of couple of stuff you can do with it).

1 Like

Hi Merve, I’m not sure I understood how duckling works… I’m still learning a lot of stuff. From the link, it seems to be a library in Haskell. I forgot to say that I’m using python… The wrappers I’ve seen for this, haven’t been updated in a while (4years at least). Do you know of something in python?

Actually you can use the spacy models for this. There are few dozens of them for different languages.

You can see spacy/en_core_web_sm · Hugging Face for example. If you expand label scheme, you can see it has a date label.

!pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("Last monday was the first of July")
for ent in doc.ents:
  print(ent, ent.label_)

Gives me

Last monday DATE
the first of DATE
July DATE
1 Like