Skip to content

search_dates() silently drops a French date when STRICT_PARSING=True and multiple languages are passedΒ #1326

Closed

Description

@KameniAlexNea

"""
Bug: search_dates() silently drops a French date when STRICT_PARSING=True and multiple languages are passed,
if the string ends with a bare uppercase token that is a valid ISO 639-1 language code (e.g. "FR").

dateparser version: 1.4.0
Python version: 3.13
"""

import dateparser
import dateparser.search

print("dateparser version:", dateparser.__version__)

TEXT = "Date de facture 23 juillet 2020 Condition Redevable livraison FR"

# Works β€” single language, no ambiguity for the language detector
r1 = dateparser.search.search_dates(TEXT, languages=["fr"], settings={"STRICT_PARSING": True})

# Fails β€” same string, same settings, but 7 languages passed
r2 = dateparser.search.search_dates(TEXT, languages=["en", "fr", "es", "pt", "de", "it", "ar"], settings={"STRICT_PARSING": True})

print(f"languages=['fr'],    STRICT_PARSING=True  β†’ {r1}")   # Expected: [('23 juillet 2020', datetime(...))]
print(f"languages=[7 langs], STRICT_PARSING=True  β†’ {r2}")   # Bug:      None

assert r1 is not None, "Baseline broken"
assert r2 is not None, f"BUG: date not found when multiple languages passed β€” got {r2}"

Note that it works well when we remove FR in this input TEXT

It works also if we replace FR with EN or US or Frn

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions