Metadata-Version: 2.4
Name: jusText
Version: 4.0.1
Summary: Heuristic based boilerplate removal tool
Author: Jan Pomikálek
Author-email: Jan Pomikálek <jan.pomikalek@gmail.com>
License-Expression: BSD-2-Clause
License-File: LICENSE.rst
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Pre-processors
Classifier: Topic :: Text Processing :: Filters
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Dist: lxml[html-clean]>=4.4.2
Maintainer: Michal Belica
Maintainer-email: Michal Belica <miso.belica@gmail.com>
Requires-Python: >=3.8
Project-URL: Homepage, https://github.com/miso-belica/jusText
Project-URL: Repository, https://github.com/miso-belica/jusText
Description-Content-Type: text/markdown

# jusText

[![Run tests](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml/badge.svg)](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml)

Program jusText is a tool for removing boilerplate content, such as navigation
links, headers, and footers from HTML pages. It is
[designed](doc/algorithm.rst) to preserve
mainly text containing full sentences and it is therefore well suited for
creating linguistic resources such as Web corpora. You can
[try it online](http://nlp.fi.muni.cz/projects/justext/).

This is a fork of original (currently unmaintained) code of [jusText](http://code.google.com/p/justext/) hosted
on Google Code.

Adaptations of the algorithm to other languages:

- [C++](https://github.com/endredy/jusText)
- [Go](https://github.com/JalfResi/justext)
- [Java](https://github.com/wizenoze/justext-java)
- [Javascript](https://github.com/smodin-io/justext)

Some libraries using jusText:

- [chirp](https://github.com/9b/chirp)
- [lazynlp](https://github.com/chiphuyen/lazynlp)
- [off-topic-memento-toolkit](https://github.com/oduwsdl/off-topic-memento-toolkit)
- [pears](https://github.com/PeARSearch/PeARS-orchard)
- [readability calculator](https://github.com/joaopalotti/readability_calculator)
- [sky](https://github.com/kootenpv/sky)

Some currently (Jan 2020) maintained alternatives:

- [dragnet](https://github.com/dragnet-org/dragnet)
- [html2text](https://github.com/Alir3z4/html2text)
- [inscriptis](https://github.com/weblyzard/inscriptis)
- [newspaper](https://github.com/codelucas/newspaper)
- [python-readability](https://github.com/buriy/python-readability)
- [trafilatura](https://github.com/adbar/trafilatura)

## Installation

jusText needs Python 3.8+. Add it to your project with [uv](https://docs.astral.sh/uv/):

```bash
$ uv add justext
```

or install it with pip via `pip install justext`.

## Dependencies

```
lxml (version depends on your Python version)
```

## Usage

```bash
$ uv run python -m justext -s Czech -o text.txt http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
$ uv run python -m justext -s English -o plain_text.txt english_page.html
$ uv run python -m justext --help # for more info
```

Without a project, prefix the commands with `uv run --with justext` instead of `uv run`.

## Python API

```python
import requests
import justext

response = requests.get("http://planet.python.org/")
paragraphs = justext.justext(response.content, justext.get_stoplist("English"))
for paragraph in paragraphs:
    if not paragraph.is_boilerplate:
        print(paragraph.text)
```

## Development

Install [uv](https://docs.astral.sh/uv/) and run tests, the linter and the formatter via

```bash
$ uv run pytest
$ uv run ruff check
$ uv run ruff format
```

To skip formatting-only commits in `git blame`, run `git config blame.ignoreRevsFile .git-blame-ignore-revs` once.

## Releasing

Go to Actions → Release → Run workflow and pick `patch`, `minor` or `major`. The workflow runs the tests,
bumps the version, moves the "Unreleased" part of the CHANGELOG under the new version, pushes the commit and tag
to `main`, publishes to PyPI and creates a GitHub release.

Publishing needs PyPI [trusted publisher](https://docs.pypi.org/trusted-publishers/) set up for
the `publish-to-pypi.yaml` workflow.

If `uv publish` fails after the push, don't re-run the workflow, it would bump the version again.
Check out the new tag and run `uv build && uv publish` by hand instead. Outside of GitHub Actions `uv publish`
needs a PyPI API token in `UV_PUBLISH_TOKEN`.

## Acknowledgements

This software has been developed at the [Natural Language Processing Centre](http://nlp.fi.muni.cz/en/nlpc) of
[Masaryk University in Brno](http://nlp.fi.muni.cz/en) with a financial support from [PRESEMT](http://presemt.eu/) and
[Lexical Computing Ltd.](http://lexicalcomputing.com/) It also relates to [PhD research](http://is.muni.cz/th/45523/fi_d/phdthesis.pdf) of Jan Pomikálek.
