opus-read - read sentence alignment in XCES align format
# read sentence alignments and print aligned sentences opus-read align-file.xml opus-read align-file.xml.gz opus-read corpusname/lang-pair opus-read -d corpusname lang-pair opus-read -d corpusname -s srclang -t trglang # print alignments with alignment certainty > LinkThr=0 opus-read -c 0 align-file.xml # print alignments with max 2 source sentences and 3 target sentences opus-read -S 2 -T 3 align-file.xml # print aligned sentences marked as 'de' (source) and 'en' (target) # (this only works if sentences are marked with languages: # for example, in the German XML file: <s lang="de">...</s>) opus-read -s de -t en align-file.xml # wrap aligned sentences in simple HTML opus-read -h align-file.xml # print max 10 alignments opus-read -m 10 align-file.xml # specify home directory of aligned XML files opus-read -d /path/to/xml/files align-file.xml # print XCES align format of all 1:1 sentence alignments opus-read -S 1 -T 1 -l align-file.xml
opus-read [OPTIONS] align-file.xml
-c <thr> ........... set a link threshold <thr> -d <dir> ........... set home directory for aligned XML documents -h ................. print simple HTML -l ................. print links (filter mode) -m <max> ........... print max <max> alignments -n <regex> ......... get only documents that match the regex -N <regex> ......... skip all documents that match the regex -o <thr> ........... set a threshold for time overlap (subtitle data) -r <release> ....... release (default = latest) -s <LangID> ........ require source sentences to match <LangID> -t <LangID> ........ require target sentences to match <LangID> -S <max> ........... maximum number of source sentence in alignments -T <max> ........... maximum number of target sentence in alignments -SN <nr> ........... number of source sentence in alignments -TN <nr> ........... number of target sentence in alignments
opus-read is a simple script to read sentence alignments stored in XCES align format and prints the aligned sentences to STDOUT. It requires monolingual alignments (ascending order, no crossing links) of sentences in linked XML files. Linked XML files are specified in the toDoc and <fromDoc> attributes (see below).
opus-read
toDoc
<cesAlign version="1.0"> <linkGrp targType="s" toDoc="source1.xml" fromDoc="target1.xml"> <link certainty="0.88" xtargets="s1.1 s1.2;s1.1" id="SL1" /> .... <linkGrp targType="s" toDoc="source2.xml" fromDoc="target2.xml"> <link certainty="0.88" xtargets="s1.1;s1.1" id="SL1" />
Several parameters can be set to filter the alignments and to print only certain types of alignments.
opus-read can also be used to filter the XCES alignment files and to print the remaining links in the same XCES align format. Use the -l flag to enable this mode.
-l
--------------------------------------------------------------------------- Copyright (c) 2004-2019 Joerg Tiedemann 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. ---------------------------------------------------------------------------
This script is part of opus-tools https://github.com/Helsinki-NLP/opus-tools See also OPUS http://opus.nlpl.eu for more information about the corpus.
To install OPUS::Tools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OPUS::Tools
CPAN shell
perl -MCPAN -e shell install OPUS::Tools
For more information on module installation, please visit the detailed CPAN module installation guide.