Skip to main content

Toolkit for the Målfrid project

Project description

Maalfrid toolkit

maalfrid_toolkit is a Python package designed for crawling and extracting natural language data from documents found on the web (HTML, PDF, DOC). It is primarily used in the Målfrid project, a collaboration between the National Library of Norway and The Language Council of Norway, which aims to measure the usage of the two official Norwegian language forms, Bokmål and Nynorsk, on Norwegian public sector websites. While the toolkit has a particular emphasis on the Nordic countries, it supports extraction and language detection of more than 60 languages.

It builds upon:

Install

Install with pip

pip install maalfrid_toolkit

With Glotlid / fasttext (optional, see below for caveats):

pip install maalfrid_toolkit[glotlid]

Install with pdm

pdm install

Test run pipeline

On HTML

python -m maalfrid_toolkit.pipeline --url https://www.nb.no/utstilling/opplyst-glimt-fra-en-kulturhistorie/ --to_jsonl

On PDF

python -m maalfrid_toolkit.pipeline --url https://www.nb.no/sbfil/dok/nst_taledat_dk.pdf --to_jsonl

On DOC

python -m maalfrid_toolkit.pipeline --url https://www.nb.no/content/uploads/2018/11/Søknadsskjema-Bokhylla-2.doc --to_jsonl

On (W)ARC file (e.g. from self-crawled material)

python -m maalfrid_toolkit.pipeline --warc_file example_com-00000.warc.gz --calculate_simhash --to_jsonl > warc.jsonl

On sitemap

python -m maalfrid_toolkit.pipeline --url https://example.com/sitemap.xml --crawl_sitemap --to_jsonl > example.jsonl

Database (Postgres)

If you want to store and process the data further in a database, setup a Postgres database and enter your credentials in an .env file in the package root directory (see env-example). Be sure to populate the database with schema and indices found in db/ prior to running the commands in maalfrid_toolkit.db.

OS-level dependencies (tested with Ubuntu 24.04) for optional functionality

For fasttext (optional)

sudo apt-get install build-essential python3-dev

For .doc text extraction (optional)

sudo apt-get install antiword

A note on using Browsertrix

In order to use Browsertrix for crawling JavaScript-heavy pages and extract text from HTML, you must currently clone a custom Browsertrix from:

https://github.com/Sprakbanken/browsertrix-crawler/tree/add-dom-resource

Then build with Docker:

docker build -t maalfrid-browsertrix .

License

GPL

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

maalfrid_toolkit-1.4.1.tar.gz (29.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maalfrid_toolkit-1.4.1-py3-none-any.whl (29.3 MB view details)

Uploaded Python 3

File details

Details for the file maalfrid_toolkit-1.4.1.tar.gz.

File metadata

  • Download URL: maalfrid_toolkit-1.4.1.tar.gz
  • Upload date:
  • Size: 29.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-84-generic

File hashes

Hashes for maalfrid_toolkit-1.4.1.tar.gz
Algorithm Hash digest
SHA256 c0709a6ad0e07bc66fe3208ca941d16f46f331b180df5b1363db205eff131b66
MD5 a9cd07061bf0ad5226f43f46f5e6f5c4
BLAKE2b-256 f68f599cd8b494b3018e1245a681e6c115a3749bbde74d6e2701b91f3975f094

See more details on using hashes here.

File details

Details for the file maalfrid_toolkit-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: maalfrid_toolkit-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 29.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-84-generic

File hashes

Hashes for maalfrid_toolkit-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab87f09894a6e2c4b7531278bc6f4d2a83a9c1ca10e15588612bd88bde656430
MD5 c495d7c214f0a57e99a81d208d6225a9
BLAKE2b-256 883d7a6438df188531f0b0f0812faaaae7081ee52a0692b7c5906cc737e1f852

See more details on using hashes here.

Supported by

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