【问题标题】:Extract dates from text with spaCy in relation to a given date从与给定日期相关的 spaCy 文本中提取日期
【发布时间】: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


    【解决方案1】:

    使用 CoreNLP 的 SUTime,这可以很容易地完成: https://github.com/FraBle/python-sutime

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多