Datefinder Module Stranger behavior on particular string

我只是一个虾纸丫 提交于 2019-12-11 03:12:41

问题


I have two strings:

s1 = 'Agreement dated on March 9, 2007'
s2 = 'Agreement signed on March 9, 2007'

I run below code on the string

import datefinder
matches =datefinder.find_dates(s1) ## or s2
for match in matches:
       print (match)

s2 gives me desired result but s1 doesn't as it contains the word dated.

P.S. I have used datefinder as I had multiple date formats and hence need to write multiple regex. This worked well just for this exception

Any idea why this strange behavior?


回答1:


It's not a bug in datefinder.

dated is one of the token patterns in the regex code:

EXTRA_TOKENS_PATTERN = r"due|by|on|during|standard|daylight|savings|time|date|dated|of|to|through|between|until|at|day"

You will likely need to write a regex to by pass the issue or become a contributor to the project to fix the issue.

https://github.com/akoumjian/datefinder



来源:https://stackoverflow.com/questions/54673878/datefinder-module-stranger-behavior-on-particular-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!