Code gesäubert

This commit is contained in:
2025-06-09 19:30:14 +02:00
parent 50aec63700
commit 15c22b522c

View File

@ -32,7 +32,6 @@ plotly_template.set_theme(theme)
pd.set_option('display.max_columns', None) pd.set_option('display.max_columns', None)
pd.set_option('future.no_silent_downcasting', True) pd.set_option('future.no_silent_downcasting', True)
# Optional: slugify-Funktion # Optional: slugify-Funktion
def slugify(value): def slugify(value):
return re.sub(r'[^a-zA-Z0-9_-]', '', value.replace(' ', '_').lower()) return re.sub(r'[^a-zA-Z0-9_-]', '', value.replace(' ', '_').lower())
@ -321,7 +320,7 @@ def visualize_network(bib_database):
fig = go.Figure(data=[edge_trace, primary_trace, secondary_trace, tertiary_trace]) fig = go.Figure(data=[edge_trace, primary_trace, secondary_trace, tertiary_trace])
layout = get_standard_layout( layout = get_standard_layout(
title=f'Suchbegriff-Netzwerk nach Relevanz und Semantik (n={sum(fundzahlen.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f"Suchbegriff-Netzwerk nach Relevanz und Semantik (n={sum(fundzahlen.values())}, Stand: {current_date})",
x_title="Technologische Dimension", x_title="Technologische Dimension",
y_title="Pädagogische Dimension" y_title="Pädagogische Dimension"
) )
@ -418,7 +417,7 @@ def visualize_tags(bib_database):
data, data,
x='Tag', x='Tag',
y='Count', y='Count',
title=f'Häufigkeit der Suchbegriffe in der Literaturanalyse (n={total_count}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Häufigkeit der Suchbegriffe in der Literaturanalyse (n={total_count}, Stand: {current_date})',
labels={'Tag': 'Tag', 'Count': 'Anzahl der Vorkommen'}, labels={'Tag': 'Tag', 'Count': 'Anzahl der Vorkommen'},
color='Type', color='Type',
color_discrete_map=color_map, color_discrete_map=color_map,
@ -472,7 +471,7 @@ def visualize_index(bib_database):
print(f"Häufigkeit Indizes (Gesamtanzahl: {total_count}):") print(f"Häufigkeit Indizes (Gesamtanzahl: {total_count}):")
print(tabulate(index_data, headers="keys", tablefmt="grid")) print(tabulate(index_data, headers="keys", tablefmt="grid"))
fig = px.bar(index_data, x='Index', y='Count', title=f'Relevanzschlüssel nach Indexkategorien (n={total_count}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', labels={'Index': 'Index', 'Count': 'Anzahl der Vorkommen'}, text_auto=True) fig = px.bar(index_data, x='Index', y='Count', title=f'Relevanzschlüssel nach Indexkategorien (n={total_count}, Stand: {current_date})', labels={'Index': 'Index', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
layout = get_standard_layout( layout = get_standard_layout(
title=fig.layout.title.text, title=fig.layout.title.text,
x_title='Index', x_title='Index',
@ -521,7 +520,7 @@ def visualize_research_questions(bib_database):
print(f"Häufigkeit Forschungsunterfragen (Gesamtanzahl: {total_count}):") print(f"Häufigkeit Forschungsunterfragen (Gesamtanzahl: {total_count}):")
print(tabulate(rq_data, headers="keys", tablefmt="grid")) print(tabulate(rq_data, headers="keys", tablefmt="grid"))
fig = px.bar(rq_data_df, x='Research_Question', y='Count', title=f'Zuordnung der Literatur zu Forschungsunterfragen (n={total_count}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', labels={'Research_Question': 'Forschungsunterfrage', 'Count': 'Anzahl der Vorkommen'}, text_auto=True) fig = px.bar(rq_data_df, x='Research_Question', y='Count', title=f'Zuordnung der Literatur zu Forschungsunterfragen (n={total_count}, Stand: {current_date})', labels={'Research_Question': 'Forschungsunterfrage', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
layout = get_standard_layout( layout = get_standard_layout(
title=fig.layout.title.text, title=fig.layout.title.text,
x_title='Forschungsunterfrage', x_title='Forschungsunterfrage',
@ -565,7 +564,7 @@ def visualize_categories(bib_database):
print(f"Häufigkeit Kategorien (Gesamtanzahl: {total_count}):") print(f"Häufigkeit Kategorien (Gesamtanzahl: {total_count}):")
print(tabulate(cat_data, headers="keys", tablefmt="grid")) print(tabulate(cat_data, headers="keys", tablefmt="grid"))
fig = px.bar(cat_data_df, x='Category', y='Count', title=f'Textsortenzuordnung der analysierten Quellen (n={total_count}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', labels={'Category': 'Kategorie', 'Count': 'Anzahl der Vorkommen'}, text_auto=True) fig = px.bar(cat_data_df, x='Category', y='Count', title=f'Textsortenzuordnung der analysierten Quellen (n={total_count}, Stand: {current_date})', labels={'Category': 'Kategorie', 'Count': 'Anzahl der Vorkommen'}, text_auto=True)
layout = get_standard_layout( layout = get_standard_layout(
title=fig.layout.title.text, title=fig.layout.title.text,
x_title='Kategorie', x_title='Kategorie',
@ -609,7 +608,7 @@ def visualize_time_series(bib_database):
df, df,
x='Year', x='Year',
y='Count', y='Count',
title=f'Jährliche Veröffentlichungen in der Literaturanalyse (n={sum(year_counts.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Jährliche Veröffentlichungen in der Literaturanalyse (n={sum(year_counts.values())}, Stand: {current_date})',
labels={'Year': 'Jahr', 'Count': 'Anzahl der Veröffentlichungen'} labels={'Year': 'Jahr', 'Count': 'Anzahl der Veröffentlichungen'}
) )
layout = get_standard_layout( layout = get_standard_layout(
@ -646,7 +645,7 @@ def visualize_top_authors(bib_database):
if top_authors: if top_authors:
df = pd.DataFrame(top_authors, columns=['Author', 'Count']) df = pd.DataFrame(top_authors, columns=['Author', 'Count'])
fig = px.bar(df, x='Author', y='Count', title=f'Meistgenannte Autor:innen in der Literaturanalyse (Top {top_n}, n={sum(author_counts.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', labels={'Author': 'Autor', 'Count': 'Anzahl der Werke'}, text_auto=True) fig = px.bar(df, x='Author', y='Count', title=f'Meistgenannte Autor:innen in der Literaturanalyse (Top {top_n}, n={sum(author_counts.values())}, Stand: {current_date})', labels={'Author': 'Autor', 'Count': 'Anzahl der Werke'}, text_auto=True)
layout = get_standard_layout( layout = get_standard_layout(
title=fig.layout.title.text, title=fig.layout.title.text,
x_title='Autor', x_title='Autor',
@ -693,7 +692,7 @@ def visualize_top_publications(bib_database):
df = pd.DataFrame(publication_data) df = pd.DataFrame(publication_data)
fig = px.bar(df, x='Title', y='Count', title=f'Häufig zitierte Publikationen in der Analyse (Top {top_n}, n={sum(publication_counts.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', labels={'Title': 'Titel', 'Count': 'Anzahl der Nennungen'}) fig = px.bar(df, x='Title', y='Count', title=f'Häufig zitierte Publikationen in der Analyse (Top {top_n}, n={sum(publication_counts.values())}, Stand: {current_date})', labels={'Title': 'Titel', 'Count': 'Anzahl der Nennungen'})
layout = get_standard_layout( layout = get_standard_layout(
title=fig.layout.title.text, title=fig.layout.title.text,
x_title='Titel', x_title='Titel',
@ -834,7 +833,7 @@ def create_path_diagram(data):
) )
)]) )])
layout = get_standard_layout( layout = get_standard_layout(
title=f'Kategorischer Analysepfad der Literatur (n={len(data)}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Kategorischer Analysepfad der Literatur (n={len(data)}, Stand: {current_date})',
x_title='', x_title='',
y_title='' y_title=''
) )
@ -968,7 +967,7 @@ def create_sankey_diagram(bib_database):
)) ))
# Layout anpassen # Layout anpassen
layout = get_standard_layout( layout = get_standard_layout(
title=f"Flussdiagramm der Literaturselektion (Stichprobe: n={sample_size}, Stand: {current_date}) | Quelle: {bib_filename.replace('.bib', '')}", title=f"Flussdiagramm der Literaturselektion (Stichprobe: n={sample_size}, Stand: {current_date})",
x_title='', x_title='',
y_title='' y_title=''
) )
@ -1089,7 +1088,7 @@ def visualize_sources_status(bib_database):
marker=plot_styles['balken_primaryLine'] marker=plot_styles['balken_primaryLine']
)) ))
layout = get_standard_layout( layout = get_standard_layout(
title=f'Analyse- und Stichprobenstatus je Suchordner (n={sum(counts["Identifiziert"] for counts in source_data.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Analyse- und Stichprobenstatus je Suchordner (n={sum(counts["Identifiziert"] for counts in source_data.values())}, Stand: {current_date})',
x_title='Suchbegriffsordner', x_title='Suchbegriffsordner',
y_title='Anzahl der Quellen' y_title='Anzahl der Quellen'
) )
@ -1191,7 +1190,7 @@ def visualize_languages(bib_database):
text='Anzahl', text='Anzahl',
color='Gruppe', color='Gruppe',
color_discrete_map=color_discrete_map, color_discrete_map=color_discrete_map,
title=f'Sprachverteilung der analysierten Quellen (n={sum(norm_counts.values())}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Sprachverteilung der analysierten Quellen (n={sum(norm_counts.values())}, Stand: {current_date})',
hover_data=["Sprache", "Gruppe", "Anzahl", "Anteil (%)"], hover_data=["Sprache", "Gruppe", "Anzahl", "Anteil (%)"],
barmode="stack" barmode="stack"
) )
@ -1296,7 +1295,7 @@ def visualize_language_entrytypes(bib_database):
category_orders={'Sprache': sprache_order, 'Eintragstyp': eintragstyp_order, 'Typgruppe': list(typgruppen_colors.keys())}, category_orders={'Sprache': sprache_order, 'Eintragstyp': eintragstyp_order, 'Typgruppe': list(typgruppen_colors.keys())},
color_discrete_map=typgruppen_colors, color_discrete_map=typgruppen_colors,
barmode="group", barmode="group",
title=f'Verteilung der Eintragstypen pro Sprache (n={len(df)}, Stand: {current_date}) | Quelle: {bib_filename.replace(".bib", "")}', title=f'Verteilung der Eintragstypen pro Sprache (n={len(df)}, Stand: {current_date})',
text='Anzahl', text='Anzahl',
labels={'Sprache': 'Sprache', 'Eintragstyp': 'Eintragstyp', 'Anzahl': 'Anzahl', 'Typgruppe': 'Typgruppe'} labels={'Sprache': 'Sprache', 'Eintragstyp': 'Eintragstyp', 'Anzahl': 'Anzahl', 'Typgruppe': 'Typgruppe'}
) )