From stefanML at collocations.de Wed Jul 1 11:52:11 2026 From: stefanML at collocations.de (Stephanie Evert) Date: Wed, 1 Jul 2026 11:52:11 +0200 Subject: [CWB] xml searches... In-Reply-To: <8c93469d-12cd-4358-a77e-75855d0fa428@univ-avignon.fr> References: <8c93469d-12cd-4358-a77e-75855d0fa428@univ-avignon.fr> Message-ID: > Is there any way I can search for xml tags inside other xml tags? Something like > n: []+ :: n.div2_n="1"; You need to set the label on some token within the region, typically the first one: n:[] []* :: n.div2_n="1"; Or you could use the implicitly defined match or matchend anchors as long as the region of interest is at the start or end of the query: []+ :: match.div2_n="1"; Another ? faster ? option is to do the check inline, but I generally prefer the global constraint for readability: [ _.div2_n="1" ] []* :: Best, Stephanie > (which doesn't work, as it is gross improvisation!). > Many thanks in advance for any help! > Best, > Graham. > _______________________________________________ > CWB mailing list > CWB at sslmit.unibo.it > http://liste.sslmit.unibo.it/mailman/listinfo/cwb From graham.ranger at univ-avignon.fr Wed Jul 1 15:55:08 2026 From: graham.ranger at univ-avignon.fr (Graham Ranger) Date: Wed, 1 Jul 2026 15:55:08 +0200 Subject: [CWB] xml searches... In-Reply-To: References: <8c93469d-12cd-4358-a77e-75855d0fa428@univ-avignon.fr> Message-ID: Many thanks for this Stephanie. It works brilliantly. Best, Graham. Le 01/07/2026 ? 11:52, Stephanie Evert a ?crit?: > >> Is there any way I can search for xml tags inside other xml tags? Something like >> n: []+ :: n.div2_n="1"; > You need to set the label on some token within the region, typically the first one: > > n:[] []* :: n.div2_n="1"; > > Or you could use the implicitly defined match or matchend anchors as long as the region of interest is at the start or end of the query: > > []+ :: match.div2_n="1"; > > Another ? faster ? option is to do the check inline, but I generally prefer the global constraint for readability: > > [ _.div2_n="1" ] []* :: > > Best, > Stephanie > >> (which doesn't work, as it is gross improvisation!). >> Many thanks in advance for any help! >> Best, >> Graham. >> _______________________________________________ >> CWB mailing list >> CWB at sslmit.unibo.it >> http://liste.sslmit.unibo.it/mailman/listinfo/cwb > > > > From graham.ranger at univ-avignon.fr Wed Jul 8 10:28:30 2026 From: graham.ranger at univ-avignon.fr (Graham Ranger -- UAPV) Date: Wed, 8 Jul 2026 10:28:30 +0200 Subject: [CWB] Question re: parallel corpora set up Message-ID: Hello all, I have a quick question regarding parallel corpora set up. Does the cwb-align command actually do the alignment, as I understand it does, from the terminal messages, and, if so, is it possible to override the cwb alignment to impose one's own alignment? I'm asking because I remember reading that the cwb-align command was not a very efficient aligner, and so far I prefer to do the alignment myself in advance, and to give cwb-align files with exactly the same number of alignment fields (s tags). Despite this, I have the impression that the command can knock this initial, hand-checked alignment out of kilter, which is a shame, and so an override flag, if it existed, would be nice. A related question: what does the "no alignments found" message most often mean? I'm setting up a three-way corpus English-French-Polish. The source text is English, the French and Polish texts are translations but, since the alignments are based on the English, I would like to be able to provide the option for searching in one translated corpus, and looking for the equivalent in the other translated corpus. So far, things work perfectly Eng-Fre and Eng-Pol but I get the "no alignments found" message when searching in "Fre-Pol" and yet I think I've set it all up identically... Many thanks in advance for help on all this. Best, Graham. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefanML at collocations.de Fri Jul 10 08:43:35 2026 From: stefanML at collocations.de (Stephanie Evert) Date: Fri, 10 Jul 2026 08:43:35 +0200 Subject: [CWB] Question re: parallel corpora set up In-Reply-To: References: Message-ID: Hi Graham! > I have a quick question regarding parallel corpora set up. Does the cwb-align command actually do the alignment, as I understand it does, from the terminal messages, and, if so, is it possible to override the cwb alignment to impose one's own alignment? Correct. cwb-align ist the actual sentence aligner and does indeed use a rather simplistic and old-fashioned algorithm. It outputs the alignment in a text format (basically listing start/end corpus positions of corresponding regions in source and target corpus), which is then indexed with cwb-align-encode for use with CWB. Which means that you can "simply" generate your own alignment in this text format and then run cwb-align-encode. You can also preview your alignment with cwb-align-show first to check that you've got the format right. > I'm asking because I remember reading that the cwb-align command was not a very efficient aligner, and so far I prefer to do the alignment myself in advance, and to give cwb-align files with exactly the same number of alignment fields (s tags). Despite this, I have the impression that the command can knock this initial, hand-checked alignment out of kilter, which is a shame, and so an override flag, if it existed, would be nice. If you have a pre-alignment (which might be at a different level than sentences), you can indicate this to cwb-align, which will force the aligner to only consider sentence correspondences that are consistent with the pre-alignment. A trick I've sometimes used is to specify the same s-attribute that encodes the pre-alignment (keep in mind that there must be a single region for each pre-alignment block) as alignment grid, which keeps cwb-align from making any changes. It is usually much easier, though, to use cwb-align-import from the CWB/Perl modules. This script is intended to import an external alignment given in terms of sentence IDs (which must be annotated in the corpus via an s-attribute). From its documentation: > As an example, the line > > id_1 id_2 id_3 id_2 id_3 [ ... ] > > indicates that the first three sentences of the source corpus are > aligned to the second and third sentence of the target corpus. Further > TAB-delimited fields (e.g. specifying the confidence in an alignment > bead) are silently ignored. > A related question: what does the "no alignments found" message most often mean? I'm setting up a three-way corpus English-French-Polish. The source text is English, the French and Polish texts are translations but, since the alignments are based on the English, I would like to be able to provide the option for searching in one translated corpus, and looking for the equivalent in the other translated corpus. So far, things work perfectly Eng-Fre and Eng-Pol but I get the "no alignments found" message when searching in "Fre-Pol" and yet I think I've set it all up identically... "no alignment found" is the message you get if a query match in your source corpus isn't aligned to the target corpus. Since alignments don't have to cover the corpus completely, this may well happen. However, if you always get the message, there's something wrong with the Fre-Pol alignment. Perhaps a first step would be to use cwb-align-decode on the French corpus to see which alignment beads you actually have. Hope this helps, Stephanie -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefanML at collocations.de Fri Jul 10 09:39:42 2026 From: stefanML at collocations.de (Stephanie Evert) Date: Fri, 10 Jul 2026 09:39:42 +0200 Subject: [CWB] Question re: parallel corpora set up In-Reply-To: References: Message-ID: <2247B2B0-4EDA-44AB-9ABB-66DE4DF652A4@collocations.de> Hi Graham! > I have a quick question regarding parallel corpora set up. Does the cwb-align command actually do the alignment, as I understand it does, from the terminal messages, and, if so, is it possible to override the cwb alignment to impose one's own alignment? Correct. cwb-align ist the actual sentence aligner and does indeed use a rather simplistic and old-fashioned algorithm. It outputs the alignment in a text format (basically listing start/end corpus positions of corresponding regions in source and target corpus), which is then indexed with cwb-align-encode for use with CWB. Which means that you can "simply" generate your own alignment in this text format and then run cwb-align-encode. You can also preview your alignment with cwb-align-show first to check that you've got the format right. > I'm asking because I remember reading that the cwb-align command was not a very efficient aligner, and so far I prefer to do the alignment myself in advance, and to give cwb-align files with exactly the same number of alignment fields (s tags). Despite this, I have the impression that the command can knock this initial, hand-checked alignment out of kilter, which is a shame, and so an override flag, if it existed, would be nice. If you have a pre-alignment (which might be at a different level than sentences), you can indicate this to cwb-align, which will force the aligner to only consider sentence correspondences that are consistent with the pre-alignment. A trick I've sometimes used is to specify the same s-attribute that encodes the pre-alignment (keep in mind that there must be a single region for each pre-alignment block) as alignment grid, which keeps cwb-align from making any changes. It is usually much easier, though, to use cwb-align-import from the CWB/Perl modules. This script is intended to import an external alignment given in terms of sentence IDs (which must be annotated in the corpus via an s-attribute). From its documentation: > As an example, the line > > id_1 id_2 id_3 id_2 id_3 [ ... ] > > indicates that the first three sentences of the source corpus are > aligned to the second and third sentence of the target corpus. Further > TAB-delimited fields (e.g. specifying the confidence in an alignment > bead) are silently ignored. > A related question: what does the "no alignments found" message most often mean? I'm setting up a three-way corpus English-French-Polish. The source text is English, the French and Polish texts are translations but, since the alignments are based on the English, I would like to be able to provide the option for searching in one translated corpus, and looking for the equivalent in the other translated corpus. So far, things work perfectly Eng-Fre and Eng-Pol but I get the "no alignments found" message when searching in "Fre-Pol" and yet I think I've set it all up identically... "no alignment found" is the message you get if a query match in your source corpus isn't aligned to the target corpus. Since alignments don't have to cover the corpus completely, this may well happen. However, if you always get the message, there's something wrong with the Fre-Pol alignment. Perhaps a first step would be to use cwb-align-decode on the French corpus to see which alignment beads you actually have. Hope this helps, Stephanie -------------- next part -------------- An HTML attachment was scrubbed... URL: From graham.ranger at univ-avignon.fr Fri Jul 10 15:09:34 2026 From: graham.ranger at univ-avignon.fr (Graham Ranger -- UAPV) Date: Fri, 10 Jul 2026 15:09:34 +0200 Subject: [CWB] Question re: parallel corpora set up In-Reply-To: References: Message-ID: <03eaf27a-0e14-4c03-b551-2c5894fbf83e@univ-avignon.fr> Hi Stephanie, Thanks, as always, for your quick and precise answers. One or two other follow-up questions below... but please do not feel obliged to answer, these are really just to help me understand things a little better, if you have a free minute. Best wishes, Graham. Le 10/07/2026 ? 08:43, Stephanie Evert a ?crit?: > > ? Ce courrier est envoy? par un correspondant externe > > Hi Graham! > >> I have a quick question regarding parallel corpora set up. Does the >> cwb-align command actually do the alignment, as I understand it does, >> from the terminal messages, and, if so, is it possible to override >> the cwb alignment to impose one's own alignment? > > Correct. cwb-align ist the actual sentence aligner and does indeed use > a rather simplistic and old-fashioned algorithm. It outputs the > alignment in a text format (basically listing start/end corpus > positions of corresponding regions in source and target corpus), which > is then indexed with cwb-align-encode for use with CWB. > > Which means that you can "simply" generate your own alignment in this > text format and then run cwb-align-encode. You can also preview your > alignment with cwb-align-show first to check that you've got the > format right. So as I understand this, given that my s tags are one-to-one correspondancse, it would be enough for me to upload an .align file reading 1 1, 2 2, etc.? > >> I'm asking because I remember reading that the cwb-align command was >> not a very efficient aligner, and so far I prefer to do the alignment >> myself in advance, and to give cwb-align files with exactly the same >> number of alignment fields (s tags). Despite this, I have the >> impression that the command can knock this initial, hand-checked >> alignment out of kilter, which is a shame, and so an override flag, >> if it existed, would be nice. > > If you have a pre-alignment (which might be at a different level than > sentences), you can indicate this to cwb-align, which will force the > aligner to only consider sentence correspondences that are consistent > with the pre-alignment. A trick I've sometimes used is to specify the > same s-attribute that encodes the pre-alignment (keep in mind that > there must be a single region for each pre-alignment block) as > alignment grid, which keeps cwb-align from making any changes. Does this mean that, since I specify alignment on s tags in cwb-align, I should be getting what I want to achieve anyway? > > It is usually much easier, though, to use cwb-align-import from the > CWB/Perl modules. This script is intended to import an external > alignment given in terms of sentence IDs (which must be annotated in > the corpus via an s-attribute). From its documentation: > >> As an example, the line id_1 id_2 id_3 id_2 id_3 [ ... ] >> indicates that the first three sentences of the source corpus are >> aligned to the second and third sentence of the target corpus. >> Further TAB-delimited fields (e.g. specifying the confidence in an >> alignment bead) are silently ignored. My pre-alignement is tagged ... which generally, but not always, correspond to sentences. As I understand it, I'd need to tag it ... , etc. Is that right? If so, could it just, trivially, be a question of added the "id" attribute incrementally to the already present "s" tags in order to run cwb-align-import with my pre-aligned material? > > >> A related question: what does the "no alignments found" message most >> often mean? I'm setting up a three-way corpus English-French-Polish. >> The source text is English, the French and Polish texts are >> translations but, since the alignments are based on the English, I >> would like to be able to provide the option for searching in one >> translated corpus, and looking for the equivalent in the other >> translated corpus. So far, things work perfectly Eng-Fre and Eng-Pol >> but I get the "no alignments found" message when searching in >> "Fre-Pol" and yet I think I've set it all up identically... > > "no alignment found" is the message you get if a query match in your > source corpus isn't aligned to the target corpus. Since alignments > don't have to cover the corpus completely, this may well happen. > > However, if you always get the message, there's something wrong with > the Fre-Pol alignment. Perhaps a first step would be to use > cwb-align-decode on the French corpus to see which alignment beads you > actually have. Thank you for this... I'll check again. > > Hope this helps, > Stephanie -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefanML at collocations.de Sun Jul 12 14:04:23 2026 From: stefanML at collocations.de (Stephanie Evert) Date: Sun, 12 Jul 2026 14:04:23 +0200 Subject: [CWB] Question re: parallel corpora set up In-Reply-To: <03eaf27a-0e14-4c03-b551-2c5894fbf83e@univ-avignon.fr> References: <03eaf27a-0e14-4c03-b551-2c5894fbf83e@univ-avignon.fr> Message-ID: <81BF4FBC-5E2C-449B-801F-5D3F35883C1E@collocations.de> Hi again! >> Which means that you can "simply" generate your own alignment in this text format and then run cwb-align-encode. You can also preview your alignment with cwb-align-show first to check that you've got the format right. > So as I understand this, given that my s tags are one-to-one correspondancse, it would be enough for me to upload an .align file reading 1 1, 2 2, etc.? No, the input file has to list the start and end corpus positions of the corresponding regions. If your pre-alignment is encoded in s-attribute "s" in both SOURCE and TARGET corpus, and if there's indeed a perfect correspondence between the reasons, these unix command-line steps will give you most of the .align file (you just need to add a header line as described in "man cwb-align"). cwb-s-decode SOURCE s > tmp1.txt cwb-s-decode TARGET s > tmp2.txt paste tmp1.txt tmp2.txt > source_target.align But it's even easier to use "cwb-align" to generate the file, by using "s" both as the alignment grid and as pre-alignment. cwb-align -o source_target.align -S s SOURCE TARGET s -C:1 "cwb-align" has no choice but to generate all 1:1 alignments because there's only a single source and target region in each pre-alignment block. (Theoretically it could split them into 1:0 and 0:1 beads, but that should always get a worse score than the 1:1 alignment.) You could also just use the default feature set, but using only sentence length (-C:1) is avoids unnecessary work. >> If you have a pre-alignment (which might be at a different level than sentences), you can indicate this to cwb-align, which will force the aligner to only consider sentence correspondences that are consistent with the pre-alignment. A trick I've sometimes used is to specify the same s-attribute that encodes the pre-alignment (keep in mind that there must be a single region for each pre-alignment block) as alignment grid, which keeps cwb-align from making any changes. > Does this mean that, since I specify alignment on s tags in cwb-align, I should be getting what I want to achieve anyway? If you do it as I've shown above, this should just pass through the pre-alignment. > My pre-alignement is tagged ... which generally, but not always, correspond to sentences. As I understand it, I'd need to tag it ... , etc. Is that right? If so, could it just, trivially, be a question of added the "id" attribute incrementally to the already present "s" tags in order to run cwb-align-import with my pre-aligned material? Yes, that would be the cleanest solution, combined with an input file that lists the trivially corresponding IDs 1 TAB 1 2 TAB 2 ... Best, Stephanie -------------- next part -------------- An HTML attachment was scrubbed... URL: