Start a new topic

Split source-side alternatives in glossary

(Created by a kind person in the KM forum.)


Split source-side alternatives in glossary:


Augen-Arzt;Augenarzt\toogarts


Will be split to:


Augen-Arzt\toogarts

Augenarzt\toogarts


 The Perl script:

#!/usr/bin/perl

while (<>){
	chomp;
	($lhs, $rhs) = split /\t/;
	foreach $s (split /;/, $lhs){
		print "$s\t$rhs\n";
	}
}

 


1. Put a copy of the glossary.txt file on your Desktop.

2. Use a plain text editor to create a file called splitterms.pl. Copy the Perl script above into it and save it to your Desktop.

3. Open Terminal and execute the following two lines:

 

cd ~/Desktop
perl splitterms.pl glossary.txt > newglossary.txt

 


The file newglossary.txt will appear on your Desktop in the format you want.


txt
(641 Bytes)
pl
(122 Bytes)

Why would you want to split these source-side alternatives? While they are useful during the addition of a new term pair, they have a disadvantage later: you cannot set the preferred target term via the right mouse button.

Here's a Perl script to split target-side alternatives. Note, however, that the order of the lines with target terms matches matches the order of the individual target terms in the combined variant. To re-import the lines, you'll need the reverse version (I'll work on that).

 

#!/usr/bin/perl

while (<>){
	chomp;
	($lhs, $rhs) = split /\t/;
	foreach $s (split /;/, $rhs){
		print "$lhs\t$s\n";
	}
}

 

Tadaa!


Here's the Perl script that splits the target but keeps the correct (reversed) order, so that the glossary can be merged again (Glossary > Merge alternative translations):

 

#!/usr/bin/perl

while (<>){
	chomp;
	($lhs, $rhs) = split /\t/;
	@targets = split /;/, $rhs;
	@targets = reverse @targets;
	foreach $s (@targets){
		print "$lhs\t$s\n";
	}
}

 

Now you can decompose your advanced glossaries, either from the source side or from the target side, or from both sides. After this, you can rearrange or modify the term pairs in any other way you like. And once you're satisfied, you can merge. The target side, that is. Currently there's no way to merge the source side (apart from swapping the source-side and target-side columns, of course).

Login to post a comment