Fix WhatsAppChatLoader regex pattern for 24 hour time format (#2458)

Fix for 24 hour time format bug. Now whatsapp regex is able to parse
either 12 or 24 hours time format.

Linked [issue](https://github.com/hwchase17/langchain/issues/2457).
This commit is contained in:
Luk Regarde 2023-04-06 18:45:14 +02:00 committed by GitHub
parent 3acf423de0
commit 60c837c58a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@ class WhatsAppChatLoader(BaseLoader):
for line in lines: for line in lines:
result = re.match( result = re.match(
r"(\d{1,2}/\d{1,2}/\d{2,4}, \d{1,2}:\d{1,2} (?:AM|PM)) - (.*?): (.*)", r"(\d{1,2}/\d{1,2}/\d{2,4}, \d{1,2}:\d{1,2}(?: AM| PM)?) - (.*?): (.*)",
line.strip(), line.strip(),
) )
if result: if result: