Skip to content

Download, parse and postprocess any OpenSubtitles monolingual file

Notifications You must be signed in to change notification settings

William-N-Havard/opus-corpus-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

opus-corpus-parser

Download, parse and postprocess any Opus monolingual file. Python 2.7 and 3 compatible (significantly slower with Python 2.7 though)

This Python script allows you to download, extract and postprocess any monolingual file from the Opus Database. Each file in the .tar.gz file is extracted and read into memory so that no temporary file is created. The XML file is then parsed and its corresponding raw text is outputed in a .txt file. The original .tar.gz directory structure is kept unchanged.

The user can specify its own processing functions, which make the processing operation language independent. As for now, only a basic English detokenizer has been provided.

Usage

python[2.7|3] opus-corpus-parser.py URL --outdir='./my-outdir' --ext='.txt' --transform='en' --verbose

URL: URL of file to be downloaded (e. g. http://opus.nlpl.eu/download.php?f=OpenSubtitles/ro.tar.gz)

--outdir: Path where processed files will be saved. If no path is provided, path name will be derived automatically

--ext: Extension that will be given to the processed files

--tranform: Post-process each sentence with a user-specified function (to be found in detokenizer.py. (e. g. --transform="en, rm_commentary" will first transform each sentence using "en" in detokenizer.py and will then process each sentence using the user-defined function "rm_commentary")

--verbose: Increase verbosity

Credits

Opus Database - http://opus.nlpl.eu/index.php Jörg Tiedemann, 2012, Parallel Data, Tools and Interfaces in OPUS. [pdf] In Proceedings of the 8th International Conference on Language Resources and Evaluation (LREC'2012)

About

Download, parse and postprocess any OpenSubtitles monolingual file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages