Skip to content

Commit 79f4cb5

Browse files
dronperminovNastyBogetsunveiloksidgyalexander1999-hub
authored
update master (#328)
* TLDR-446 annotations doc (#322) * Annotations information added * Line types information added * add tesseract info to instalation docs (#325) * Remove plexus-utils-1.1.jar (#326) * TLDR-455 change README and fixed 3.1, 3.3.4, 3.3.3 notes of FOND (#323) * TLDR-455 change README and fixed 3.1, 3.3.4, 3.3.3 notes of FOND * TLDR-455 update installation instructions * TLDR-455 update README according online-instruction * TLDR-455 added info about trusted torch * fix indentation in code --------- Co-authored-by: dronperminov <[email protected]> * fixed examples directory (#324) * fixed examples directory * update readme * update installation.rst * update README --------- Co-authored-by: Alexander Golodkov <[email protected]> Co-authored-by: Belyaeva Oksana <[email protected]> * new version 0.11.2 (#327) * Update README.md --------- Co-authored-by: Bogatenkova Anastasiya <[email protected]> Co-authored-by: Andrey Mikhailov <[email protected]> Co-authored-by: Oksana Belyaeva <[email protected]> Co-authored-by: Alexander Golodkov <[email protected]> Co-authored-by: Alexander Golodkov <[email protected]>
1 parent 79fb6e3 commit 79f4cb5

21 files changed

+716
-88
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Push to dockerhub
4242
if: ${{ success() }}
4343
run: |
44-
docker build -f docker/Dockerfile -t dedocproject/dedoc:$GITHUB_REF_NAME .
44+
docker build -f Dockerfile -t dedocproject/dedoc:$GITHUB_REF_NAME .
4545
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
4646
docker tag dedocproject/dedoc:$GITHUB_REF_NAME dedocproject/dedoc:latest
4747
docker push dedocproject/dedoc:$GITHUB_REF_NAME

README.md

Lines changed: 175 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
![Dedoc](https://github.com/ispras/dedoc/raw/master/dedoc_logo.png)
66

7-
Dedoc is an open universal system for converting documents to a unified output format. It extracts a document’s logical structure and content, its tables, text formatting and metadata. The document’s content is represented as a tree storing headings and lists of any level. Dedoc can be integrated in a document contents and structure analysis system as a separate module.
7+
Dedoc is an open universal system for converting documents to a unified output format.
8+
It extracts a document’s logical structure and content, its tables, text formatting and metadata.
9+
The document’s content is represented as a tree storing headings and lists of any level.
10+
Dedoc can be integrated in a document contents and structure analysis system as a separate module.
811

912
## Features and advantages
10-
Dedoc is implemented in Python and works with semi-structured data formats (DOC/DOCX, ODT, XLS/XLSX, CSV, TXT, JSON) and none-structured data formats like images (PNG, JPG etc.), archives (ZIP, RAR etc.), PDF and HTML formats. Document structure extraction is fully automatic regardless of input data type. Metadata and text formatting is also extracted automatically.
13+
Dedoc is implemented in Python and works with semi-structured data formats (DOC/DOCX, ODT, XLS/XLSX, CSV, TXT, JSON) and none-structured data formats like images (PNG, JPG etc.), archives (ZIP, RAR etc.), PDF and HTML formats.
14+
Document structure extraction is fully automatic regardless of input data type.
15+
Metadata and text formatting are also extracted automatically.
1116

1217
In 2022, the system won a grant to support the development of promising AI projects from the [Innovation Assistance Foundation (Фонд содействия инновациям)](https://fasie.ru/).
1318

@@ -16,45 +21,189 @@ In 2022, the system won a grant to support the development of promising AI proje
1621
* Support for extracting document structure out of nested documents having different formats.
1722
* Extracting various text formatting features (indentation, font type, size, style etc.).
1823
* Working with documents of various origin (statements of work, legal documents, technical reports, scientific papers) allowing flexible tuning for new domains.
19-
* Working with PDF documents containinng a text layer:
20-
* Support to automatically determine the correctness of the text layer in PDF documents;
21-
* Extract containing and formatting from PDF-documents with a text layer using the developed interpreter of the virtual stack machine for printing graphics according to the format specification.
22-
Extracting table data from DOC/DOCX, PDF, HTML, CSV and image formats:
24+
* Working with PDF documents containing a textual layer:
25+
* Support to automatically determine the correctness of the textual layer in PDF documents;
26+
* Extract containing and formatting from PDF-documents with a textual layer using the developed interpreter of the virtual stack machine for printing graphics according to the format specification.
27+
* Extracting table data from DOC/DOCX, PDF, HTML, CSV and image formats:
2328
* Recognizing a physical structure and a cell text for complex multipage tables having explicit borders with the help of contour analysis.
2429
* Working with scanned documents (image formats and PDF without text layer):
2530
* Using Tesseract, an actively developed OCR engine from Google, together with image preprocessing methods.
2631
* Utilizing modern machine learning approaches for detecting a document orientation, detecting single/multicolumn document page, detecting bold text and extracting hierarchical structure based on the classification of features extracted from document images.
2732

33+
## Impact
34+
This project may be useful as a first step of automatic document analysis pipeline (e.g. before the NLP part).
35+
Dedoc is in demand for information analytic systems, information leak monitoring systems, as well as for natural language processing systems.
36+
The library is intended for application use by developers of systems for automatic analysis and structuring of electronic documents, including for further search in electronic documents.
2837

29-
This project may be useful as a first step of automatic document analysis pipeline (e.g. before the NLP part)
38+
# Online-Documentation
39+
Relevant documentation of the dedoc is available [here](https://dedoc.readthedocs.io/en/latest/)
3040

31-
This project has REST Api and you can run it in Docker container
32-
To read full Dedoc documentation run the project and go to localhost:1231.
33-
41+
# Installation instructions
42+
****************************************
43+
This project has REST Api and you can run it in Docker container.
44+
Also, dedoc can be installed as a library via `pip`.
45+
There are two ways to install and run dedoc as a web application or a library that are described below.
3446

35-
## Run the project
36-
How to build and run the project
3747

38-
Ensure you have Git and Docker installed
39-
40-
Clone the project
48+
## Install and run dedoc using docker
49+
50+
You should have [`git`] (https://git-scm.com) and [`docker`](https://www.docker.com) installed for running dedoc by this method.
51+
This method is more flexible because it doesn't depend on the operating system and other user's limitations,
52+
still, the docker application should be installed and configured properly.
53+
54+
If you don't need to change the application configuration, you may use the built docker image as well.
55+
56+
### 1. Pull the image
4157
```bash
42-
git clone https://github.com/ispras/dedoc.git
58+
docker pull dedocproject/dedoc
59+
```
4360

44-
cd dedoc/
61+
### 2. Run the container
62+
```bash
63+
docker run -p 1231:1231 --rm dedocproject/dedoc python3 /dedoc_root/dedoc/main.py
4564
```
46-
47-
Ensure you have Docker installed.
48-
Start 'Dedoc' on the port 1231:
49-
```bash
65+
66+
Go to [dockerhub](https://hub.docker.com/r/dedocproject/dedoc) to get more information about available dedoc images.
67+
68+
If you need to change some application settings, you may update `config.py` according to your needs and re-build the image.
69+
You can build and run image:
70+
71+
### 1. Clone the repository
72+
```bash
73+
git clone https://github.com/ispras/dedoc
74+
```
75+
76+
### 2. Go to the `dedoc` directory
77+
```bash
78+
cd dedoc
79+
```
80+
81+
### 3. Build the image and run the application
82+
```bash
5083
docker-compose up --build
5184
```
5285

53-
Start Dedoc with tests:
54-
```bash
86+
### 4. Run container with tests
87+
```bash
5588
test="true" docker-compose up --build
56-
```
89+
```
90+
91+
If you need to change some application settings, you may update `config.py` according to your needs and re-build the image.
92+
93+
94+
## Install dedoc using pip
95+
96+
If you don't want to use docker for running the application, it's possible to run dedoc locally.
97+
However, it isn't suitable for any operating system (`Ubuntu 20+` is recommended) and
98+
there may be not enough machine's resources for its work.
99+
You should have `python` (`python3.8`, `python3.9` are recommended) and `pip` installed.
100+
101+
### 1. Install necessary packages:
102+
```bash
103+
sudo apt-get install -y libreoffice djvulibre-bin unzip unrar
104+
```
105+
106+
`libreoffice` and `djvulibre-bin` packages are used by converters (doc, odt to docx; xls, ods to xlsx; ppt, odp to pptx; djvu to pdf).
107+
If you don't need converters, you can skip this step.
108+
`unzip` and `unrar` packages are used in the process of extracting archives.
109+
110+
### 2. Install `Tesseract OCR 5` framework:
111+
You can try any tutorial for this purpose or look [`here`](https://github.com/ispras/dedockerfiles/blob/master/dedoc_p3.9_base.Dockerfile)
112+
to get the example of Tesseract installing for dedoc container or use next commands for building Tesseract OCR 5 from sources:
113+
114+
#### 2.1. Install compilers and libraries required by the Tesseract OCR:
115+
```bash
116+
sudo apt-get update
117+
sudo apt-get install -y automake binutils-dev build-essential ca-certificates clang g++ g++-multilib gcc-multilib libcairo2 libffi-dev \
118+
libgdk-pixbuf2.0-0 libglib2.0-dev libjpeg-dev libleptonica-dev libpango-1.0-0 libpango1.0-dev libpangocairo-1.0-0 libpng-dev libsm6 \
119+
libtesseract-dev libtool libxext6 make pkg-config poppler-utils pstotext shared-mime-info software-properties-common swig zlib1g-dev
120+
```
121+
#### 2.2. Build Tesseract from sources:
122+
```bash
123+
sudo add-apt-repository -y ppa:alex-p/tesseract-ocr-devel
124+
sudo apt-get update --allow-releaseinfo-change
125+
sudo apt-get install -y tesseract-ocr tesseract-ocr-rus
126+
git clone --depth 1 --branch 5.0.0-beta-20210916 https://github.com/tesseract-ocr/tesseract/
127+
cd tesseract && ./autogen.sh && sudo ./configure && sudo make && sudo make install && sudo ldconfig && cd ..
128+
export TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata/
129+
```
130+
131+
## Install the dedoc library via pip.
132+
133+
You need torch~=1.11.0 and torchvision~=0.12.0 installed. If you already have torch and torchvision in your environment:
134+
135+
```bash
136+
pip install dedoc
137+
```
138+
139+
Or you can install dedoc with torch and torchvision included:
140+
141+
```bash
142+
pip install "dedoc[torch]"
143+
```
144+
145+
## Install and run dedoc from sources
146+
147+
If you want to run dedoc as a service from sources. it's possible to run dedoc locally.
148+
However, it isn't suitable for any operating system (Ubuntu 20+ is recommended) and
149+
there may be not enough machine's resources for its work.
150+
You should have `python` (python3.8, python3.9 are recommended) and `pip` installed.
151+
152+
### 1. Install necessary packages: according to instructions [install necessary packages](#1-Install-necessary-packages)
153+
154+
### 2. Build Tesseract from sources according to instructions [Install Tesseract OCR-5 framework](#2-Install-Tesseract-OCR-5-framework)
155+
156+
### 3. We recommend to install python's virtual environment (for example, via `virtualenvwrapper`)
157+
158+
Below are the instructions for installing the package `virtualenvwrapper`:
159+
160+
```bash
161+
sudo pip3 install virtualenv virtualenvwrapper
162+
mkdir ~/.virtualenvs
163+
export WORKON_HOME=~/.virtualenvs
164+
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.8" >> ~/.bashrc
165+
echo ". /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
166+
source ~/.bashrc
167+
mkvirtualenv dedoc_env
168+
```
169+
170+
### 4. Install python's requirements and launch dedoc service on default port `1231`:
171+
172+
```bash
173+
# clone dedoc project
174+
git clone https://github.com/ispras/dedoc.git
175+
cd dedoc
176+
# check on your's python environment
177+
workon dedoc_env
178+
export PYTHONPATH=$PYTHONPATH:$(pwd)
179+
pip install -r requirements.txt
180+
pip install torch=1.11.0 torchvision==0.12.0 -f https://download.pytorch.org/whl/torch_stable.html
181+
python dedoc/main.py -c ./dedoc/config.py
182+
```
183+
Now you can go to the `localhost:1231` and look at the docs and examples.
184+
185+
## Option: You can change the port of service:
186+
you need to change environment DOCREADER_PORT
187+
188+
1. For local service launching on your_port (1166 example). [Install instruction from sources](#Install-and-run-dedoc-from-sources) and launch with environment:
189+
```bash
190+
DOCREADER_PORT=1166 python dedoc/main.py -c ./dedoc/config.py
191+
```
57192

58-
Now you can go to the localhost:1231 and look at the docs and examples.
193+
2. For service launching in docker-container you need to change port value in DOCREADER_PORT env and field 'ports' in docker-compose.yml file:
194+
```yaml
195+
...
196+
dedoc:
197+
...
198+
ports:
199+
- your_port_number:your_port_number
200+
environment:
201+
DOCREADER_PORT: your_port_number
202+
...
203+
test:
204+
...
205+
environment:
206+
DOCREADER_PORT: your_port_number
207+
```
59208
60-
You can change the port and host in the config file 'dedoc/config.py'
209+
Go [here](https://dedoc.readthedocs.io/en/latest/getting_started/installation.html) to get more details about dedoc installation.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.11.1
1+
0.11.2
Binary file not shown.

docs/source/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
=========
33

4+
v0.11.2 (2023-09-06)
5+
--------------------
6+
Release note: `v0.11.2 <https://github.com/ispras/dedoc/releases/tag/v0.11.2>`_
7+
8+
* Remove plexus-utils-1.1.jar.
9+
* Update installation documentation.
10+
* Add documentation for Tesseract OCR installation.
11+
* Add documentation for annotations.
12+
* Add documentation for secure torch.
13+
* Fix examples.
14+
415
v0.11.1 (2023-08-30)
516
--------------------
617
Release note: `v0.11.1 <https://github.com/ispras/dedoc/releases/tag/v0.11.1>`_

docs/source/getting_started/installation.rst

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,54 @@ Install dedoc using pip
5959
If you don't want to use docker for running the application, it's possible to run dedoc locally.
6060
However, it isn't suitable for any operating system (Ubuntu 20+ is recommended) and
6161
there may be not enough machine's resources for its work.
62-
You should have `python` (python3.8+ is recommended) and `pip` installed.
62+
You should have `python` (python3.8, python3.9 are recommended) and `pip` installed.
6363

64+
.. _install_packages:
6465

65-
1. Install `libreoffice` and `djvulibre-bin` packages:
66+
1. Install necessary packages:
67+
******************************
6668

6769
.. code-block:: bash
6870
69-
sudo apt-get install -y libreoffice djvulibre-bin
71+
sudo apt-get install -y libreoffice djvulibre-bin unzip unrar
7072
71-
These packages are used by converters (doc, odt to docx; xls, ods to xlsx; ppt, odp to pptx; djvu to pdf).
73+
`libreoffice` and `djvulibre-bin` packages are used by converters (doc, odt to docx; xls, ods to xlsx; ppt, odp to pptx; djvu to pdf).
7274
If you don't need converters, you can skip this step.
75+
`unzip` and `unrar` packages are used in the process of extracting archives.
7376

77+
.. _install_tesseract:
7478

7579
2. Install `Tesseract OCR 5` framework.
80+
***************************************
7681
You can try any tutorial for this purpose or look `here <https://github.com/ispras/dedockerfiles/blob/master/dedoc_p3.9_base.Dockerfile>`_
77-
to get the example of Tesseract installing for dedoc container.
82+
to get the example of Tesseract installing for dedoc container or use next commands for building Tesseract OCR 5 from sources:
7883

84+
2.1. Install compilers and libraries required by the Tesseract OCR:
85+
86+
.. code-block:: bash
87+
88+
sudo apt-get update
89+
sudo apt-get install -y automake binutils-dev build-essential ca-certificates clang g++ g++-multilib gcc-multilib libcairo2 libffi-dev \
90+
libgdk-pixbuf2.0-0 libglib2.0-dev libjpeg-dev libleptonica-dev libpango-1.0-0 libpango1.0-dev libpangocairo-1.0-0 libpng-dev libsm6 \
91+
libtesseract-dev libtool libxext6 make pkg-config poppler-utils pstotext shared-mime-info software-properties-common swig zlib1g-dev
92+
93+
2.2. Build Tesseract from sources:
94+
95+
.. code-block:: bash
96+
97+
sudo add-apt-repository -y ppa:alex-p/tesseract-ocr-devel
98+
sudo apt-get update --allow-releaseinfo-change
99+
sudo apt-get install -y tesseract-ocr tesseract-ocr-rus
100+
git clone --depth 1 --branch 5.0.0-beta-20210916 https://github.com/tesseract-ocr/tesseract/
101+
cd tesseract && ./autogen.sh && sudo ./configure && sudo make && sudo make install && sudo ldconfig && cd ..
102+
export TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata/
103+
104+
.. _install_library_via_pip:
79105

80106
3. Install the dedoc library via pip.
81-
To fulfil all the library requirements, you should have `torch~=1.11.0` and `torchvision~=0.12.0` installed.
82-
You can install suitable for you versions of these libraries and install dedoc using pip command:
107+
*************************************
108+
You need `torch~=1.11.0` and `torchvision~=0.12.0` installed.
109+
If you already have torch and torchvision in your environment:
83110

84111
.. code-block:: bash
85112
@@ -90,3 +117,69 @@ Or you can install dedoc with torch and torchvision included:
90117
.. code-block:: bash
91118
92119
pip install "dedoc[torch]"
120+
121+
Install and run dedoc from sources
122+
----------------------------------
123+
124+
If you want to run dedoc as a service from sources. it's possible to run dedoc locally.
125+
However, it isn't suitable for any operating system (Ubuntu 20+ is recommended) and
126+
there may be not enough machine's resources for its work.
127+
You should have `python` (python3.8, python3.9 are recommended) and `pip` installed.
128+
129+
1. Install necessary packages: according to instructions :ref:`install_packages`
130+
131+
2. Build Tesseract from sources according to instructions :ref:`install_tesseract`
132+
133+
3. We recommend to install python's virtual environment (for example, via `virtualenvwrapper`)
134+
135+
Below are the instructions for installing the package `virtualenvwrapper`:
136+
137+
.. code-block:: bash
138+
139+
sudo pip3 install virtualenv virtualenvwrapper
140+
mkdir ~/.virtualenvs
141+
export WORKON_HOME=~/.virtualenvs
142+
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.8" >> ~/.bashrc
143+
echo ". /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
144+
source ~/.bashrc
145+
mkvirtualenv dedoc_env
146+
147+
4. Install python's requirements and launch dedoc service on default port `1231`:
148+
149+
.. code-block:: bash
150+
151+
# clone dedoc project
152+
git clone https://github.com/ispras/dedoc.git
153+
cd dedoc
154+
# check on your's python environment
155+
workon dedoc_env
156+
export PYTHONPATH=$PYTHONPATH:$(pwd)
157+
pip install -r requirements.txt
158+
pip install torch==1.11.0 torchvision==0.12.0 -f https://download.pytorch.org/whl/torch_stable.html
159+
python dedoc/main.py -c ./dedoc/config.py
160+
161+
162+
Install trusted torch (verified version)
163+
----------------------------------------------
164+
165+
You can install a trusted library `torch` (as a verified version of the library, verified by tools developed by the Ivannikov Institute for System Programming of the Russian Academy of Sciences).
166+
167+
First you need to install two required packages.:
168+
169+
.. code-block:: bash
170+
171+
sudo apt-get install -y mpich intel-mkl
172+
173+
Second you need to install torch and torchvision from built wheels:
174+
175+
For `python3.8`:
176+
.. code-block:: bash
177+
178+
pip install https://github.com/ispras/dedockerfiles/raw/master/wheels/torch-1.11.0a0+git137096a-cp38-cp38-linux_x86_64.whl
179+
pip install https://github.com/ispras/dedockerfiles/raw/master/wheels/torchvision-0.12.0a0%2B9b5a3fe-cp38-cp38-linux_x86_64.whl
180+
181+
For `python3.9`:
182+
.. code-block:: bash
183+
184+
pip install https://github.com/ispras/dedockerfiles/raw/master/wheels/torch-1.11.0a0+git137096a-cp39-cp39-linux_x86_64.whl
185+
pip install https://github.com/ispras/dedockerfiles/raw/master/wheels/torchvision-0.12.0a0%2B9b5a3fe-cp39-cp39-linux_x86_64.whl

0 commit comments

Comments
 (0)