def test_time_convert(self): """ 时间转换测试. """ print('{} test_time_convert {}'.format('-' * 15, '-' * 15)) tc = TimeNormalizer(isPreferFuture=False) texts = [ '三月', '今年三月', '三月中旬', '去年三月十五日', '去年六月份', '今天', '昨天下午三点', '一个月后', '明年', '烟花三月下扬州' ] for text in texts: print('{}\t{}'.format(text, tc.parse(text))) """
@Software: PyCharm @File : ner_utils.py @Time : 2020/7/20 11:20 下午 @Desc : 实体提取工具类, 调用实体提取接口 """ from time_convert import TimeNormalizer tc = TimeNormalizer() def get_time(msg): """ 提取时间信息 :param msg: :return: """ result = tc.parse(msg) print(result) return result if __name__ == '__main__':