This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
forked from kukas/vallex3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml2html.pl
executable file
·1514 lines (1366 loc) · 60.8 KB
/
xml2html.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env perl
use strict;
use warnings;
use locale;
use POSIX qw(locale_h);
setlocale(LC_ALL,"cs_CZ.utf8");
# setlocale('LANG',"czech");
use utf8;
use JSON qw(encode_json);
# use encoding "utf-8";
binmode STDERR,":encoding(utf-8)";
binmode STDOUT,":encoding(utf-8)";
use XML::DOM;
use List::Util 1.33 'none';
#use Data::Printer colored => 1,max_depth => 8, show_tied => 1, class => {inherited => 'all', expand => 3}, caller_info => 0;
my ($VERB_MODE, $NOUN_MODE) =
$ENV{VERB_MODE} ? (1,0) :
$ENV{NOUN_MODE} ? (0,1) :
(1,0); # VERB_MODE is default
my $ADD_VALEVAL = 0;
# ------------------ initializing hint hashes ----------------------
my $xmlfile = shift;
my $xml2html_dir = shift;
my $version = shift;
my $outputdir = "$xml2html_dir/../vallex-$version/data/html/";
my %functor_comments = (
"ACT" => "actor",
"ADDR" => "addressee",
"PAT" => "patient",
"EFF" => "effect",
"ORIG" => "origin",
"DIFF" => "difference",
"OBST" => "obstacle",
"ACMP" => "accompaniement",
"AIM" => "aim",
"APP" => "appurtenance",
"AUTH" => "author",
"BEN" => "benefactive",
"CAUS" => "cause",
"COMPL" => "complement",
"CPHR" => "compound phraseme",
"CRIT" => "criterion/measure/standard",
"DIR" => "shortcut for DIR1 DIR2 DIR3",
"DIR1" => "direction-from",
"DIR2" => "direction-through",
"DIR3" => "direction-to",
"DPHR" => "dependent part of a phraseme",
"EXT" => "extent",
"HER" => "heritage",
"ID" => "identity",
"INTT" => "intent",
"LOC" => "locative",
"MANN" => "manner",
"MAT" => "material",
"MEANS" => "means",
"NORM" => "norm",
"RCMP" => "recompense",
"REG" => "regard",
"RESL" => "result",
"SUBS" => "substitution",
"TFHL" => "temporal-for-how-long",
"TFRWH" => "temporal-from-when",
"THL" => "temporal-how-long ",
"TOWH" => "temporal-to when",
"TSIN" => "temporal-since-when",
"TTILL" => "temporal-until-when",
"TWHEN" => "temporal-when"
);
my %type_of_compl = (
'opt' => 'type of complementation: optional',
'typ' => 'type of complementation: typical',
'obl' => 'type of complementation: obligatory'
);
my $border = 0;
my %long_attr_names = (
'class' => 'sem. class',
'frame' => 'val. frame',
);
my %long_form_types = (
'direct_case' => 'Direct cases',
'prepos_case' => 'Prepositional cases',
'subord_conj' => 'Subordinating conjunctions',
'cont' => 'Content clauses',
'infinitive' => 'Infinitive',
'adjective' => 'Constructions with adjectives',
'byt' => 'Constructions with "být" (to be)',
'phraseme_part' => 'Parts of phrasemes',
'possessive' => 'Possessive',
);
my %long_form_type = (
'direct_case' => 'direct case',
'prepos_case' => 'prepositional case',
'subord_conj' => 'subordinating conjunction',
'cont' => 'content clause',
'infinitive' => 'infinitive',
'adjective' => 'construction with an adjective',
'byt' => 'construction with "být" (to be)',
'phraseme_part' => 'part of a phraseme',
'possessive' => 'possessive',
);
my %case_names = (
'1' => 'nominative',
'2' => 'genitive',
'3' => 'dative',
'4' => 'accusative',
'5' => 'vocative',
'6' => 'locative',
'7' => 'instrumental',
);
my $bullet = "<img src='../../static/redbullet.gif'>";
use Readonly;
Readonly my $PDTVALLEX_URL => "http://lindat.mff.cuni.cz/services/PDT-Vallex/?verb=";
my ($multiframe,$template);
my %irrefl_mlemma;
# ----------------- pomocne funkce ----------------
# prevod arabskych cislic na rimske (zatim napraseno)
sub ara2roman ($) {
my ($cnt)=@_;
return join "",map {'I'} (1..$cnt);
}
# odstraní whitespace z obou stran stringu
sub trim {
my $s = shift;
$s =~ s/^\s+|\s+$//g;
return $s;
};
# nahradi znaky s diakritikou a prida za ne suffix (zatim jednosmerne!)
my %substitution;
my %subst_prefs;
sub string_to_html_filename {
my $orig=shift;
if (not $substitution{$orig}) {
my $subst_prefix;
my $subst_suffix = "";
if ($orig =~ /^lxm-v-(.{1,5}).*?$/) {
$subst_prefix = $1;
$subst_prefix =~ tr/áéíóúůýěžščřďťň/aeiouuyezscrdtn/;
$subst_prefix =~ s/[^a-zA-Z0-9-]/_/g;
$subst_suffix = ++$subst_prefs{$subst_prefix};
} else {
$subst_prefix = $orig =~ /^([^:]*).*$/s ? $1 : "";
$subst_prefix =~ tr/áéíóúůýěžščřďťňŽŠČŘĎŤŇ/aeiouuyezscrdtnZSCRDTN/;
$subst_prefix =~ s/^\s+//;
$subst_prefix =~ s/\s+$//;
$subst_prefix =~ s/, /-/; # control: ACT, PAT
$subst_prefix =~ tr/+ /-_/; # forms: mezi+4 do bot
$subst_prefix =~ s/[^a-zA-Z0-9_-]/./g;
$subst_prefix = "_" if !$subst_prefix;
if ($subst_prefs{$subst_prefix}) {
$subst_suffix = ++$subst_prefs{$subst_prefix};
} else {
$subst_prefs{$subst_prefix} = 1;
}
}
$substitution{$orig} = "$subst_prefix$subst_suffix";
}
return $substitution{$orig};
}
sub create_directory ($) {
my $directory_name = shift;
my $fullpath = $outputdir.$directory_name;
print STDERR "Creating directory $fullpath ...\n";
system "mkdir $fullpath -p";
}
my $javascript_head = '<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css"/>
<script type="text/javascript" src="../lexeme-entries/index.js"></script>
<script type="text/javascript" src="autocomplete.js"></script>';
my $HTML_noun_header = '<!DOCTYPE html>
<html>
<head>
<title>vallex '.$version.'</title>
<meta charset="utf-8">
<link rel="stylesheet/less" type="text/css" href="../../css/styles.less">
<script src="../../libs/less.min.js"></script>
<script src="../../libs/underscore-min.js"></script>
<script src="../../libs/jquery-2.1.4.min.js"></script>
<script src="../../libs/jquery.autocomplete.min.js"></script>
<script src="../../libs/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="../../libs/backbone-min.js"></script>
<script src="../../js/layout.js"></script>
<script src="../../js/filters.js"></script>
<script src="../../js/lexeme.js"></script>
<script src="../../js/router.js"></script>
<script src="../../js/app.js"></script>
</head>
<body>
<div class="dictionary" style="margin: 5em 25em">
<div class="wordentry">
';
my $HTML_noun_footer = "\n</div>\n</div>\n</body>\n</html>";
sub create_html_file ($$) {
my ($filename, $content)=@_;
$filename = $outputdir.$filename;
open F,">:encoding(utf-8)",$filename or die "!!!! Nelze otevrit $filename pro zapis\n";
print F $HTML_noun_header if $NOUN_MODE;
print F $content;
print F $HTML_noun_footer if $NOUN_MODE;
close F;
}
sub create_multiframe ($$$) {
my ($filename,$firstframelist,$firstentryfilename)=@_;
my $m=$multiframe;
$filename = $outputdir.$filename;
$m=~s/#framelist#/$firstframelist/;
$m=~s/#wordentry#/$firstentryfilename/;
# open F,">:encoding(utf-8)",$filename;
# open F,">:$filename";
# $filename=~s/^(..............................).+/$1/; #hack!!!! tady by mel byt poradny test
# print STDERR "Storing $filename ...\n";
open F,">:encoding(utf-8)",$filename or die "!!!! Nelze otevrit $filename pro zapis\n";
print F $m;
close F;
}
my $json_obj = JSON->new->utf8->canonical->pretty;
sub create_json_file ($$) {
my ($filename, $hash)=@_;
$filename = $outputdir.$filename;
my $json = $json_obj->encode($hash);
open F,">",$filename or die "!!!! Nelze otevrit $filename pro zapis\n";
print F $json;
close F;
}
sub questionmark ($) {
my ($label)=@_;
if ($label) {
return "<a href='../../../../doc/structure_en.html#sec:$label' target='_parent'><img border='0' src='../../static/questionmark.gif'></a>";
}
else {
return "<img border='0' src='../../static/questionmark.gif'>";
}
}
sub formnode2formtxt {
my ($formnode)=@_;
my $to_be = "";
if ($formnode->getAttribute('to_be')) { $to_be="být+" }
my $prep=$formnode->getAttribute('prepos_lemma');
$prep=~s/\_/ /g;
my $type=$formnode->getAttribute('type');
if ($type eq "direct_case") {
return [$to_be.$formnode->getAttribute('case')];
}
elsif ($type eq "prepos_case") {
return [$prep."+".$formnode->getAttribute('case')]
}
elsif ($type eq "subord_conj") {
return [$formnode->getAttribute('subord_conj_lemma')];
}
elsif ($type eq "adjective") {
my $prepos = $formnode->getAttribute('prepos_lemma');
$prepos = $prepos ? $prepos."+" : "";
return [$to_be.$prepos."adj-".$formnode->getAttribute('case')]
}
elsif ($type eq "infinitive") {
if ($prep) {$prep="$prep+";};
return [$prep.'inf'];
}
elsif ($type eq "cont") {
return ["cont"];
}
elsif ($type eq "phraseme_part") {
return [$formnode->getAttribute('phraseme_part')];
}
elsif ($type eq "possessive") {
return ["poss"];
}
else { print STDERR "Nerozeznana forma ($type)!\n"; return [''] }
}
my %framelist;
my %framecnt;
my %firstframefilename;
my %filtertree;
sub add_to_list ($$$) {
my ($crit,$value,$link)=@_;
return unless $value;
$framelist{$crit}{$value}.=$link;
$framecnt{$crit}{$value}++;
$link=~/href=\'([^']+)/;
$firstframefilename{$crit}{$value}=$1 unless $firstframefilename{$crit}{$value};
}
# přidá LU do filtrovacího stromu
# parametry:
# - index LU (v našem případě od 1 do n - pořadí v XML)
# - lexém (nejlépe unikátní id)
# - html string lexému - takový, jaký se bude zobrazovat na stránkách v seznamech
# - volitelný počet parametrů cesty ve stromu kritérií
sub unit_to_criteria {
my $lu_index = shift;
my $lexeme = shift;
my $headword_lemmas = shift;
my $tree = \%filtertree;
#warn "\n\@_ = ".np(@_);
my $add_this_unit_allnodes = @_<=1 || $_[1] ne 'reflexive lexemes';
foreach ( my $i = 0; $i < @_; $i++ ) {
my $node = $_[$i];
if(!exists ${${$tree}{"subfilters"}}{$node}){
${${$tree}{"subfilters"}}{$node} = {
"lexemes" => {},
"subfilters" => {}
};
}
$tree = ${${$tree}{"subfilters"}}{$node};
my $add_this_unit_thisnode =
! $add_this_unit_allnodes
&& $lu_index == 0 ? $node =~ m/lexeme/ : $node !~ m/lexemes/ ;
#$add_this_unit_allnodes || $add_this_unit_thisnode ? warn "ADD $lexeme-$lu_index ($headword_lemmas)"
# : warn "DON'T ADD $lexeme-$lu_index ($headword_lemmas)";
$tree->{"lexemes"}->{$lexeme . "-" . $lu_index} = [$lexeme, $lu_index, $headword_lemmas]
if $add_this_unit_allnodes or $add_this_unit_thisnode ;
}
}
# přidá lexém do filtrovacího stromu
# parametry:
# - id lexému
# - html string lexému
# - cesta ve stromu
sub lexeme_to_criteria {
unit_to_criteria (0, @_);
}
sub mlemma_2_string {
my ($mlemma, $homo_index) = @_;
my $mlemma_string = $mlemma;
if ($homo_index) {
$mlemma_string .= "<sub class='scriptsize'>".ara2roman($homo_index)."</sub>"
}
return $mlemma_string;
}
sub lexeme_or_blu_to_lemmas {
my ($higher_node) = @_;
my %asp2lemma;
my $globreflex = "";
foreach my $node (
grep {$_->getNodeType == ELEMENT_NODE}
map {$_->getChildNodes}
grep {$_->getNodeType == ELEMENT_NODE and $_->getTagName eq "lexical_forms"} $higher_node->getChildNodes) {
my $coindex = $node->getAttribute("coindex");
if ($node->getTagName eq "mlemma") {
# check whether this aspect is used in any LVC-LU
# if ($NOUN_MODE) {
# # FIXME: It doesn't expect mlemma_variants (as these are rare in noun data)
# my $is_used_in_lvc = 0;
# foreach my $blu ($higher_node->getElementsByTagName('nlu')) {
# next if !$blu; # in case it is called on blu, not on lexeme
# my $lex_forms = (grep {$_} $blu->getElementsByTagName('lexical_forms'))[0];
# if (scalar(grep {$_} $blu->getElementsByTagName('lvc')) # is LVC-LU
# && (!$lex_forms # either without limit
# || scalar( # or with specified aspect
# grep { $_->getAttribute('coindex') eq $coindex }
# $lex_forms->getElementsByTagName('mlemma')))) {
# $is_used_in_lvc = 1;
# }
# }
# next if !$is_used_in_lvc;
# }
my $refl = $node->getAttribute("optrefl") ? " (".$node->getAttribute("optrefl").")" : "##GLOBREFL##";
$asp2lemma{$coindex}
= [[$node->getFirstChild->getNodeValue . $refl, $node->getAttribute('homograph')]]; # TODO o dva radky niz je temer kopie
} elsif ($node->getTagName eq "mlemma_variants") {
$asp2lemma{$coindex}
= [ map {
my $refl = $_->getAttribute("optrefl") ? " (".$_->getAttribute("optrefl").")" : "##GLOBREFL##";
[$_->getFirstChild->getNodeValue . $refl, $_->getAttribute('homograph')]
} $node->getElementsByTagName('mlemma')];
} elsif ($node->getTagName eq "commonrefl") {
$globreflex = " ".$node->getFirstChild->getNodeValue;
} else {
print STDERR "Necekany tagname: ".$node->getTagName()."\n";
}
}
foreach my $coindex (keys %asp2lemma) {
foreach my $lemma (@{$asp2lemma{$coindex}}) {
$lemma->[0] =~ s/##GLOBREFL##/$globreflex/g; # replace placeholder by (possibly empty) $globreflex
}
}
return %asp2lemma;
}
sub coindex_sort { # (temer) kopie z txt2xml_b.pl
local $_ = shift;
my $n = $1 if s/(\d*)$//;
s/^biasp$/b$n/;
s/^pf/c$n/;
s/^impf/a$n/;
s/^iter/d$n/;
return $_;
}
sub lexeme_node_2_headwords {
my ($aspect2lemma_ref, $with_aspect) = @_;
my @headwords;
foreach my $coindex (sort {coindex_sort($a) cmp coindex_sort($b)} keys %$aspect2lemma_ref) {
my @lemmas = @{$aspect2lemma_ref->{$coindex}};
push( @headwords,
join("/", map {mlemma_2_string(@{$_})} @lemmas)
. ($VERB_MODE && $with_aspect ? "<sup class='scriptsize'>$coindex</sup>" : "")
);
}
return [@headwords];
}
# Returns HTML string with links from lemmas (in this lexeme) to PDT-Vallex
sub pdtvallex_word_links {
my $lexeme_node = shift;
my %coindexed_lemmas = @_;
my $wlink_string;
# Go through all aspects
foreach my $wlink ($lexeme_node->getElementsByTagName('wlink')) {
my @lemmas = @{$coindexed_lemmas{$wlink->getAttribute('coindex')}};
my $lemma;
if (@lemmas > 1) { # if there are more variants
$lemma = $wlink->getAttribute('variant'); # the proper one is specified
} else {
$lemma = $lemmas[0]->[0]; # the only one -> 'lemma' from (lemma, homo)
}
my $url_lemma = $lemma;
$lemma =~ s/\ / /x; # keep reflexive verbs on one line together
$url_lemma =~ s/\ /+/x;
$wlink_string .=
"<li><a href='$PDTVALLEX_URL$url_lemma' target='_blank' class='external'>"
. "<span>$lemma</span>"
. "<div class='arrow'>></div></a></li>";
}
if($wlink_string){
return "<div class='pdtvallex-box'>"
. "<a class='expander'>"
. "<span>PDT-Vallex</span>"
. "<div class='arrow'>></div>"
. "</a>"
. "<ul class='pdt-links' style='display: none;'>$wlink_string</ul>"
. "</div>";
}
else {
return "";
}
}
# INPUT: HTML string like aktualizovat<sup class='scriptsize'>biasp</sup>
# moci/moct<sup class='scriptsize'>impf</sup>
# patřit<sub class='scriptsize'>II</sub><sup class='scriptsize'>impf</sup>
# dožít<sub class='scriptsize'>II</sub>/dožnout<sup class='scriptsize'>pf</sup>
# OUTPUT: hash biasp => ( (aktualizovat,'') )
# impf => ( (moci,''), (moct,'') )
# impf => ( (patřit,'II') )
# pf => ( (dožít,'II'), (dožnout,'') )
sub get_coindexed_hash {
my @headwords_html = @{shift()};
my %coindexed;
return if $NOUN_MODE;
foreach my $headword_html (@headwords_html) {
# $coindexed{$2} = $1 if $headword_html =~ /^ ([^<>]+) <sup\ class='scriptsize'> ([^<>]+) <\/sup> $/x;
my $asp = $1 if $headword_html =~ s/<sup\ class='scriptsize'> ([^<>]+) <\/sup> $//x;
$headword_html =~ s/([^<])\//$1|/g; # HTML slashes remain -- variant slashes changed into pipes
my @lemma_variants = map { /^ ([^<>]+) (?:<sub\ class='scriptsize'>([IV]+)<\/sub>)? $/x; [$1,$2]} split(/\|/, $headword_html);
$coindexed{$asp} = \@lemma_variants;
}
return %coindexed;
}
# Returns HTML string with examples from VALEVAL: one line for each aspect, <br/> between lines
my %valeval_frames;
sub create_links_to_valeval {
my $frame_num = shift;
my $filename = shift;
my $lexeme_id = shift;
my $only_one_aspect = shift;
my %coindexed_lemmas = @_;
my @return;
my %sortasp = (impf=>1, impf1=>2, impf2=>3, pf=>4, pf1=>5, pf2=>6, biasp=>7, iter=>8, iter1=>9, iter2=>10);
my @aspects = sort {$sortasp{$a}<=>$sortasp{$b}} keys(%coindexed_lemmas);
foreach my $asp (@aspects) {
my @variants = @{$coindexed_lemmas{$asp}};
my $var = (@variants > 1) ? 0 : undef();
foreach my $lemma (@variants) {
my $lemma_stem = $lemma->[0];
my $homo = $lemma->[1];
$var++ if defined($var);
my $lemma_full = $lemma_stem . ($homo ? "-$homo" : "");
$lemma_full =~ s/ /_/g;
my $excerpt = get_valeval_excerpt(\$lemma_full, $frame_num);
next if $excerpt eq "0" or $excerpt eq "-1"; # no occurence of a frame or of a verb at all
# The frame is used in VALEVAL
my $line = (@aspects > 1 and !$only_one_aspect ? " <span class='scriptsize'>$asp:</span> " : "" ) .
"<a href=\"generated/cnk/$lemma_full.html#$frame_num\" target=\"_blank\">" . $excerpt . "</a>";
push(@return, $line);
my $headword = $lemma_stem . ($homo ? "<sub class='scriptsize'>$homo</sub>" : "");
push(@{$valeval_frames{$headword}}, "<a target='wordentry' href='../lexeme-entries/$filename#$frame_num'>$bullet $headword <span class='scriptsize'>$frame_num</span></a><br>");
# Output lexeme's ID (it will be used to prune VALLEX XML and get smaller one only with those lexemes used in VALEVAL
print(Pruned_IDs "$lexeme_id-$asp",
$var ? "-".("", "A","B","C","D")[$var] : "",
"\n");
}
}
return join("<br/>", @return);
}
sub get_valeval_excerpt {
my $lemma = shift;
my $filename = create_correct_filename($lemma);
return -1 if !$filename; # "no occurence of this verb in CNK"
my $frame_num = shift;
open(CNK, "<encoding(utf-8)", $filename)
or die("Can't open HTML $filename with VALEVAL examples.\n");
my $nalezen_ramec = 0;
my $nalezena_veta = 0;
my $sentence = "empty";
while (<CNK>) {
if ($nalezena_veta) {
# $sentence = <CNK>;
$sentence = $_;
last;
}
$nalezena_veta = 1 if $nalezen_ramec and /<td class="sentences" title="example sentence">/;
$nalezen_ramec = 1 if /<a name="$frame_num"/;
}
return 0 if $sentence eq "empty"; # no occurence of this frame
$sentence =~ s/<a href=["'][^"']+["']>//g; # ged rid of href start tag
$sentence =~ s/^.*?( .{1,40}:\d+<\/a>)/…$1/ # trim beginning
if $sentence =~ /^.*(.{60}:\d+<\/a>)/; # if too long
$sentence =~ s/:\d+<\/a>(.{1,50} ).*/$1…/ # trim end
if $sentence =~ /:\d+<\/a>(.{70}).*/; # if too long
$sentence =~ s/:\d+<\/a>//g; # ged rid of href closing tag
$sentence =~ s/<\/a>//g; # href of reflexive particles
$sentence =~ s/^\s+//; # leading spaces
$sentence =~ s/\s+$//; # trailing newline
my $more = ""; # is there more than one example for this frame?
while (<CNK>) {
last if /<table class="examples">/; # next frame
if (/<td class="sentences"/) { # next sentences for the same frame
$more = " <span style=\"font-size:6pt\">(more…)</span>";
last;
}
}
close(CNK);
return $sentence . $more;
}
sub create_correct_filename {
my $lemma = shift;
$$lemma =~ s/-III/-3/;
$$lemma =~ s/-II/-2/;
$$lemma =~ s/-I/-1/;
if (!-f cnk_filename($$lemma)) {
if (-f cnk_filename($$lemma."-1")) {
$$lemma .= "-1";
return cnk_filename($$lemma);
} elsif ($$lemma =~ /-1/ or $$lemma =~ /_se-[23]/) {
my $lemma_without = $$lemma;
$lemma_without =~ s/-[123]//;
if (-f cnk_filename($lemma_without)) {
$$lemma = $lemma_without;
return cnk_filename($$lemma);
}
return 0; # "no occurence of this verb in CNK"
} elsif ($$lemma =~ /zachy/ and cnk_filename($$lemma."-2")) {
$$lemma .= "-2";
return cnk_filename($$lemma);
} else {
return 0; # "no occurence of this verb in CNK"
}
}
return cnk_filename($$lemma);
}
sub cnk_filename {
return "vallex-$version/data/html/generated/cnk/$_[0].html";
}
# -------------------------------- MAIN ----------------------
print STDERR "Copying non-generated (static) files ...\n";
system "mkdir -p $outputdir/";
# open IIN,"$xml2html_dir/index.html" or die "Can't open html index\n";
# open IOUT,">:encoding(utf-8)","$outputdir/index.html";
# s/#version#/$version/g, print IOUT while <IIN>; # copy s jednou substituci
# close IIN;
# close IOUT;
system "cp -r $xml2html_dir/static/* $outputdir/"; # je potreba vyhnout se kopirovan .svn
print STDERR "Loading $xmlfile...\n";
my $parser = XML::DOM::Parser->new();
my $doc = $parser->parsefile($xmlfile);
my ($version_xml) = map {$_->getFirstChild->toString}
$doc->getElementsByTagName('version');
if ( $version ne $version_xml ) {
if ( $version."test" ne $version_xml) {
die "The given XML has different version ($version_xml) than requested VALLEX $version\n";
} else {
warn "The given XML has different version ($version_xml) than requested VALLEX $version\n";
}
}
my %type_of_form;
my %htmlized_lexeme_entry;
print STDERR "Transforming lexemes into HTML and their classification according to sorting criteria ...\n";
foreach my $lexeme_node ($doc->getElementsByTagName('lexeme')) {
my @refl = $lexeme_node->getElementsByTagName('commonrefl');
# print "REFL: @refl\n";
# exit;
if (@refl == 0) {
# print "Nonrefl\n";
foreach my $mlemma_node ($lexeme_node->getElementsByTagName('mlemma')) {
my $mlemma = $mlemma_node->getFirstChild->getNodeValue;
my $homo_index = $mlemma_node->getAttribute('homograph');
$irrefl_mlemma{$mlemma.$homo_index} = 1;
# print "IRREFL: $mlemma.$homo_index\n";
}
}
}
my %autocomplete_lemma2filename;
my $pruned_IDs_file = $xmlfile;
$pruned_IDs_file =~ s/\/[^\/]+$/\/pruned_IDs.txt/;
$pruned_IDs_file =~ s/(?:\.xml)?$/_pruned_IDs.txt/ if $pruned_IDs_file eq $xmlfile;
open(Pruned_IDs, ">:encoding(utf-8)", $pruned_IDs_file)
or die("Cannot open $pruned_IDs_file for writing.\n");
foreach my $lexeme_node ($doc->getElementsByTagName('lexeme')){
my $filename = string_to_html_filename($lexeme_node->getAttribute('id'));
my %global_aspect = lexeme_or_blu_to_lemmas($lexeme_node); # global == for lexeme
#next if $NOUN_MODE && !%global_aspect; # no lemma in this lexeme is used in LVC
my $headwords_rf = lexeme_node_2_headwords(\%global_aspect, 0);
foreach my $headword_string (map {split(/\//, $_)} map {$_ =~ s/<.+?>//g; $_} map {$_} @$headwords_rf) {
$autocomplete_lemma2filename{$headword_string} = $filename;
}
my $headword_lemmas = join ", ",@$headwords_rf;
my $headwords_rf_with_aspect = lexeme_node_2_headwords(\%global_aspect, 1);
my $headword_lemmas_table= join ", ",@$headwords_rf_with_aspect; # doplnit vyrobeni tabulek
my $link_to_word = "<a target='wordentry' href='../lexeme-entries/$filename'>$bullet $headword_lemmas</a><br>\n";
my %coindexed_lemmas = get_coindexed_hash($headwords_rf_with_aspect);
my $pdtvallex_word_links = pdtvallex_word_links($lexeme_node, %coindexed_lemmas);
lexeme_to_criteria($filename, $headword_lemmas, "all");
my ($lexical_forms) = $lexeme_node->getElementsByTagName('lexical_forms');
my $aspect_combination = join "+",sort grep {!/iter/} grep {$_} keys %global_aspect;
lexeme_to_criteria($filename, $headword_lemmas, "lexemes", "aspect", $aspect_combination);
my @variants = $lexeme_node->getElementsByTagName('mlemma_variants');
if (@variants > 0) {
lexeme_to_criteria($filename, $headword_lemmas, "lexemes", "variants");
}
$htmlized_lexeme_entry{$filename} .= "<div class='wordentry_header'>$pdtvallex_word_links\n <div class='headword'>$headword_lemmas_table</div>\n</div>\n";
# "<td>
# <span class='headword_aspect'> <a title='aspect' href='../aspect/index-$aspect.html' target='_parent'>$aspect.</a></span></table><br>\n";
my $homographs = grep {$_->getAttribute('homograph') } $lexeme_node->getElementsByTagName('mlemma');
if ($homographs) {
lexeme_to_criteria($filename, $headword_lemmas, "lexemes", "homographs");
}
my $complexity = $#{[$lexeme_node->getElementsByTagName('lu_cluster')]}+1;
$complexity .= $complexity > 1 ? " LUs" : " LU"; # přidá jednotné/množné číslo LU
lexeme_to_criteria($filename, $headword_lemmas, "lexemes", 'complexity', $complexity);
my $frame_index;
my $htmlized_frame_entries = "";
foreach my $blu_node (
# We need to keep order of mixed <blu> and <llu> elements
grep { $_->getNodeName() =~ /^[bln]lu$/ }
map { $_->getChildNodes() }
$lexeme_node->getElementsByTagName('lexical_units')->[0]->getElementsByTagName('lu_cluster')
) {
# Previously we wanted to take all <blu> in XML order and then all <llu>:
# $lexeme_node->getElementsByTagName('blu'),
# $lexeme_node->getElementsByTagName('llu')) {
$frame_index ++;
my $id = $blu_node->getAttribute('id');
warn( "ERROR: Non-sequential IDs? $id / ",
$blu_node->getAttribute('web_id'), " : $frame_index\n")
if $frame_index != $blu_node->getAttribute('order');
if ($NOUN_MODE && !grep {$_} $blu_node->getElementsByTagName('lvc')) {
$htmlized_frame_entries .=
" <table class='lexical_unit u$frame_index' data-id='".$frame_index."'>\n".
" <tr>\n".
" <td class='lexical_unit_index'>".
"<a href='#/lexeme/$filename/$frame_index' title='$id' class='frame_index_link circle'>$frame_index</a></td>\n".
" <td colspan='3' class='gloss_header'><i>This lexical unit does not participate in any LVC…</i></td>\n".
" </tr>\n".
" </table>\n";
next;
}
# ------ html link na ramec do vyhledavacich tabulek
my $link_to_frame = "<a target='wordentry' href='../lexeme-entries/$filename\#$frame_index'>$bullet $headword_lemmas <span class='scriptsize'>$frame_index</span></a><br>\n";
my $limited_lex_forms = "";
my @blu_coindexes;
my %local_aspect;
if ( @{[$blu_node->getElementsByTagName('lexical_forms')]}>0 # omezeni forem, pro nez LU plati
&& ($VERB_MODE || @$headwords_rf>1) # nemam-li jmenny lexem s jedinou f.
) {
%local_aspect = lexeme_or_blu_to_lemmas($blu_node); # local == for LU
my $blu_headwords_rf = lexeme_node_2_headwords(\%local_aspect, 1);
$limited_lex_forms = "limit <span class='gloss'>".(join ", ",@$blu_headwords_rf)."</span><br>";
@blu_coindexes = keys %local_aspect;
# print(STDERR @blu_coindexes ? "lokalni: @blu_coindexes\n" : "lokalni prazdno\n");
} else {
%local_aspect = %global_aspect;
@blu_coindexes = (keys %coindexed_lemmas);
# print(STDERR @blu_coindexes ? "globalni: @blu_coindexes\n" : "globalni prazdno\n");
}
# ---------- load the frame attributes
my %frame_attrs;
# tady se musi pridat rozdeleni na dok: %???% /ned: %...%
foreach my $attrname ('example','gloss','control','class','reflex','diat','alter','recipr','links','lvc', 'instigator', 'functor_mapping', 'reciprverb', 'reflexverb') {
if ($blu_node->getElementsByTagName($attrname)->item(0)) {
eval {
foreach my $attr_node ($blu_node->getElementsByTagName($attrname)) {
my $attribute_coindex = ( $blu_node->getTagName eq 'llu'
and $attrname =~ m/^(lvc|functor_mapping|instigator|example)$/
) ? ($attr_node->getAttribute('lvc_coindex') or 0)
: undef();
#warn "============================\n\$attrname = $attrname\n\$attribute_coindex = $attribute_coindex"; #\n\$attr_node = ".np($attr_node)."
if ($attrname=~/^(control|class)$/) {
unit_to_criteria($frame_index, $filename, $headword_lemmas, $attrname, trim($attr_node->getFirstChild->getNodeValue));
} elsif ($attrname eq 'alter') {
my $type = $attr_node->getAttribute('type');
my $subtype = $attr_node->getAttribute('subtype');
my $primary = $attr_node->getAttribute('primary');
my $locatum = $attr_node->getAttribute('locatumtype');
$locatum = $locatum ? " ($locatum)" : "";
my $primary_mark = "<span class='primary-mark'>" # FIXME moc velke, odstrkuje radku
. ($primary ? "Ⅰ." : "Ⅱ.") . "</span>";
my $LU_ref = $attr_node->getElementsByTagName('flink')->[0]->getAttribute('web_frame_id');
my $LU_ref_index = $1 if $LU_ref =~ /^w-blu-v-.+-(\d+)$/; # same as getAttribute("order");
if (!$LU_ref_index) {
warn("*** Unrecognized ID of a counterpart of lexical alternation: $LU_ref\n");
$LU_ref_index = 'N';
}
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'alternation', 'lexicalized', $type, $subtype.$locatum);
my $url_type = string_to_html_filename($type);
my $url_subtype = string_to_html_filename($subtype.$locatum);
$frame_attrs{$type} .= "<table cellspacing='0' cellpadding='0'>\n"
. "<tr><td><a href='#/filter/alternation/lexicalized/$url_type/$url_subtype'>$subtype$locatum</a>: $primary_mark </td>\n"
. "<td><a href='#/lexeme/$filename/$LU_ref_index' class='circle small'>$LU_ref_index</a> <a href='grammar.html#sec-sect-$type' class='rule-link'>rule</a></td><tr>\n"
. "</table>";
} elsif ($attrname eq 'diat') {
my $type = $attr_node->getAttribute('type');
if ($attr_node->getAttribute('value') eq 'no') {
# add_to_list("diat","$type NO",$link_to_frame);
} elsif ($attr_node->getAttribute('value') eq 'yes') {
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'alternation', 'grammaticalized', 'diathesis', "$type");
if ($frame_attrs{diat}) {$frame_attrs{diat} .='<br>'}
my %subtypes;
if ( my @coindexed = $attr_node->getElementsByTagName('coindexeddiat') ) {
foreach my $coindexed (@coindexed) {
if ( $coindexed->getAttribute('coindex') ) {
foreach my $example ( $coindexed->getElementsByTagName('diatexample') ) {
$subtypes{$example->getAttribute('subtype')} .= " <span class='scriptsize'>".$coindexed->getAttribute('coindex').":</span> ".$example->getFirstChild->getNodeValue;
}
} else {
foreach my $example ( $coindexed->getElementsByTagName('diatexample') ) {
$subtypes{$example->getAttribute('subtype')} .= $example->getFirstChild->getNodeValue;
}
}
}
} elsif ( my @examples = $attr_node->getElementsByTagName('diatexample') ) {
foreach my $example (@examples) {
$subtypes{$example->getAttribute('subtype')} .= $example->getFirstChild->getNodeValue;
}
}
foreach my $subtype (sort keys %subtypes) {
$subtypes{$subtype} =~ s@( <span class='scriptsize'>(impf|pf|iter|biasp)[12]?:</span>)(.*)\g1@$1$3@gs;
$subtypes{$subtype} =~ s/\s+$//; # trailing whitespace removed -> semicolon can be appended
}
# $type --> $subtype
# poss-result --> (poss-result-conv poss-result-nconv poss-result-both)
# deagent --> (deagent deagent0)
# passive --> passive / or YES
# recipient --> recipient / or YES
warn("ERROR: Possessive resultative without a subtype: $headword_lemmas LU$frame_index\n") if $type eq "poss-result" and !%subtypes;
warn("ERROR: Deagentisation without a subtype: $headword_lemmas LU$frame_index\n") if $type eq "deagent" and !%subtypes;
warn("ERROR: Subtype not allowed for $type diathesis: $headword_lemmas LU$frame_index\n") if $type ne "poss-result" and $type ne "deagent" and %subtypes and (keys(%subtypes) > 1 or !$subtypes{$type});
# TODO predchozi chyby kontrolovat hlavne v prevodu do XML ci v testech dat
if ($type eq 'poss-result') {
$frame_attrs{'diat'} .=
join('<br/>',
map {
my $adjusted_subtype = $_;
$adjusted_subtype =~ s@-(n?conv|both)@<sub>$1</sub>@;
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'alternation', 'grammaticalized', 'diathesis', $type, $adjusted_subtype);
"<a href='#/filter/alternation/grammaticalized/diathesis/$type/$_' class='valuename'>$adjusted_subtype</a>".$subtypes{$_}
} sort keys(%subtypes));
} elsif (%subtypes) {
$frame_attrs{'diat'} .= "<a href='#/filter/alternation/grammaticalized/diathesis/$type' class='valuename'>$type</a>";
# Only one possible subtype for "passive" and "recipient"
# and both possible subtypes for "deagent" should be merged
# TODO aspects are not merged properly (original "deagent impf pf deagent0 impf pf" -> "deagent impf pf impf pf")
$frame_attrs{'diat'} .= join('; ', map {$subtypes{$_}} sort keys(%subtypes));
} else {
$frame_attrs{'diat'} .= "<a href='#/filter/alternation/grammaticalized/diathesis/$type' class='valuename'>$type</a> YES";
}
} else {
print STDERR "Unexpected value of 'value' in a diathesis node.";
}
} elsif (my $type = $attr_node->getAttribute('type')) {
if ($frame_attrs{$attrname} and not ref($frame_attrs{$attrname}) eq 'ARRAY' ) {
$frame_attrs{$attrname} .='<br>'
}
my $url_type = string_to_html_filename($type);
if ($attrname eq 'reflex') {
$attribute_coindex = ( $attr_node->getAttribute('reflex_coindex') or 0);
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'alternation', 'grammaticalized', 'reflexivity', $type);
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'reflexivity', $type);
$frame_attrs{$attrname}->[$attribute_coindex] .= "<a href='#/filter/alternation/grammaticalized/reflexivity/$url_type' class='valuename'>$type</a> ";
} elsif ($attrname eq 'recipr') {
$attribute_coindex = ( $attr_node->getAttribute('recipr_coindex') or 0);
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'alternation', 'grammaticalized', 'reciprocity', $type);
#unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'reciprocal verbs');
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'reciprocity', $type);
$frame_attrs{$attrname}->[$attribute_coindex] .= "<a href='#/filter/alternation/grammaticalized/reciprocity/$url_type' class='valuename'>$type</a> ";
} elsif ($attrname eq 'reciprverb') { ## TODO: we are relying on the xml containing reciprverb only for inherently reciprocal verbs
$attribute_coindex = ( $attr_node->getAttribute('recipr_coindex') or 0);
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'inherently reciprocal verbs');
$frame_attrs{$attrname}->[$attribute_coindex] .= "<a href='#/filter/alternation/grammaticalized/reciprocity/$url_type'>$type</a>";
} elsif ($attrname eq 'reflexverb') {
if ($type eq 'tantum') {
lexeme_to_criteria($filename, $headword_lemmas, 'lexemes', 'reflexive lexemes', 'reflexive tantum lexemes');
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'lexemes', 'reflexive lexemes', 'reflexive tantum lexemes', 'reflexive tantum LUs');
lexeme_to_criteria($filename, $headword_lemmas, 'reflexivity and reciprocity', 'reflexive lexemes', 'reflexive tantum lexemes');
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'reflexive lexemes', 'reflexive tantum lexemes', 'reflexive tantum LUs');
$frame_attrs{$attrname} .= "<a href='#/filter/reflexivity_and_reciprocity/reflexive_lexemes/reflexive_tantum_lexemes'>$type</a> ";
} else {
lexeme_to_criteria($filename, $headword_lemmas, 'lexemes', 'reflexive lexemes', 'derived reflexive lexemes');
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'lexemes', 'reflexive lexemes', 'derived reflexive lexemes', $type);
lexeme_to_criteria($filename, $headword_lemmas, 'reflexivity and reciprocity', 'reflexive lexemes', 'derived reflexive lexemes');
unit_to_criteria($frame_index, $filename, $headword_lemmas, 'reflexivity and reciprocity', 'reflexive lexemes', 'derived reflexive lexemes', $type);
$frame_attrs{$attrname} .= "<a href='#/filter/reflexivity_and_reciprocity/reflexive_lexemes/derived_reflexive_lexemes/$url_type'>$type</a> ";
}
} else { ## $type = $attr_node->getAttribute('type') and $atttrname !~ reflex|recipr|reciprverb|reflexverb
$frame_attrs{$attrname} .= "$type: ";
}
} elsif ($attrname eq 'links') {
my $last_limit = '';
foreach my $flink_node ($attr_node->getElementsByTagName('flink')) {
my $coindex = $flink_node->getAttribute('coindex');
my $pdtvallex_id = $flink_node->getAttribute('frame_id');
my $variant = $flink_node->getAttribute('variant');
my $weight = $flink_node->getAttribute('weight');
my $lemma = $variant ? $variant : join('/', map {$_->[0]} @{$local_aspect{$coindex}}); # TODO kdyby se fakt pouzilo /, je to chyba
$lemma =~ s/\ /+/xg;
# Rounding (2 decimal places)
$weight += 0.005; # plus half
$weight =~ s/,(..).*$/.$1/; # trunk
$weight += 0; # remove trailing zeros
$weight =~ s/,/./; # point instead of comma
my $limit = '';
# kdyz je nutne rozlisovat, ktery z vidu platnych pro danou LU to je,
# protoze neiterativnich je vic -- a nebo je toto dokonce iterativum
if ((grep {$_ !~ /^iter/} @blu_coindexes) > 1 or $coindex =~ /^iter/) {
$limit = $coindex;
}
$limit = $limit ? "$limit, $variant" : $variant if $variant;
if ($limit eq $last_limit) {
$limit = '';
} else {
$last_limit = $limit;
}
$frame_attrs{'PDT-Vallex'} .=
($limit ? " <span class='scriptsize'>$limit:</span> " : '')
. "<a href='$PDTVALLEX_URL$lemma#$pdtvallex_id' target='_blank'>$pdtvallex_id</a> "
. "<span style='font-size:xx-small'>($weight)</span>\n";
}
}
my @coindexed = $attr_node->getElementsByTagName('coindexed');
if (@coindexed) {
my $sep = '';
foreach my $node (@coindexed) {
my $node_value
= "$sep"
. ($VERB_MODE ?
"<span class='scriptsize'>"
. $node->getAttribute('coindex')
. ':</span> '
: '')
. $node->getFirstChild->getNodeValue;
if ( defined($attribute_coindex) ) {
#warn "-----------------\n\$attribute_coindex = $attribute_coindex\n\$frame_attrs{$attrname} = ".np($frame_attrs{$attrname})."\n\$node_value = $node_value";
$frame_attrs{$attrname}->[$attribute_coindex] .= $node_value;
} else {
$frame_attrs{$attrname} .= $node_value;
}
$sep = ' ';
}
} else { ## not @coindexed
if (my $the_only_child = $attr_node->getFirstChild) {
my $trimmed_value = trim($the_only_child->getNodeValue);
if($attrname=~/^(control|class)$/){
my $url_value = string_to_html_filename($trimmed_value);
$frame_attrs{$attrname} .= "<a href='#/filter/$attrname/$url_value'>$trimmed_value</a>";
} else { ## $attrname !~ control|class
my $node_value = $the_only_child->getNodeValue;
$node_value =~ s/^\s+//;
$node_value =~ s/\s+$//;
if ( $attrname eq 'lvc' ) {
$node_value = join(', ',
map {
if (/^blu-n-(.*-\d+)$/) {
my $noun = $1;
my $noun_lexeme = 'lxm-n-' . $noun;
$noun_lexeme =~ s/-\d+//;
"<a href='generated/lexeme-entries/"
. string_to_html_filename($noun_lexeme)
. ".html' target='_blank'>$noun</a>";
} elsif (/\|/) {
';';
} else {
"<span class='one-verb-noun'>$_</span>"; # TODO no specification for this class, yet
}
}
grep { $_ }
split(/\s+/, $node_value));
$node_value =~ s/^;,//; # lvc: | noun noun -> ;, noun, noun
$node_value =~ s/, ;,/;/; # lvc: noun1 noun1 | noun -> noun1, noun1, ;, noun
} elsif ( $attrname eq 'reflexverb' and $attr_node->getElementsByTagName('flink')) {
my $LU_ref = $attr_node->getElementsByTagName('flink')->[0]->getAttribute('web_frame_id');
my ($LU_ref_lexeme, $LU_ref_index) = ($1,$2) if $LU_ref =~ /^w-blu-v-(.+)-(\d+)$/; # same as getAttribute("order");
#my %aspect = lexeme_or_blu_to_lemmas($doc-> TODO: get structure corresponding to $LU_ref_real_id);
#my $headwords_rf = lexeme_node_2_headwords(\%aspect, 1);
#my $LU_ref_lex_forms = "<span class='gloss'>".(join ", ",@$headwords_rf)."</span>";
$node_value .= "<a href='#/lexeme/".string_to_html_filename("lxm-v-$LU_ref_lexeme")."/$LU_ref_index'>$LU_ref_lexeme <span class='circle small'>$LU_ref_index</span></a></td><tr>\n";