Package: alto2txt
Extract plain text from newspapers (alto2txt 0.3.1)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.InstallationInstallation using an Anaconda environmentWe recommend installation via Anaconda:Refer to theAnaconda website and follow the instructions.Create a new environment for alto2txtcondacreate-npy37altopython=3.7Activate the environment:condaactivatepy37altoInstall alto2txt itselfInstallalto2txtusing pip:pipinstallalto2txt(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 environmentNote, 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.pipinstallalto2txtInstallation of a test releaseIf you need (or want) to install a test release ofalto2txtyou will likely be advised of the specific version number to install. This examaple command will installv0.3.1-alpha.20:pipinstall-ihttps://test.pypi.org/simple/alto2txt==0.3.1a20UsageDownsampling 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

Converts XML publications to plaintext articles

positional arguments:
  xml_in_dir            Input directory with XML publications
  txt_out_dir           Output directory for plaintext articles

optional arguments:
  -h, --help            show this help message and exit
  -d [DOWNSAMPLE], --downsample [DOWNSAMPLE]
                        Downsample. Default 1
  -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
  -n [NUM_CORES], --num-cores [NUM_CORES]
                        Number of cores (Spark only). Default 1")xml_in_diris expected to hold XML for multiple publications, in the following structure:xml_in_dir
|-- publication
|   |-- year
|   |   |-- issue
|   |   |   |-- xml_content
|   |-- year
|-- publicationHowever, if-p|--process-type singleis provided thenxml_in_diris expected to hold XML for a single publication, in the following structure:xml_in_dir
|-- year
|   |-- issue
|   |   |-- xml_content
|-- yeartxt_out_diris created with an analogous structure toxml_in_dir.PROCESS_TYPEcan be one of:single: Process single publication.serial: Process publications serially.multi: Process publications using multiprocessing (default).spark: Process publications using Spark.DOWNSAMPLEmust be a positive integer, default 1.The following XSLT files need to be in anextract_text.xsltsmodule: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 publicationsAssume~/BNAexists and matches the structure above.Extract text from every publication:./extract_publications_text.py~/BNAtxtExtract text from every 100th issue of every publication:./extract_publications_text.py~/BNAtxt-d100Process a single publicationExtract text from every issue of a single publication:./extract_publications_text.py-psingle~/BNA/0000151txtExtract text from every 100th issue of a single publication:./extract_publications_text.py-psingle~/BNA/0000151txt-d100Configure loggingBy default, logs are put inout.log.To specify an alternative location for logs, use the-lflag e.g../extract_publications_text.py-lmylog.txt~/BNAtxt-d1002>err.logProcess publications via SparkInformation on running on spark.Future workFor a complete list of future plans see theGitHub issues list. Some highlights include:Export more metadata from alto, probably by parsingmetsfirst.Check and ensure that articles that span multiple pages are pulled into a single article file.Smarter handling of articles spanning multiple pages.CopyrightSoftwareCopyright 2022 The Alan Turing Institute, British Library Board, Queen Mary University of London, University of Exeter, University of East Anglia and University of Cambridge.SeeLICENSEfor more details.Example DatasetsThis repo contains example datasets, which have been taken from theBritish Library Research Repository(DOI link).This data is "CC0 1.0 Universal Public Domain" -No Copyright - Other Known Legal RestrictionsThere is a subset of the example data in thedemo-filesdirectory.There are adapted copies of the data in thetests/tests/test_filesdirectory. These have been edited to test errors and edge cases.Funding and AcknowledgementsThis software has been developed as part of theLiving with Machinesproject.This project, funded by the UK Research and Innovation (UKRI) Strategic Priority Fund, is a multidisciplinary collaboration delivered by the Arts and Humanities Research Council (AHRC), with The Alan Turing Institute, the British Library and the Universities of Cambridge, East Anglia, Exeter, and Queen Mary University of London.