Skip to content

Commit

Permalink
Fix synonym/antonym headers; correctly split synonyms/antonyms on commas
Browse files Browse the repository at this point in the history
  • Loading branch information
garfieldnate committed Jan 25, 2018
1 parent 0444d6d commit 60d869c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/convert_to_mac.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@
}

my $src;
my $src_name;
my $trg;
my $trg_name;
my $tag_names;
my $id_prefix;
if ($ARGV[0] eq 'en-th') {
$src = 'en';
$src_name = 'English';
$trg = 'th';
$trg_name = 'Thai';
$tag_names = get_tag_names('e', 't');
$id_prefix = 'etlex-';
} elsif ($ARGV[0] eq 'th-en') {
$src = 'th';
$src_name = 'Thai';
$trg = 'en';
$trg_name = 'English';
$tag_names = get_tag_names('t', 'e');
$id_prefix = 'telex-';
} else {
Expand Down Expand Up @@ -183,9 +189,9 @@ sub entry {
}

if($src_syns) {
my @synonyms = split /;\s*/, $src_syns->text;
my @synonyms = split /[;,]\s*/, $src_syns->text;
my $div = XML::Twig::Elt->new('div', {class => 'source-synonyms'});
XML::Twig::Elt->new("h4", {class => 'syns-header'}, 'Synonyms')->paste('first_child', $div);
XML::Twig::Elt->new("h4", {class => 'syns-header'}, "$src_name Synonyms")->paste('first_child', $div);
$div->paste('last_child', $el);
my $list = XML::Twig::Elt->new('ul');
$list->paste('last_child', $div);
Expand All @@ -196,9 +202,9 @@ sub entry {
$src_syns->delete;
}
if($trg_syns) {
my @synonyms = split /;\s*/, $trg_syns->text;
my @synonyms = split /[;,]\s*/, $trg_syns->text;
my $div = XML::Twig::Elt->new('div', {class => 'target-synonyms', lang => $trg});
XML::Twig::Elt->new("h4", {class => 'ants-header'}, 'Synonyms')->paste('first_child', $div);
XML::Twig::Elt->new("h4", {class => 'syns-header'}, "$trg_name Synonyms")->paste('first_child', $div);
$div->paste('last_child', $el);
my $list = XML::Twig::Elt->new('ul');
$list->paste('last_child', $div);
Expand All @@ -209,9 +215,9 @@ sub entry {
$trg_syns->delete;
}
if($ants) {
my @antonyms = split /;\s*/, $ants->text;
my @antonyms = split /[;,]\s*/, $ants->text;
my $div = XML::Twig::Elt->new('div', {class => 'antonyms'});
XML::Twig::Elt->new("h4", {class => 'syns-header'}, 'Antonyms')->paste('first_child', $div);
XML::Twig::Elt->new("h4", {class => 'ants-header'}, 'Antonyms')->paste('first_child', $div);
$div->paste('last_child', $el);
my $list = XML::Twig::Elt->new('ul');
$list->paste('last_child', $div);
Expand Down

0 comments on commit 60d869c

Please sign in to comment.