POS (Export)

POS (Export)#

POS-Daten exportieren

  1. Export der Daten (CSV & xlsx)

1# Export der Zusammenfassung als Tabelle (CSV)
2df.to_csv("results/latin_pos_summary.csv", index=False)
3
4# Export der Zusammenfassung als Tabelle (Excel, xlsx) (benötigt openpyxl)
5# !pip install openpyxl  # Run this if you get an error
6df.to_excel("results/latin_pos_summary.xlsx", index=False)
7
8print("Summary tables exported as 'latin_pos_summary.csv' and '.xlsx'")

Tip!

Alle Daten sollten aus Gründen der Übersichtlichkeit in einem separaten Ordner ‘results’ gespeichert werden.

  1. Export der POS-Daten Wort für Wort

 1# Anlegen einer detaillierten Liste für jedes Wort + Tag (ohne Satzzeichen & White Space)
 2detailed_data = []
 3for token in doc:
 4    if not token.is_punct and not token.is_space:
 5        detailed_data.append({
 6            "Word": token.text,
 7            "Lemma": token.lemma_, 
 8            "POS": token.pos_,
 9            "Morphology": token.morph # Kasus, Numerus, Genus etc.
10        })
11
12# DataFrame (Tabelle) konvertieren und exportieren
13detailed_df = pd.DataFrame(detailed_data)
14detailed_df.to_csv("results/latin_text_annotated.csv", index=False)
15
16print("Detailierte Annotation exportiert als 'latin_text_annotated.csv'")
  1. Export der Visualisierungen

# Re-run des Balkendiagramms und Abspeichern
plt.figure(figsize=(10, 6))
sns.barplot(data=df, x="Count", y="Description", palette="viridis", hue="Description", legend=False)
plt.title("Häufigkeit der einzelnen POS")

# Als PNG speichern
plt.savefig("results/pos_bar_chart.png", dpi=300, bbox_inches='tight')
#plt.show()

# Re-run des Donut-Diagramms und Abspeichern
plt.figure(figsize=(8, 8))
plt.pie(df["Count"], labels=df["Description"], autopct='%1.1f%%', startangle=140)
centre_circle = plt.Circle((0,0), 0.70, fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.title("POS Verteilung")

# Als PDF speichern (VeKtorformat, am besten für Vergrößern)
plt.savefig("results/pos_donut_chart.pdf", bbox_inches='tight')
#plt.show()

print("Diagramme exportiert als 'pos_bar_chart.png' und 'pos_donut_chart.pdf'")