Exercise: Rule-Based Matchmaking
Let's test the concepts we've learned with an exercise.
We'll cover the following
Problem
You are working on a project that requires you to extract all the dates mentioned in a given text. You decide to use the spaCy Matcher
class to define a pattern for matching dates. The pattern should match dates in the format "YYYY-MM-DD" ("2022-02-15"). Write a Python program that does the following:
Defines a spaCy
Matcher
object and adds a pattern to it that matches dates in the format "YYYY-MM-DD."Processes the text "I have a meeting on 2023-02-15 and another meeting on 2023-02-20" using the spaCy NLP pipeline.
Matches the defined pattern against the processed document and prints out the matched spans.
Sample Input:
Get hands-on with 1200+ tech skills courses.