【发布时间】:2019-02-22 23:26:02
【问题描述】:
我想从新闻文章中提取日期,以文本形式给出,如 'next week' 或 'February',给出文章的发布日期。 IE。如果该文章于 2019 年 2 月 13 日发布并且该文章中提到了 'next week',我希望该函数为 'next week' 找到 2019 年 2 月 20 日。有人知道该怎么做吗?我想用 spaCy 的实体查找器来做,然后为每个“日期”实例手动编写一个函数,但一定有更好的东西。
这是我的例子:
text = """Chancellor Angela Merkel and some of her ministers will
discuss at a cabinet retreat next week ways to avert driving
bans in major cities after Germany's top administrative court
in February allowed local authorities to bar heavily polluting
diesel cars."""
article_date = '2019-02-13'
我的理想结果如下:
ref_dates = {'next_week': '2019-02-20',
'february': '2019-02-01'}
【问题讨论】:
标签: python-3.x spacy