Skip to content

Commit 60c837c

Browse files
authored
Fix WhatsAppChatLoader regex pattern for 24 hour time format (langchain-ai#2458)
Fix for 24 hour time format bug. Now whatsapp regex is able to parse either 12 or 24 hours time format. Linked [issue](langchain-ai#2457).
1 parent 3acf423 commit 60c837c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

langchain/document_loaders/whatsapp_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def load(self) -> List[Document]:
2828

2929
for line in lines:
3030
result = re.match(
31-
r"(\d{1,2}/\d{1,2}/\d{2,4}, \d{1,2}:\d{1,2} (?:AM|PM)) - (.*?): (.*)",
31+
r"(\d{1,2}/\d{1,2}/\d{2,4}, \d{1,2}:\d{1,2}(?: AM| PM)?) - (.*?): (.*)",
3232
line.strip(),
3333
)
3434
if result:

0 commit comments

Comments
 (0)