-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBX_to_HTML.py
1101 lines (939 loc) · 40.2 KB
/
TBX_to_HTML.py
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/python3
import os # Betgriebssystem-spezifische Funktionen
import xml.etree.ElementTree as ET # Verarbeitung von XML-Daten
import tkinter as tk # GUI-Bibliothek
from tkinter import filedialog # Dateidialog-Funktionalität
from datetime import datetime # Datumsanzeige
import webbrowser
from tkinter import *
from tkinter.ttk import * # Für Links in tkInter benötigt
class ScrollableFrame(tk.Frame):
# Klasse für ein scrollbares Frame in der Gui
def __init__(self, master, **kwargs):
tk.Frame.__init__(self, master, **kwargs)
# Canvas für Scrollbar erstellen
self.canvas = tk.Canvas(self, borderwidth=0, background="#ffffff")
self.frame = tk.Frame(self.canvas, background="#ffffff")
self.vsb = tk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)
# Widgets anordnen
self.vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window((4, 4), window=self.frame, anchor="nw", tags="self.frame")
# Event-Handler für Größenänderungen
self.canvas.bind("<Configure>", self.on_canvas_configure)
# Scrollable Frame
self.scrollable_frame = tk.Frame(self.frame, background="#ffffff")
self.scrollable_frame.pack(fill="both", expand=True)
# Event-Handler: Canvas-Größe ändern
def on_canvas_configure(self, event):
# Scrollable Frame an die Größe des Canvas anpassen
canvas_width = event.width
self.canvas.itemconfig("self.frame", width=canvas_width)
def open_github(event):
webbrowser.open_new("https://github.com/W45P85/TBX_to_HTML")
def read_tbx(file_path, selected_columns):
# Funktion zum Lesen einer TBX-Datei und Extrahieren von Daten
tree = ET.parse(file_path)
root = tree.getroot()
term_dict = {}
# Schritt 1: Durchlaufe jeden termEntry-Eintrag
for entry in root.findall(".//termEntry"):
concept_id = entry.get("id")
lang_sets = entry.findall(".//langSet")
terms_info = []
# Schritt 2: Iteriere über alle <langSet> Tags unter dem aktuellen <termEntry>
for lang_set in lang_sets:
language = lang_set.get("{http://www.w3.org/XML/1998/namespace}lang", "")
# Schritt 3: Iteriere über alle <termGrp> Tags unter dem aktuellen <langSet>
for term_grp in lang_set.findall(".//termGrp"):
term_info = {"term": "", "notes": {}, "language": language}
# Schritt 4: Iteriere über alle <term> Tags unter dem aktuellen <termGrp>
term = term_grp.find(".//term")
if term is not None:
term_info["term"] = term.text
# Schritt 5: Füge die Daten aus <termNote> Tags hinzu
for term_note in term_grp.findall(".//termNote"):
note_type = term_note.get("type")
note_value = term_note.text
term_info["notes"][note_type] = note_value
terms_info.append(term_info)
# Schritt 6: Füge das Dictionary zum Dict hinzu
if concept_id and terms_info:
term_dict[concept_id] = terms_info
return term_dict
# Funktion zum Konvertieren von TBX in HTML
def convert_tbx_to_html(file_path, html_file_path, selected_columns):
term_dictionary = read_tbx(file_path, selected_columns)
date = datetime.now().date()
# Ersetze die alten Spaltennamen durch die neuen
new_column_names = {
'normativeAuthorization': 'Usage',
'Benennungstyp|String': 'Term type',
'Wortklasse|String': 'Word class',
'Genus|String': 'Gender',
'Definition|String': 'Definition',
'Quelle|String': 'Source',
'Anmerkung|String': 'Additional note',
'Kontextbeispiel|String': 'Context example',
'Termset|String': 'Term set'
}
# HTML-Inhalt erstellen
html_content = f"""
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TBX in HTML konvertiert</title>
<style>
.tooltip {{
position: relative;
}}
.tooltip .tooltiptext {{
visibility: hidden;
width: auto;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 10000;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}}
.tooltip:hover .tooltiptext {{
visibility: visible;
opacity: 1;
}}
body {{
font-family: 'Poppins', 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-color: #f8f9fa;
margin: 0;
text-align: center;
padding: 20px;
}}
.container {{
max-width: 1140px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}}
header {{
text-align: left;
display: flex;
width: 100%;
align-items: center;
background-color: #000000;
padding: 10px 20px;
color: white;
border-radius: 10px 10px 0 0;
}}
img {{
max-width: 150px;
padding: 5px;
border-radius: 8px;
}}
h1 {{
margin: 0px;
font-size: 2rem;
padding-left: 10px;
}}
h1_legende {{
font-weight: 600;
font-size: 2rem;
}}
h2 {{
color: #343a40;
text-align: center;
font-size: 1.75rem;
margin-top: 20px;
}}
.search-container {{
margin-top: 20px;
}}
p {{
color: #6c757d;
font-size: 1rem;
}}
small {{
font-size: 0.875rem;
margin-left: 1em;
font-size: 16px;
}}
input[type="text"] {{
text-align: center;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ced4da;
border-radius: 5px;
width: calc(100% - 22px);
max-width: 400px;
margin-left: auto;
margin-right: auto;
}}
button {{
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease, transform 0.3s ease;
}}
button:hover {{
background-color: #0056b3;
transform: translateY(-2px);
}}
.hidden {{
display: none;
}}
table {{
border: 1px solid #dee2e6;
width: 100%;
border-collapse: collapse;
margin-top: 20px;
border-radius: 8px;
overflow: hidden;
}}
th, td {{
border: 1px solid #dee2e6;
vertical-align: top;
padding: 12px;
text-align: left;
border-bottom: 1px solid #dee2e6;
}}
th {{
background-color: #009e8b;
color: white;
}}
tr:nth-child(even) {{
background-color: #f2f2f2;
}}
tr:hover {{
background-color: #e9ecef;
}}
footer {{
text-align: center;
font-style: italic;
margin: 20px 0;
padding: 10px;
background-color: #f8f9fa;
border-top: 1px solid #dee2e6;
color: #6c757d;
border-radius: 0 0 10px 10px;
}}
.english-table {{
display: none;
}}
.preferred-term {{
background-color: lightgreen;
color: darkgreen;
}}
.deprecated-term {{
background-color: lightcoral;
color: darkred;
}}
.admitted-term {{
background-color: lightgray;
color: black;
}}
</style>
</head>
<header>
<!-- <img src="img\logo.PNG" alt="Logo"> -->
<h1>TERMINOLOGY Overview from: </h1>
<small>{date}</small>
</header>
<body>
<p>Welcome to the terminology database. Here you will find a list of permitted and prohibited terms that should be used depending on the application.</p>
<p>Use the search field to search the table for terms.</p>
<p>In addition to the search function, the table can also be filtered using the drop-down menu.</p>
<p>There is a <a href="#legend">small legend at the bottom of the page</a> in case you have any initial questions.</p>
<div class="search-container">
<input type="text" id="searchInput" placeholder="Search for terms" oninput="updateAutocomplete()">
<div id="autocomplete" class="autocomplete-items"></div>
<br />
<br />
<!-- Dropdown-Menü zur Auswahl des TermSet -->
<label for="filterSelect">Select terminology set:</label>
<select id="filterSelect">
<option value="all">All</option>
<option value="Standard">Default</option>
<option value="ABC-Analyse">ABC-Analysis</option>
<option value="LOGOMATE">LOGOMATE</option>
<option value="INSTORE App">INSTORE App</option>
<option value="RCC">COMMERCE Cloud</option>
<option value="RPOS">POS</option>
<option value="RETAIL">RETAIL</option>
<option value="STATCONTROL">STATCONTROL Cloud</option>
<option value="UCP">UCP</option>
<option value="UI/UX">UI/UX</option>
<option value="Handelterminologie">General Commerce and Logistics Terminology</option>
<!-- Bei Bedarf weitere hinzufügen -->
</select>
<br />
<br />
<!-- Dropdown-Menü zur Auswahl der Sprache -->
<label for="languageSelect">Select Language</label>
<select id="languageSelect" onchange="filterTableLanguage()">
<option value="" selected>All</option>
<option value="en-us">English</option>
<option value="de">Deutsch</option>
<!-- Bei Bedarf weitere hinzufügen -->
</select>
</div>
<table id="termTable">
<tr>
<th>Concept ID</th>
<th>Language</th>
<th>Term</th>
<!-- Add headers here -->
"""
for column in selected_columns:
html_content += f"<th>{column}</th>\n"
html_content += "</tr>\n"
for concept_id, terms_info in term_dictionary.items():
for term_info in terms_info:
html_content += f"<tr>"
html_content += f"<td>{concept_id}</td>"
html_content += f"<td>{term_info['language']}</td>"
html_content += f"<td>{term_info['term']}</td>"
for column in selected_columns:
# Verwende den ursprünglichen Spaltennamen für die Zuordnung des Inhalts
original_column_name = next((key for key, value in new_column_names.items() if value == column), column)
note_value = term_info["notes"].get(original_column_name, "-")
html_content += f"<td>{note_value}</td>"
html_content += "</tr>\n"
html_content += """</table>
<script>
// Function called when the window is fully loaded
window.onload = function() {
filterTable(); // filtert die Tabelle basierend auf Benutzereingaben
toggleTable(); // schaltet die Legende um (zwischen de und en)
addTooltipsFromTable() // fügt Tooltips basierend auf den Daten in der Tabelle hinzu
convertUrlsToLinks() // konvertiert http:// und https:// Einträge in einen Link
colorizeTerms() // färbt die Term-IDs in der Tabelle mit der entsprechenden Farbe
};
/**
* Function to update autocomplete suggestions based on user input.
* Delays the update by 500 milliseconds to reduce excessive updates.
*/
var suggestionTimeout;
// Funktion zum Aktualisieren der Autovervollständigung basierend auf Benutzereingaben
function updateAutocomplete() {
clearTimeout(suggestionTimeout);
// Verzögere die Aktualisierung der Vorschläge um 500 Millisekunden
suggestionTimeout = setTimeout(function () {
var input, filter, table, tr, td, i, txtValue, found;
input = document.getElementById('searchInput');
filter = input.value.toUpperCase();
table = document.getElementById('termTable');
tr = table.getElementsByTagName('tr');
// Array, um Concept-IDs der sichtbaren Zeilen zu speichern
var visibleConceptIds = [];
// Loop durch jede Zeile (überspringt die erste Zeile, die die Überschriften enthält)
for (i = 1; i < tr.length; i++) {
// Zeige die Zeile standardmäßig an
tr[i].style.display = '';
// Suche nur in der Spalte "Term" (Index 2)
td = tr[i].getElementsByTagName('td')[2];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
found = true;
// Extrahiere die Concept-ID der gefundenen Zeile
var conceptId = tr[i].getElementsByTagName('td')[0].textContent || tr[i].getElementsByTagName('td')[0].innerText;
// Speichere die Concept-ID, wenn sie noch nicht gespeichert wurde
if (!visibleConceptIds.includes(conceptId)) {
visibleConceptIds.push(conceptId);
}
} else {
tr[i].style.display = 'none';
}
}
}
// Wenn keine sichtbaren Zeilen vorhanden sind und die Sucheingabe nicht leer ist, zeige alle Zeilen mit den gespeicherten Concept-IDs
if (visibleConceptIds.length > 0 && filter.trim() !== '') {
for (i = 1; i < tr.length; i++) {
var conceptId = tr[i].getElementsByTagName('td')[0].textContent || tr[i].getElementsByTagName('td')[0].innerText;
if (visibleConceptIds.includes(conceptId)) {
tr[i].style.display = '';
} else {
tr[i].style.display = 'none';
}
}
}
// Aktualisiere die Suchvorschläge
updateSuggestions(filter);
}, 500); // Warte 500 Millisekunden, bevor die Vorschläge aktualisiert werden
}
// Funktion zum Aktualisieren der Suchvorschläge basierend auf einem Filter
function updateSuggestions(filter) {
// Array für die Vorschläge initialisieren
var suggestions = [];
// Tabelle und Zeilen abrufen
var termTable = document.getElementById('termTable');
var tr = termTable.getElementsByTagName('tr');
// Durchlaufe jede Zeile (überspringe die erste Zeile, die die Überschriften enthält)
for (var i = 1; i < tr.length; i++) {
var td = tr[i].getElementsByTagName('td');
// Überprüfe jede Zelle in der Zeile
for (var j = 0; j < td.length; j++) {
var txtValue = td[j].textContent || td[j].innerText;
// Überprüfe, ob der Begriff mit dem eingegebenen Filter beginnt
if (txtValue.toUpperCase().startsWith(filter)) {
// Füge den gefundenen Begriff zu den Vorschlägen hinzu
suggestions.push(txtValue);
break; // Sobald ein passender Begriff gefunden wurde, breche die innere Schleife ab
}
}
}
// Anzeige der Vorschläge im Eingabefeld
var autocompleteInput = document.getElementById('searchInput');
if (suggestions.length > 0) {
autocompleteInput.placeholder = suggestions[0].substring(filter.length);
} else {
autocompleteInput.placeholder = '';
}
}
/**
* Main function to filter the table based on selected language and filter option.
* Shows or hides rows based on filter criteria.
*/
function filterTable() {
var selectedLanguage = document.getElementById("languageSelect").value.toUpperCase();
var selectedFilter = document.getElementById("filterSelect").value.toUpperCase();
var table = document.getElementById("termTable");
var rows = table.getElementsByTagName("tr");
// Loop through each row (skip header row)
for (var i = 1; i < rows.length; i++) {
var languageCell = rows[i].getElementsByTagName("td")[1].textContent.toUpperCase();
var termsetCell = rows[i].getElementsByTagName("td")[11].textContent.toUpperCase();
// Check if language and filter match the selected criteria
var languageFilterPassed = selectedLanguage === "" || languageCell === selectedLanguage;
var filterFilterPassed = selectedFilter === "ALL" || termsetCell.includes(selectedFilter);
// Show or hide the row based on the filter results
if (languageFilterPassed && filterFilterPassed) {
rows[i].classList.remove('hidden');
} else {
rows[i].classList.add('hidden');
}
}
}
// Function to add event listeners for filter and language selection
document.addEventListener("DOMContentLoaded", function () {
var filterSelect = document.getElementById('filterSelect');
var languageSelect = document.getElementById('languageSelect');
// Add event listener for filter selection change
filterSelect.addEventListener('change', function () {
filterTable();
});
// Add event listener for language selection change
languageSelect.addEventListener('change', function () {
filterTable();
});
});
/**
* Function to toggle between German and English legend.
* Shows the corresponding table based on the toggle checkbox state.
*/
function toggleTable() {
var germanTable = document.getElementById('german-table');
var englishTable = document.getElementById('english-table');
// Check if the language toggle checkbox is checked
if (document.getElementById('language-toggle').checked) {
germanTable.style.display = 'table';
englishTable.style.display = 'none';
} else {
germanTable.style.display = 'none';
englishTable.style.display = 'table';
}
}
/**
* Function to add tooltips based on predefined table data.
* Searches for specific terms and adds corresponding tooltips.
*/
function addTooltipsFromTable() {
// Table with tooltips
// Syntax: "Word", "Translation", "Tooltip"
var tooltipTable = [
["Hauptbenennung", "Main term designation", "This is the main term designation."],
["Substantiv", "Noun", "This is a noun."],
["Verb", "Verb", "This is a verb."],
["Adjektiv", "Adjective", "This is an adjective."],
["Adverb", "Adverb", "This is an adverb."],
["Synonym", "Synonym", "This is a synonym term."],
["Gemeinsprachlich", "Common language term", "This is a common language term"],
["Variante", "Variant", "This is a variant term."],
["Abkürzung", "Abbreviation", "This is a term abbreviation."],
["Kurzform", "Short form", "This is a short-form term."],
["Standardtext", "Standard usage", "This is standard usage term."],
["Femininum", "Feminine", "This is feminine."],
["Masculinum", "Masculine", "This is masculine."],
["Neutrum", "Neuter", "This is neuter."],
["Handelterminologie", "General Commerce and Logistics Terminology", "This is the General Commerce and Logistics Terminology."]
// Hier können weitere Wörter und deren Übersetzungen eingefügt werden
];
// Get the table with the terms
var termTable = document.getElementById("termTable");
var cells = termTable.getElementsByTagName("td");
// Loop through each cell in the table
for (var i = 0; i < cells.length; i++) {
var term = cells[i].innerText.trim();
// Search for the term in the tooltip table
for (var j = 0; j < tooltipTable.length; j++) {
if (tooltipTable[j][0] === term) {
cells[i].classList.add("tooltip");
cells[i].innerHTML += '<span class="tooltiptext">' + tooltipTable[j][2] + '</span>'; // Füge den Tooltip hinzu
}
}
}
}
/**
* Function to convert URLs in table cells to clickable links.
* Checks for URLs in cell content and converts them.
*/
function convertUrlsToLinks() {
var table = document.getElementById("termTable");
if (table) {
for (var i = 0; i < table.rows.length; i++) {
for (var j = 0; j < table.rows[i].cells.length; j++) {
var cellContent = table.rows[i].cells[j].innerHTML;
// Use a regular expression to match URLs with spaces
var urlRegex = /(https?:\/\/[^\s]+)/g;
var matches = cellContent.match(urlRegex);
if (matches && !cellContent.includes("(translation)")) {
var link = document.createElement("a");
link.href = matches[0];
link.textContent = matches[0];
link.target = "_blank";
// Extract the remaining text after the URL
var remainingText = cellContent.substring(matches[0].length);
// Create a text node for the remaining text
var textNode = document.createTextNode(remainingText);
// Check if there is content before the URL
var textBefore = cellContent.substring(0, cellContent.indexOf(matches[0]));
if (textBefore) {
// Create a text node for the text before the URL
var textNodeBefore = document.createTextNode(textBefore);
table.rows[i].cells[j].innerHTML = '';
table.rows[i].cells[j].appendChild(textNodeBefore);
table.rows[i].cells[j].appendChild(link);
} else {
table.rows[i].cells[j].innerHTML = '';
table.rows[i].cells[j].appendChild(link);
}
table.rows[i].cells[j].appendChild(textNode);
} else if (cellContent.includes("(translation)")) {
// Split the cell content at "(translation)"
var parts = cellContent.split("(translation)");
// Create a new link for the part before "(translation)"
var linkBefore = document.createElement("a");
linkBefore.href = parts[0];
linkBefore.textContent = parts[0];
linkBefore.target = "_blank"; // Open the link in a new window
// Create a text node for the part after "(translation)"
var textNodeAfter = document.createTextNode("(translation)" + parts[1]);
// Clear the cell content and append the link and text nodes
table.rows[i].cells[j].innerHTML = '';
table.rows[i].cells[j].appendChild(linkBefore);
table.rows[i].cells[j].appendChild(textNodeAfter);
}
}
}
} else {
console.error("Table not found!");
}
}
/**
* Function to make table headers sticky.
* Ensures headers stay in place when scrolling.
*/
document.addEventListener('DOMContentLoaded', function() {
var tableHeaders = document.querySelectorAll('#termTable th');
tableHeaders.forEach(function(th) {
th.style.position = 'sticky';
th.style.top = '0';
th.style.zIndex = '1000';
});
});
/**
* Function to colorize table cells based on their content.
* Searches for specific terms and applies corresponding CSS classes
* to change the background and text color of the cells.
*/
function colorizeTerms() {
// Get the table element by its ID
const table = document.getElementById('termTable');
// Get all rows in the table
const rows = table.getElementsByTagName('tr');
// Loop through each row, skipping the header row (index 0)
for (let i = 1; i < rows.length; i++) {
// Get all cells in the current row
const cells = rows[i].getElementsByTagName('td');
// Loop through each cell in the row
for (let j = 0; j < cells.length; j++) {
// Get the text content of the cell
const term = cells[j].innerText;
// Apply a specific CSS class based on the cell's text content
if (term === 'preferredTerm') {
// Apply the 'preferred-term' class for preferred terms
cells[j].classList.add('preferred-term');
} else if (term === 'deprecatedTerm') {
// Apply the 'deprecated-term' class for deprecated term
cells[j].classList.add('deprecated-term');
} else if (term === 'admittedTerm') {
// Apply the 'admitted-term' class for admitted terms
cells[j].classList.add('admitted-term');
}
}
}
}
</script>
<br>
<br>
<br>
<h1_legende id="legend">Legend</h1_legende>
<br>
<br>
<label for="language-toggle">German version</label>
<input type="checkbox" id="language-toggle" onchange="toggleTable()">
<table id="german-table">
<!-- Deutsche Tabelle -->
<thead>
<tr>
<th>Spaltenname</th>
<th>Beschreibung</th>
<th>Mögliche Werte</th>
<!-- Weitere Spalten nach Bedarf -->
</tr>
</thead>
<tbody>
<tr>
<td>Concept-ID</td>
<td>Eindeutige Identifikationsnummer einer Termgruppe im Redaktionssystem SMC. Verschiedene Terme können zu einer Termgruppe gehören.</td>
<td>Aufsteigende Nummerierung (z.B. concept-xxx)</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Language</td>
<td>Jeweilige Sprache eines Terms innerhalb einer Termgruppe.</td>
<td>de (Deutsch - Deutschland)<br>en_US (Englisch - USA)</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Usage</td>
<td>Jeweilige Verwendungseinstufung eines Terms</td>
<td>preferredTerm (Bevorzugter Begriff)<br>admittedTerm (Erlaubter Begriff/ Wörterbucheintrag)<br>deprecatedTerm (Gesperrter Begriff)</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Term type</td>
<td>Jeweilige Art der Benennung eines Terms (z.B. Langform, Kurzform)</td>
<td>Hauptbenennung<br>
Gemeinsprachliche Benennung<br>
Kurzform<br>
Abkürzung<br>
Standardtext<br>
Synonym<br>
Variante
</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Word class</td>
<td>Lexikalische Kategorie eines Terms (z.B. Verb)</td>
<td>Substantiv: Nomen<br>Verb: Tätigkeitswort<br>Adjektiv: Eigenschaftswort<br>Adverb: Umstandswort</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Gender</td>
<td>Grammatikalische Kategorie eines Terms (z.B. Männlich)</td>
<td>Masculinum: Männlich<br>Femininum: Weiblich<br>Neutrum: Sächlich</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Definition</td>
<td>Klar formulierte Erklärung oder Bedeutung des Terms.</td>
<td>Freitexteingabe einer Definition eines Terms aus dem Redaktionssystem SMC</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Source</td>
<td>Ursprung oder Referenz, woher der Term stammt.</td>
<td>Freitexteingabe einer Quelle eines Terms aus dem Redaktionssystem SMC</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Additional note</td>
<td>Zusätzliche Information für einen Term, insbesondere für Produkte.</td>
<td>Freitexteingabe einer Quelle eines Terms aus dem Redaktionssystem SMC</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Context example</td>
<td>Praktisches Beispiel, das den Term in einem Kontext zeigt.</td>
<td>Freitexteingabe einer Quelle eines Terms aus dem Redaktionssystem SMC</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Term set</td>
<td>Gruppierung des Terms in einem bestimmten produktspezifischen oder thematischen Satz oder Zusammenhang.</td>
<td>Standard<br>
ABC-Analyse<br>
LOGOMATE<br>
INSTORE App<br>
RCC<br>
RPOS<br>
RETAIL<br>
STATCONTROL<br>
UCP<br>
UI/UX<br>
Handelsterminologie</td>
<!-- Weitere Zeilen und Daten nach Bedarf -->
</tr>
<tr>
<td>Select terminology set</td>
<td>Das Dropdown-Menü "Select terminology set" ermöglicht es, spezifische Terminologiesets auszuwählen, um die angezeigten Begriffe in der Tabelle entsprechend zu filtern.</td>
<td>Standard<br>
ABC-Analyse<br>
LOGOMATE<br>
INSTORE App<br>
RCC<br>
RPOS<br>
RETAIL<br>
STATCONTROL<br>
UCP<br>
UI/UX<br>
Handelsterminologie
</td>
</tr>
</tbody>
</table>
<table id="english-table" class="english-table">
<!-- Englische Tabelle (initial ausgeblendet) -->
<thead>
<tr>
<th>Column Name</th>
<th>Description</th>
<th>Possible Values</th>
<!-- Add more columns as needed -->
</tr>
</thead>
<tbody>
<tr>
<td>Concept ID</td>
<td>Unique identification number of a term group in the editorial system SMC. Different terms can belong to a term group.</td>
<td>Ascending numbering (e.g., concept-xxx)</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Language</td>
<td>Respective language of a term within a term group.</td>
<td>de (German - Germany)<br>en_US (English - USA)</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Usage</td>
<td>Respective classification of usage for a term.</td>
<td>preferredTerm (Preferred Term)<br>admittedTerm (Allowed Term / Dictionary Entry)<br>deprecatedTerm (Deprecated Term)</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Term Type</td>
<td>Respective type of naming for a term (e.g., long form, short form).</td>
<td>Hauptbenennung: Main term destignation<br>
Gemeinschaftliche Benennung: Common language term<br>
Kurzform: Short-form designation<br>
Abkürzung: Term abbrevation<br>
Standardtext: Standard usage term<br>
Synonym: Synonym term<br>
Variante: Variant term
</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Word Class</td>
<td>Lexical category of a term (e.g., Verb).</td>
<td>Substantiv: Noun<br>Verb: Verb<br>Adjectiv: Adjective<br>Adverb: Adverb</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Gender</td>
<td>Grammatical category of a term (e.g., Masculine).</td>
<td>Masculinum: Masculine<br>Femininum: Feminine<br>Neutrum: Neuter</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Definition</td>
<td>Clearly formulated explanation or meaning of the term.</td>
<td>Free text entry of a definition of a term from the editorial system SMC</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Source</td>
<td>Origin or reference from where the term comes.</td>
<td>Free text entry of a source of a term from the editorial system SMC</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Additional Note</td>
<td>Additional information for a term, especially for products.</td>
<td>Free text entry of a source of a term from the editorial system SMC</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Context Example</td>
<td>Practical example that shows the term in a context.</td>
<td>Free text entry of a source of a term from the editorial system SMC</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Term Set</td>
<td>Grouping of the term in a specific product-specific or thematic set or context.</td>
<td>Standard<br>
ABC-Analysis<br>
LOGOMATE<br>
INSTORE App<br>
COMMERCE Cloud<br>
POS<br>
RETAIL<br>
STATCONTROL Cloud<br>
UCP<br>
UI/UX<br>
General Commerce and Logistics Terminology</td>
<!-- Add more rows and data as needed -->
</tr>
<tr>
<td>Select terminology set</td>
<td>The "Select terminology set" drop-down menu allows you to select specific terminology sets in order to filter the terms displayed in the table accordingly.</td>
<td>Standard<br>
ABC-Analysis<br>
LOGOMATE<br>
INSTORE App<br>
COMMERCE Cloud<br>
POS<br>
RETAIL<br>
STATCONTROL Cloud<br>
UCP<br>
UI/UX<br>
General Commerce and Logistics Terminology
</td>
</tr>
</tbody>
</table>
</div>
<footer>
<small>This list was created automatically by the tool <a href="https://github.com/W45P85/TBX_to_HTML" target="_blank">TBX to HTML</a>.</small>
</footer>
</body>
</html>
"""
# HTML in Datei schreiben
with open(html_file_path, "w", encoding="utf-8") as html_file:
html_file.write(html_content)
print(f"Successfully converted to {html_file_path}.")
# Funktion zur Vorschau der ausgewählten Spalten
def preview_columns(file_path, selected_columns):
tree = ET.parse(file_path)
root = tree.getroot()
columns = set()
for entry in root.findall(".//termEntry"):
for ntig in entry.findall(".//ntig"):
for term_note in ntig.findall(".//termNote"):
column_name = term_note.get("type")
if column_name == 'normativeAuthorization' or column_name.endswith("|String"):
columns.add(column_name)
# Spalten in gewünschter Reihenfolge anordnen
ordered_columns = ['Concept ID', 'normativeAuthorization', 'Benennungstyp|String', 'Wortklasse|String', 'Genus|String', 'Language' , 'Definition|String', 'Quelle|String', 'Anmerkung|String', 'Kontextbeispiel|String', 'Termset|String']
# Filtere die ausgewählten Spalten, die auch in der Reihenfolge vorkommen
selected_columns = [col for col in ordered_columns if col in columns]
return selected_columns
# Funktion zum Auswählen und Verarbeiten einer TBX-Datei
def choose_file():
# Dateiauswahldialog anzeigen
file_path = filedialog.askopenfilename(filetypes=[("TBX files", "*.tbx")])