{"id":27336,"library":"recognizers-text","title":"Recognizers-Text","description":"Recognizers-Text is a Microsoft-maintained NLP library for recognizing and normalizing numbers, units, date/time, phone numbers, emails, and URLs from unstructured text. It supports multiple languages (English, Spanish, French, Chinese, Japanese, and more) via separate per-culture packages. The Python package is at version 1.0.2a2 (alpha) and lags behind the .NET and JavaScript releases (v1.8.x). Releases are irregular.","status":"active","version":"1.0.2a2","language":"python","source_language":"en","source_url":"https://github.com/Microsoft/Recognizers-Text","tags":["nlp","entity-recognition","date-parser","number-parser","microsoft"],"install":[{"cmd":"pip install recognizers-text","lang":"bash","label":"Core package"},{"cmd":"pip install recognizers-text[datatypes-timex-expression]","lang":"bash","label":"With datatypes-timex-expression extra"}],"dependencies":[{"reason":"Required for working with Timex properties and date/time resolution.","package":"recognizers-text-datatypes-timex-expression","optional":true}],"imports":[{"note":"Culture is a class within recognizers_text, not a submodule.","wrong":"from recognizers_text.culture import Culture","symbol":"Culture","correct":"from recognizers_text import Culture"},{"note":"All recognizers are in the 'recognizers_text' top-level package.","wrong":"from recognizers_number import recognize_number","symbol":"recognize_number","correct":"from recognizers_text import recognize_number"},{"note":"","wrong":null,"symbol":"recognize_datetime","correct":"from recognizers_text import recognize_datetime"},{"note":"ModelResult is exported from recognizers_text directly.","wrong":"from recognizers_text.model import ModelResult","symbol":"ModelResult","correct":"from recognizers_text import ModelResult"}],"quickstart":{"code":"from recognizers_text import Culture, recognize_datetime\n\n# Recognize dates in English text\nresults = recognize_datetime(\"I'll be there on 2025-06-15\", Culture.English)\nfor result in results:\n    print(f\"Text: {result.text}, Type: {result.type_name}, Resolution: {result.resolution}\")\n\n# Example output:\n# Text: 2025-06-15, Type: datetimeV2.date, Resolution: {'values': [{'timex': '2025-06-15', 'type': 'date', 'value': '2025-06-15'}]}","lang":"python","description":"Recognizes a date from an English sentence and prints the recognition result."},"warnings":[{"fix":"If you need the latest recognizers, use the .NET or JavaScript libraries instead.","message":"The Python package (1.0.2a2) is an alpha release and significantly outdated compared to the .NET/JS versions (v1.8.x). Many languages and features (e.g., phone numbers, URLs) are missing.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'from recognizers_text import recognize_number, recognize_datetime, ...'.","message":"All recognizer functions are in the same 'recognizers_text' top-level module. Do not import from sub-packages like 'recognizers_number' or 'recognizers_datetime' — they are not directly importable.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always use Culture attributes. Example: Culture.English.","message":"Culture is a class, not an enum or string. You must use Culture.English, Culture.Spanish, etc. Passing a string like 'en-us' will raise an AttributeError.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install with extra: pip install recognizers-text[datatypes-timex-expression]","message":"The 'recognizers_text' package does not include the optional 'datatypes-timex-expression' dependency by default. Without it, accessing 'result.resolution' as a Timex object will fail.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"if not results: # handle no match","message":"Recognition results may return empty lists for unrecognized text; they do not raise exceptions. Always check the result length.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'import recognizers_text' (all lowercase, underscore).","message":"The 'recognizers_text' package name is slightly different from the GitHub repo name 'Recognizers-Text' (capitalized with hyphen). Import uses underscores.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from recognizers_text import recognize_number' instead.","cause":"Attempting to import from sub-packages that do not exist as standalone modules.","error":"ModuleNotFoundError: No module named 'recognizers_number'"},{"fix":"Use Culture.English or Culture.EnglishUs (if available). Check Culture.__dict__ for valid options.","cause":"Passing a string like 'en-us' instead of the Culture class attribute.","error":"AttributeError: type object 'Culture' has no attribute 'en-us'"},{"fix":"Check that result.resolution is a dict and contains 'values' key. Use result.resolution.get('values', []) or handle empty cases.","cause":"Accessing result.resolution['values'] when resolution is None or not a dict (e.g., when no match or different type).","error":"KeyError: 'values'"},{"fix":"Upgrade to the latest version: pip install --upgrade recognizers-text","cause":"Older versions of the package may not have the function or the package is installed incorrectly.","error":"ImportError: cannot import name 'recognize_datetime' from 'recognizers_text'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}