问题
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