Skip to main content

Extracting content from spesific address books

Project description

historical-text-extraction (hte)

PyPI version

Package to extract text from historical documents. The package is written for personal use.

Installation

The current release from the PyPI repository:

pip install hte

The development version from GitHub with:

pip install git+ssh://git@github.com/eirikberger/hte.git

Note that it is nessecary with a SSH key for this approach to work.

Using it

Import the package.

from hte import digitize

The basic setup is the following:

# Define class
book = digitize.Book("data/finnmark_1968.pdf", "books")

# Run methods on the class
book.CreateFolderStructure()
book.PdfImport(page_info=False, from_page=21, to_page=263)
book.Split(multiple_columns=True)
book.RunOCR(type="splits", export_image=False)
book.CombineCleanGroup(ocr_grouping=True, group_type='norway')
book.RegexStructure("norway")

Make sure to install the correct language package for Tesseract.

# Check languages already installed: 
tesseract --list-langs

# Languages available for installation
apt-cache search tesseract-ocr

# Install the Norwegian language pack
sudo apt-get install tesseract-ocr-nor

Extracting headers

Start by converting XML files using the Pascal VOC data format to JSON. These files can be created by using the free software labelImg.

import os 
import hte.headers as hteheaders
os.chdir('/home/eirikb/Desktop')
header = Headers('train', 2022)
header.runbbxConverting()

Then convert the json file to csv.

hteheaders.convertFromJson('/home/eirikb/Desktop/training_xml/json-bbox', 'xml')

Finally, read the concent of the boxes.

hteheaders.ReadBoxes('json-bbox/xml.csv', 'hordaland', 'train', print_images=True)

Downloade more content

These functions create a list of relevant content from the API of the Norwegian National Library and then downloads a high resolution pdf version.

import os
import hte.NB as NB
os.chdir('/home/eirikb/Desktop/')

ListOfBooks = NB.ListNB(1920, 1930, 'skatteligning', 'digitidsskrift')
ListOfBooks = NB.ListOfBooks[0:1]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hte-0.0.25.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

hte-0.0.25-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file hte-0.0.25.tar.gz.

File metadata

  • Download URL: hte-0.0.25.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for hte-0.0.25.tar.gz
Algorithm Hash digest
SHA256 2b33d6b9a692daf01b551f9e8609df30c1122950679f43b5a930ea05b70973f1
MD5 94ca66ac45c49eba9059c736bbebf311
BLAKE2b-256 665d58acb2eb83ab3d52d48c213fcb971a8b1eb06da7e045dcc38402d4d8379a

See more details on using hashes here.

File details

Details for the file hte-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: hte-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for hte-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 caa745d6ae220c15e9d69b379b0c7eeb650f3eb0c5dcfb89b24280cc0bb1b8e8
MD5 113d56e6fb2c5f2cbe5b286f96f39391
BLAKE2b-256 fdb316798e2834cf7bf319cad763d8cb9f998f16853e31b1a1a8d83e18c6c364

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page