mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-27 07:25:16 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2e06c13de | ||
|
|
82b6dd5fc0 |
No files matched your search
@@ -23,7 +23,6 @@ dependencies = [
|
|||||||
"channels~=4.2",
|
"channels~=4.2",
|
||||||
"channels-redis~=4.2",
|
"channels-redis~=4.2",
|
||||||
"concurrent-log-handler~=0.9.25",
|
"concurrent-log-handler~=0.9.25",
|
||||||
"cryptography>=50",
|
|
||||||
"dateparser~=1.4",
|
"dateparser~=1.4",
|
||||||
# WARNING: django does not use semver.
|
# WARNING: django does not use semver.
|
||||||
# Only patch versions are guaranteed to not introduce breaking changes.
|
# Only patch versions are guaranteed to not introduce breaking changes.
|
||||||
@@ -47,7 +46,6 @@ dependencies = [
|
|||||||
"flower>=2.0.1,<2.3",
|
"flower>=2.0.1,<2.3",
|
||||||
"gotenberg-client[httpx]~=1.0",
|
"gotenberg-client[httpx]~=1.0",
|
||||||
"httpx-oauth~=0.17",
|
"httpx-oauth~=0.17",
|
||||||
"humanize>=4.15",
|
|
||||||
"ijson>=3.5.1",
|
"ijson>=3.5.1",
|
||||||
"imap-tools>=1.14,<1.16",
|
"imap-tools>=1.14,<1.16",
|
||||||
"jinja2~=3.1.6",
|
"jinja2~=3.1.6",
|
||||||
@@ -58,13 +56,10 @@ dependencies = [
|
|||||||
"llama-index-embeddings-openai-like>=0.2.2",
|
"llama-index-embeddings-openai-like>=0.2.2",
|
||||||
"llama-index-llms-ollama>=0.9.1",
|
"llama-index-llms-ollama>=0.9.1",
|
||||||
"llama-index-llms-openai-like>=0.7.1",
|
"llama-index-llms-openai-like>=0.7.1",
|
||||||
"lxml>=6.1",
|
|
||||||
"ocrmypdf[heic]>=17.12,<17.13",
|
"ocrmypdf[heic]>=17.12,<17.13",
|
||||||
"ollama>=0.6.1",
|
|
||||||
"openai>=2.48",
|
"openai>=2.48",
|
||||||
"pathvalidate~=3.3.1",
|
"pathvalidate~=3.3.1",
|
||||||
"pdf2image~=1.17.0",
|
"pdf2image~=1.17.0",
|
||||||
"pikepdf>=10.13",
|
|
||||||
"python-dateutil~=2.9.0",
|
"python-dateutil~=2.9.0",
|
||||||
"python-dotenv~=1.2.1",
|
"python-dotenv~=1.2.1",
|
||||||
"python-gnupg~=0.5.4",
|
"python-gnupg~=0.5.4",
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ from paperless.utils import ocr_to_dateparser_languages
|
|||||||
pytest.param("eng", ["en"], id="single-language"),
|
pytest.param("eng", ["en"], id="single-language"),
|
||||||
pytest.param("fra+ita+lao", ["fr", "it", "lo"], id="multiple-languages"),
|
pytest.param("fra+ita+lao", ["fr", "it", "lo"], id="multiple-languages"),
|
||||||
pytest.param("fil", ["fil"], id="no-two-letter-equivalent"),
|
pytest.param("fil", ["fil"], id="no-two-letter-equivalent"),
|
||||||
|
pytest.param(
|
||||||
|
"afr+vie+kan+chr+mkd", # codespell:ignore
|
||||||
|
["af", "vi", "kn", "chr", "mk"],
|
||||||
|
id="previously-unmapped-languages",
|
||||||
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
"aze_cyrl+srp_latn",
|
"aze_cyrl+srp_latn",
|
||||||
["az-Cyrl", "sr-Latn"],
|
["az-Cyrl", "sr-Latn"],
|
||||||
@@ -49,6 +54,19 @@ def test_ocr_to_dateparser_languages(ocr_language: str, expected: list[str]) ->
|
|||||||
assert sorted(ocr_to_dateparser_languages(ocr_language)) == sorted(expected)
|
assert sorted(ocr_to_dateparser_languages(ocr_language)) == sorted(expected)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ocr_to_dateparser_map_values_supported_by_dateparser() -> None:
|
||||||
|
from dateparser.languages.loader import LocaleDataLoader
|
||||||
|
|
||||||
|
loader = LocaleDataLoader()
|
||||||
|
unsupported = []
|
||||||
|
for ocr_code, dateparser_code in utils.OCR_TO_DATEPARSER_LANGUAGES.items():
|
||||||
|
try:
|
||||||
|
loader.get_locale_map(locales=[dateparser_code])
|
||||||
|
except Exception:
|
||||||
|
unsupported.append((ocr_code, dateparser_code))
|
||||||
|
assert unsupported == []
|
||||||
|
|
||||||
|
|
||||||
def test_ocr_to_dateparser_languages_exception(
|
def test_ocr_to_dateparser_languages_exception(
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
|||||||
+16
-16
@@ -2,19 +2,18 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger("paperless.utils")
|
logger = logging.getLogger("paperless.utils")
|
||||||
|
|
||||||
|
# Translation map from languages supported by Tesseract OCR
|
||||||
|
# to languages supported by dateparser.
|
||||||
|
# To add a language, make sure it is supported by both libraries.
|
||||||
|
# The ISO 639-2 will help you link a 3-char to 2-char language code.
|
||||||
|
# Links:
|
||||||
|
# - Tesseract languages: https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html
|
||||||
|
# - Python dateparser languages: https://dateparser.readthedocs.io/en/latest/supported_locales.html
|
||||||
|
# - ISO 639-2: https://www.loc.gov/standards/iso639-2/php/code_list.php
|
||||||
OCR_TO_DATEPARSER_LANGUAGES = {
|
OCR_TO_DATEPARSER_LANGUAGES = {
|
||||||
"""
|
# These dateparser languages have no equivalent in any Tesseract release
|
||||||
Translation map from languages supported by Tesseract OCR
|
# (checked against tessdata, tessdata_best and tessdata_fast), so they cannot
|
||||||
to languages supported by dateparser.
|
# be reached from the OCR language. Set PAPERLESS_DATE_PARSER_LANGUAGES to use them:
|
||||||
To add a language, make sure it is supported by both libraries.
|
|
||||||
The ISO 639-2 will help you link a 3-char to 2-char language code.
|
|
||||||
Links:
|
|
||||||
- Tesseract languages: https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html
|
|
||||||
- Python dateparser languages: https://dateparser.readthedocs.io/en/latest/supported_locales.html
|
|
||||||
- ISO 639-2: https://www.loc.gov/standards/iso639-2/php/code_list.php
|
|
||||||
"""
|
|
||||||
# TODO check these Dateparser languages as they are not referenced on the ISO639-2 standard,
|
|
||||||
# so we didn't find the equivalent in Tesseract:
|
|
||||||
# agq, asa, bez, brx, cgg, ckb, dav, dje, dyo, ebu, guz, jgo, jmc, kde, kea, khq, kln,
|
# agq, asa, bez, brx, cgg, ckb, dav, dje, dyo, ebu, guz, jgo, jmc, kde, kea, khq, kln,
|
||||||
# ksb, ksf, ksh, lag, lkt, lrc, luy, mer, mfe, mgh, mgo, mua, mzn, naq, nmg, nnh, nus,
|
# ksb, ksf, ksh, lag, lkt, lrc, luy, mer, mfe, mgh, mgo, mua, mzn, naq, nmg, nnh, nus,
|
||||||
# rof, rwk, saq, sbp, she, ses, shi, teo, twq, tzm, vun, wae, xog, yav, yue
|
# rof, rwk, saq, sbp, she, ses, shi, teo, twq, tzm, vun, wae, xog, yav, yue
|
||||||
@@ -22,7 +21,6 @@ OCR_TO_DATEPARSER_LANGUAGES = {
|
|||||||
"amh": "am",
|
"amh": "am",
|
||||||
"ara": "ar",
|
"ara": "ar",
|
||||||
"asm": "as",
|
"asm": "as",
|
||||||
"ast": "ast",
|
|
||||||
"aze": "az",
|
"aze": "az",
|
||||||
"bel": "be",
|
"bel": "be",
|
||||||
"bul": "bg",
|
"bul": "bg",
|
||||||
@@ -31,7 +29,7 @@ OCR_TO_DATEPARSER_LANGUAGES = {
|
|||||||
"bre": "br",
|
"bre": "br",
|
||||||
"bos": "bs",
|
"bos": "bs",
|
||||||
"cat": "ca",
|
"cat": "ca",
|
||||||
"cher": "chr",
|
"chr": "chr",
|
||||||
"ces": "cs",
|
"ces": "cs",
|
||||||
"cym": "cy",
|
"cym": "cy",
|
||||||
"dan": "da",
|
"dan": "da",
|
||||||
@@ -65,19 +63,21 @@ OCR_TO_DATEPARSER_LANGUAGES = {
|
|||||||
"kat": "ka",
|
"kat": "ka",
|
||||||
"kaz": "kk",
|
"kaz": "kk",
|
||||||
"khm": "km",
|
"khm": "km",
|
||||||
"knda": "kn",
|
"kan": "kn",
|
||||||
"kor": "ko",
|
"kor": "ko",
|
||||||
"kir": "ky",
|
"kir": "ky",
|
||||||
"ltz": "lb",
|
"ltz": "lb",
|
||||||
"lao": "lo",
|
"lao": "lo",
|
||||||
"lit": "lt",
|
"lit": "lt",
|
||||||
"lav": "lv",
|
"lav": "lv",
|
||||||
|
"mkd": "mk",
|
||||||
"mal": "ml",
|
"mal": "ml",
|
||||||
"mon": "mn",
|
"mon": "mn",
|
||||||
"mar": "mr",
|
"mar": "mr",
|
||||||
"msa": "ms",
|
"msa": "ms",
|
||||||
"mlt": "mt",
|
"mlt": "mt",
|
||||||
"mya": "my",
|
"mya": "my",
|
||||||
|
"nor": "nb",
|
||||||
"nep": "ne",
|
"nep": "ne",
|
||||||
"nld": "nl",
|
"nld": "nl",
|
||||||
"ori": "or",
|
"ori": "or",
|
||||||
@@ -106,7 +106,7 @@ OCR_TO_DATEPARSER_LANGUAGES = {
|
|||||||
"ukr": "uk",
|
"ukr": "uk",
|
||||||
"urd": "ur",
|
"urd": "ur",
|
||||||
"uzb": "uz",
|
"uzb": "uz",
|
||||||
"via": "vi",
|
"vie": "vi", # codespell:ignore
|
||||||
"yid": "yi",
|
"yid": "yi",
|
||||||
"yor": "yo",
|
"yor": "yo",
|
||||||
"chi": "zh",
|
"chi": "zh",
|
||||||
|
|||||||
@@ -2516,7 +2516,6 @@ dependencies = [
|
|||||||
{ name = "channels" },
|
{ name = "channels" },
|
||||||
{ name = "channels-redis" },
|
{ name = "channels-redis" },
|
||||||
{ name = "concurrent-log-handler" },
|
{ name = "concurrent-log-handler" },
|
||||||
{ name = "cryptography" },
|
|
||||||
{ name = "dateparser" },
|
{ name = "dateparser" },
|
||||||
{ name = "django" },
|
{ name = "django" },
|
||||||
{ name = "django-allauth", extra = ["mfa", "socialaccount"] },
|
{ name = "django-allauth", extra = ["mfa", "socialaccount"] },
|
||||||
@@ -2538,7 +2537,6 @@ dependencies = [
|
|||||||
{ name = "flower" },
|
{ name = "flower" },
|
||||||
{ name = "gotenberg-client", extra = ["httpx"] },
|
{ name = "gotenberg-client", extra = ["httpx"] },
|
||||||
{ name = "httpx-oauth" },
|
{ name = "httpx-oauth" },
|
||||||
{ name = "humanize" },
|
|
||||||
{ name = "ijson" },
|
{ name = "ijson" },
|
||||||
{ name = "imap-tools" },
|
{ name = "imap-tools" },
|
||||||
{ name = "jinja2" },
|
{ name = "jinja2" },
|
||||||
@@ -2549,13 +2547,10 @@ dependencies = [
|
|||||||
{ name = "llama-index-embeddings-openai-like" },
|
{ name = "llama-index-embeddings-openai-like" },
|
||||||
{ name = "llama-index-llms-ollama" },
|
{ name = "llama-index-llms-ollama" },
|
||||||
{ name = "llama-index-llms-openai-like" },
|
{ name = "llama-index-llms-openai-like" },
|
||||||
{ name = "lxml" },
|
|
||||||
{ name = "ocrmypdf", extra = ["heic"] },
|
{ name = "ocrmypdf", extra = ["heic"] },
|
||||||
{ name = "ollama" },
|
|
||||||
{ name = "openai" },
|
{ name = "openai" },
|
||||||
{ name = "pathvalidate" },
|
{ name = "pathvalidate" },
|
||||||
{ name = "pdf2image" },
|
{ name = "pdf2image" },
|
||||||
{ name = "pikepdf" },
|
|
||||||
{ name = "python-dateutil" },
|
{ name = "python-dateutil" },
|
||||||
{ name = "python-dotenv" },
|
{ name = "python-dotenv" },
|
||||||
{ name = "python-gnupg" },
|
{ name = "python-gnupg" },
|
||||||
@@ -2673,7 +2668,6 @@ requires-dist = [
|
|||||||
{ name = "channels", specifier = "~=4.2" },
|
{ name = "channels", specifier = "~=4.2" },
|
||||||
{ name = "channels-redis", specifier = "~=4.2" },
|
{ name = "channels-redis", specifier = "~=4.2" },
|
||||||
{ name = "concurrent-log-handler", specifier = "~=0.9.25" },
|
{ name = "concurrent-log-handler", specifier = "~=0.9.25" },
|
||||||
{ name = "cryptography", specifier = ">=50.0.0" },
|
|
||||||
{ name = "dateparser", specifier = "~=1.4" },
|
{ name = "dateparser", specifier = "~=1.4" },
|
||||||
{ name = "django", specifier = "~=5.2.18" },
|
{ name = "django", specifier = "~=5.2.18" },
|
||||||
{ name = "django-allauth", extras = ["mfa", "socialaccount"], specifier = "~=65.21.1" },
|
{ name = "django-allauth", extras = ["mfa", "socialaccount"], specifier = "~=65.21.1" },
|
||||||
@@ -2696,7 +2690,6 @@ requires-dist = [
|
|||||||
{ name = "gotenberg-client", extras = ["httpx"], specifier = "~=1.0" },
|
{ name = "gotenberg-client", extras = ["httpx"], specifier = "~=1.0" },
|
||||||
{ name = "granian", extras = ["uvloop"], marker = "extra == 'webserver'", specifier = ">=2.7,<2.9" },
|
{ name = "granian", extras = ["uvloop"], marker = "extra == 'webserver'", specifier = ">=2.7,<2.9" },
|
||||||
{ name = "httpx-oauth", specifier = "~=0.17" },
|
{ name = "httpx-oauth", specifier = "~=0.17" },
|
||||||
{ name = "humanize", specifier = ">=4.15.0" },
|
|
||||||
{ name = "ijson", specifier = ">=3.5.1" },
|
{ name = "ijson", specifier = ">=3.5.1" },
|
||||||
{ name = "imap-tools", specifier = ">=1.14,<1.16" },
|
{ name = "imap-tools", specifier = ">=1.14,<1.16" },
|
||||||
{ name = "jinja2", specifier = "~=3.1.6" },
|
{ name = "jinja2", specifier = "~=3.1.6" },
|
||||||
@@ -2707,14 +2700,11 @@ requires-dist = [
|
|||||||
{ name = "llama-index-embeddings-openai-like", specifier = ">=0.2.2" },
|
{ name = "llama-index-embeddings-openai-like", specifier = ">=0.2.2" },
|
||||||
{ name = "llama-index-llms-ollama", specifier = ">=0.9.1" },
|
{ name = "llama-index-llms-ollama", specifier = ">=0.9.1" },
|
||||||
{ name = "llama-index-llms-openai-like", specifier = ">=0.7.1" },
|
{ name = "llama-index-llms-openai-like", specifier = ">=0.7.1" },
|
||||||
{ name = "lxml", specifier = ">=6.1.0" },
|
|
||||||
{ name = "mysqlclient", marker = "extra == 'mariadb'", specifier = ">=2.2.7,<2.4" },
|
{ name = "mysqlclient", marker = "extra == 'mariadb'", specifier = ">=2.2.7,<2.4" },
|
||||||
{ name = "ocrmypdf", extras = ["heic"], specifier = ">=17.12,<17.13" },
|
{ name = "ocrmypdf", extras = ["heic"], specifier = ">=17.12,<17.13" },
|
||||||
{ name = "ollama", specifier = ">=0.6.1" },
|
|
||||||
{ name = "openai", specifier = ">=2.48" },
|
{ name = "openai", specifier = ">=2.48" },
|
||||||
{ name = "pathvalidate", specifier = "~=3.3.1" },
|
{ name = "pathvalidate", specifier = "~=3.3.1" },
|
||||||
{ name = "pdf2image", specifier = "~=1.17.0" },
|
{ name = "pdf2image", specifier = "~=1.17.0" },
|
||||||
{ name = "pikepdf", specifier = ">=10.13" },
|
|
||||||
{ name = "psycopg", extras = ["c", "pool"], marker = "extra == 'postgres'", specifier = "==3.3.8" },
|
{ name = "psycopg", extras = ["c", "pool"], marker = "extra == 'postgres'", specifier = "==3.3.8" },
|
||||||
{ name = "psycopg-c", marker = "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp312-cp312-manylinux_2_38_aarch64.whl" },
|
{ name = "psycopg-c", marker = "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp312-cp312-manylinux_2_38_aarch64.whl" },
|
||||||
{ name = "psycopg-c", marker = "python_full_version == '3.14.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp314-cp314-manylinux_2_38_aarch64.whl" },
|
{ name = "psycopg-c", marker = "python_full_version == '3.14.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp314-cp314-manylinux_2_38_aarch64.whl" },
|
||||||
|
|||||||
Reference in new issue
Block a user