Skip to content

TALIE-1651 new interfaces - #564

Open
NastyBoget wants to merge 4 commits into
developfrom
TALIE-1651_new_interfaces
Open

TALIE-1651 new interfaces#564
NastyBoget wants to merge 4 commits into
developfrom
TALIE-1651_new_interfaces

Conversation

@NastyBoget

@NastyBoget NastyBoget commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

В рамках ПР:

  • TALIE-1651 - добавлен интерфейс для абстрактного обработчика и основные структуры данных (но не все). В будущем планируется добавить структуры данных для аннотаций (жирность шрифта, размер и т.д.) и для хранения логических типов узлов (например, "глава", "статья" и т.п. для законов - вероятно, типизацию нужно будет делать настраиваемой в зависимости от типа структуры).
  • TALIE-1637 - написаны модули предобработки PDF (Binarizer, OrientationClassification, SkewCorrection), вспомогательные модули для начала обработки (MetadataExtractor, PagesCreator, PopplerRender) и ContentMimeDetector, обработчик DocxProcessor реализован не до конца (оставила для примера)

@NastyBoget NastyBoget self-assigned this Aug 10, 2026
@NastyBoget
NastyBoget force-pushed the TALIE-1651_new_interfaces branch from 6fbce81 to 14be5b0 Compare August 10, 2026 13:29
@NastyBoget
NastyBoget force-pushed the TALIE-1651_new_interfaces branch from 14be5b0 to 01c0a9a Compare August 10, 2026 13:41
Comment thread requirements.txt
charset-normalizer>=2.0.12,<=3.2.0
Cython>=0.29.28,<=3.0.2
dedoc-utils==0.3.8
dedoc-utils==0.3.9

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в этой версии в dedocutils был перенесен OrientationClassifier

@NastyBoget NastyBoget Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сам парсер еще не переносила (он довольно большой), этот класс служит примером того, как будут устроены интерфейсы несложных парсеров

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот код - попытка переделать получше dedoc/download_models.py - предварительное скачивание весов моделей для последующего оффлайн использования

from dedoc_future.datamodel.nodes.file import FileNode


def format_suits(node: FileNode, extensions: set[str], mimes: set[str]) -> bool:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эта функция - аналог dedoc.readers.base_reader.BaseReader.can_read

structure: dict[AbstractNode, Iterable[AbstractNode]]


class AbstractProcessor(Generic[_Node, _Config, _DeployConfig], metaclass=ABCMeta):

@NastyBoget NastyBoget Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: возможно, стоит еще подумать в сторону subprocessors для составных обработчиков, которые разбиваются на подзадачи с нестандартным входом/выходом для запуска этих подзадач на CPU/GPU (пример: OCR+постпроцессинг)

from dedoc_future.datamodel.nodes.page import PageNode, PageNodeWrapper


class PopplerRender(AbstractProcessor[PageNode, PdfBaseConfig, ImmutableBaseModel]):

@NastyBoget NastyBoget Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функционал dedoc.readers.pdf_reader.pdf_base_reader.PdfBaseReader._split_pdf2image (предполагается, что до этого в документ добавлены пустые page ноды с помощью PagesCreator)

впоследствии планируется добавить еще один способ рендеринга, предложенный Олегом

from dedoc_future.datamodel.nodes.file import FileNode


class ContentMimeDetector(AbstractProcessor[FileNode, ImmutableBaseModel, ImmutableBaseModel]):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функционал dedoc.utils.utils.get_file_mime_by_content - предполагается запускать этот обработчик тогда, когда основная обработка упала с ошибкой

from dedoc_future.datamodel.nodes.file import FileNode


class MetadataExtractor(AbstractProcessor[FileNode, ImmutableBaseModel, ImmutableBaseModel]):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функционал dedoc.metadata_extractors.concrete_metadata_extractors.base_metadata_extractor.BaseMetadataExtractor, предполагается использовать его в начале, чтобы впоследствии определять нужный парсер

@NastyBoget
NastyBoget requested a review from Tenebroso-M August 12, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant