Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry config #51

Merged
merged 30 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d71cfc8
Add icecream to pyproject.toml dev-dependencies to run tests.
spool Jul 1, 2022
670eea4
Update lxml and typing-extensions in poetry.lock
spool Jul 4, 2022
669295e
Update pyproject.lock to fit master.
spool Jul 4, 2022
4fd29ea
Bring setup.py info over pyproject.toml and specify MIT License in LI…
spool Jul 4, 2022
5b6736e
Update pre-commit packages.
spool Jul 4, 2022
f757aa2
Fix pyproject.toml keywords
spool Jul 4, 2022
30df234
Remove previous poetry.lock file to stage reset.
spool Jul 4, 2022
a7d02a6
Fix maintainers format and poetry.lock
spool Jul 4, 2022
1d10878
Set MIT license in setup.py
spool Jul 6, 2022
23a57f9
Add pre-commit to pyproject.toml and expand to include isort checks.
spool Jul 19, 2022
18103f6
Apply import changes suggested by isort via pre-commit.
spool Jul 19, 2022
fd10d73
Add pycln pre-commit plugin and apply to remove unusued plugins.
spool Jul 19, 2022
c9c43f9
Add coverage via pytest-cov.
spool Jul 19, 2022
77cc258
Fix typos in README.md
spool Jul 19, 2022
e006e87
Set pyproject.toml python version to >3.6 for consistency with curren…
spool Jul 19, 2022
822c020
Remove requirements.txt and setup.py
spool Jul 19, 2022
031f785
Add PyPI license badge.
spool Jul 19, 2022
8f28b87
Attempted fix of licensing badge.
spool Jul 19, 2022
9982770
Add PyPI version badge.
spool Jul 19, 2022
a75396e
Put padges on the same line.
spool Jul 19, 2022
c58027c
Wrap XML formats in README.md with `` marks more consistently.
spool Jul 20, 2022
8c4aa41
Update mypy in .pre-commit-config.yaml
spool Jul 21, 2022
a7e63d4
Update CHANGELOG.md
spool Jul 21, 2022
3f6598d
Add python 3.6 and 3.10 to ci-tests.yml
spool Jul 21, 2022
347bd4f
Add 3.10 to ci-tests.yml
spool Jul 21, 2022
cf1e570
Add quotes around python-version list to support v3.10
spool Jul 21, 2022
c96a2ef
Remove support for python 3.6
spool Jul 21, 2022
b23b593
Update documentation to reflect install.
spool Nov 10, 2022
cdf144f
Apply pre-commit formatting.
spool Nov 10, 2022
90c9b7a
Replace references to requirements.txt with pyproject.toml
spool Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
21 changes: 13 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
# Leave demo-files unaltered after download from BL website.
Expand All @@ -12,18 +12,23 @@ repos:
- id: check-xml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v1.6.0' # Use the sha / tag you want to point at
rev: v1.6.0 # Use the sha / tag you want to point at
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.960' # Use the sha / tag you want to point at
rev: v0.971 # Use the sha / tag you want to point at
hooks:
- id: mypy
# - repo: https://github.com/pre-commit/mirrors-isort
# rev: v5.10.1
# hooks:
# - id: isort
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
hooks:
- id: pycln
args: [--config=pyproject.toml]
73 changes: 66 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,83 @@ All notable changes to this software will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

Please maintain both this file AND the README.md file.
Please maintain both this file AND the `README.md` file.

## [Unreleased]
## [0.3.4]

### Added
* Added this changelog file.
* Established use of [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for this project.
* Added a separate 'CONTRIBUTING.md' doc for software developers notes.
* Added a separate copyright notice for example datasets
* Added `PyPI` version and `MIT` license badges to `README.md`
* Added `pytest-cov` with default options to assess documentation
* Added `isort` to `.pre-commit-config.yaml` to sort import consistency
* Added `pycln` to `.pre-commit-config.yaml` to check unused imports
* Added `pycln` configuration to `pyproject.toml`
* Added `alto2txt` as a command line script in `pyproject.toml`

### Changed
* Switch from Apache v2.0 license to MIT license, inline with project recommendations.
* Switch from `Apache v2.0` license to `MIT` license, inline with project recommendations.
* Updated `mypy` in `.pre-commit-config.yaml`

### Deprecated
* Replace `extract_publications_text.py` with the `alto2txt` `command line interface` script specified in `pyproject.toml`

### Removed
* `setup.py`
* `requirements.txt`

### Fixed

* Fixed `python = ">3.6.0"` in `pyproject.toml` rather than `>3.7` for consistency with documentation
* Fixed licensing ambiguity (now all should be `MIT`)
* Fixed typos in `README.md`
* Fixed surperflous imports via `pycln` in `pre-commit`

### Security

## v0.3.3

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

## v0.3.2

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

## v0.3.1

### Added
* Added this changelog file.
* Established use of [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for this project.
* Added a separate `CONTRIBUTING.md` doc for software developers notes.
* Added a separate copyright notice for example datasets

### Changed

### Deprecated

### Removed

### Fixed

### Security

## v0.3.0 and before (prior to 2022-04-27)

Expand Down
8 changes: 5 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Copyright © 2022 The Alan Turing Institute, British Library Board, Queen Mary University of London, University of Exeter, University of East Anglia and University of Cambridge
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (c) 2020 The Alan Turing Institute, British Library Board, Queen Mary University of London, University of Exeter, University of East Anglia and University of Cambridge

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61 changes: 30 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Extract plain text from newspapers (alto2txt 0.3.1)
# `alto2txt`: Extract plain text from newspapers

Converts XML (in METS 1.8/ALTO 1.4, METS 1.3/ALTO 1.4, BLN or UKP format) publications to plaintext articles and generates minimal metadata.
![GitHub](https://img.shields.io/github/license/Living-with-Machines/alto2txt) ![PyPI](https://img.shields.io/pypi/v/alto2txt)

Converts `XML` (in `METS` `1.8`/`ALTO` `1.4`, `METS` `1.3`/`ALTO` `1.4`, `BLN` or `UKP` format) publications to plaintext articles and generates minimal metadata.


## [Full documentation and demo instructions.](https://living-with-machines.github.io/alto2txt/#/)
Expand All @@ -14,7 +16,7 @@ We recommend installation via Anaconda:

* Refer to the [Anaconda website and follow the instructions](https://docs.anaconda.com/anaconda/install/).

* Create a new environment for alto2txt
* Create a new environment for `alto2txt`

```bash
conda create -n py37alto python=3.7
Expand All @@ -26,19 +28,19 @@ conda create -n py37alto python=3.7
conda activate py37alto
```

* Install alto2txt itself
* Install `alto2txt` itself

Install `alto2txt` using pip:

```bash
pip install alto2txt
```

(For now it is still necessary to install using pip. In due course we plan to make alto2txt available through a conda channel, meaning that it can be installed directly using conda commands.)
(For now it is still necessary to install using `pip`. In due course we plan to make `alto2txt` available through a `conda` channel, meaning that it can be installed directly using `conda` commands.)

### Installation using pip, outside an Anaconda environment

Note, the use of `alto2txt`` outside a conda environment has not been as extensively tested as within a conda environment. Whilst we believe that this should work, please use with caution.
Note, the use of ``alto2txt`` outside a conda environment has not been as extensively tested as within a conda environment. Whilst we believe that this should work, please use with caution.

```bash
pip install alto2txt
Expand All @@ -54,16 +56,15 @@ pip install -i https://test.pypi.org/simple/ alto2txt==0.3.1a20

## Usage

Downsampling can be used to convert only every Nth issue of each newspaper. One text file is output per article, each complemented by one XML metadata file.
Downsampling can be used to convert only every Nth issue of each newspaper. One text file is output per article, each complemented by one `XML` metadata file.



```
extract_publications_text.py [-h] [-d [DOWNSAMPLE]]
[-p [PROCESS_TYPE]]
[-l [LOG_FILE]]
[-n [NUM_CORES]]
xml_in_dir txt_out_dir
usage: alto2txt [-h] [-p [PROCESS_TYPE]] [-l [LOG_FILE]] [-d [DOWNSAMPLE]] [-n [NUM_CORES]]
xml_in_dir txt_out_dir
alto2txt [-h] [-p [PROCESS_TYPE]] [-l [LOG_FILE]] [-d [DOWNSAMPLE]] [-n [NUM_CORES]]
xml_in_dir txt_out_dir

Converts XML publications to plaintext articles

Expand All @@ -73,19 +74,17 @@ positional arguments:

optional arguments:
-h, --help show this help message and exit
-d [DOWNSAMPLE], --downsample [DOWNSAMPLE]
Downsample. Default 1
-p [PROCESS_TYPE], --process-type [PROCESS_TYPE]
Process type. One of: single,serial,multi,spark Default: multi
-l [LOG_FILE], --log-file [LOG_FILE]
Log file. Default out.log
-p [PROCESS_TYPE], --process-type [PROCESS_TYPE]
Process type.
One of: single,serial,multi,spark
Default: multi
-d [DOWNSAMPLE], --downsample [DOWNSAMPLE]
Downsample. Default 1
-n [NUM_CORES], --num-cores [NUM_CORES]
Number of cores (Spark only). Default 1")
```

`xml_in_dir` is expected to hold XML for multiple publications, in the following structure:
`xml_in_dir` is expected to hold `XML` for multiple publications, in the following structure:

```
xml_in_dir
Expand All @@ -97,7 +96,7 @@ xml_in_dir
|-- publication
```

However, if `-p|--process-type single` is provided then `xml_in_dir` is expected to hold XML for a single publication, in the following structure:
However, if `-p|--process-type single` is provided then `xml_in_dir` is expected to hold `XML` for a single publication, in the following structure:

```
xml_in_dir
Expand All @@ -118,41 +117,41 @@ xml_in_dir

`DOWNSAMPLE` must be a positive integer, default 1.

The following XSLT files need to be in an `extract_text.xslts` module:
The following `XSLT` files need to be in an `extract_text.xslts` module:

* `extract_text_mets18.xslt`: METS 1.8 XSL file.
* `extract_text_mets13.xslt`: METS 1.3 XSL file.
* `extract_text_bln.xslt`: BLN XSL file.
* `extract_text_ukp.xslt`: UKP XSL file.
* `extract_text_mets18.xslt`: `METS 1.8 XSL` file.
* `extract_text_mets13.xslt`: `METS 1.3 XSL` file.
* `extract_text_bln.xslt`: `BLN XSL` file.
* `extract_text_ukp.xslt`: `UKP XSL` file.

## Process publications

Assume `~/BNA` exists and matches the structure above.
Assume folder `BNA` exists and matches the structure above.

Extract text from every publication:

```bash
./extract_publications_text.py ~/BNA txt
alto2txt BNA txt
```

Extract text from every 100th issue of every publication:

```bash
./extract_publications_text.py ~/BNA txt -d 100
alto2txt BNA txt -d 100
```

## Process a single publication

Extract text from every issue of a single publication:

```bash
./extract_publications_text.py -p single ~/BNA/0000151 txt
alto2txt -p single BNA/0000151 txt
```

Extract text from every 100th issue of a single publication:

```bash
./extract_publications_text.py -p single ~/BNA/0000151 txt -d 100
alto2txt -p single BNA/0000151 txt -d 100
```

## Configure logging
Expand All @@ -162,7 +161,7 @@ By default, logs are put in `out.log`.
To specify an alternative location for logs, use the `-l` flag e.g.

```bash
./extract_publications_text.py -l mylog.txt ~/BNA txt -d 100 2> err.log
alto2txt -l mylog.txt BNA txt -d 100 2> err.log
```

## Process publications via Spark
Expand Down
Loading