From a6c269613fef79ce34157e0d27ddaa58b404c4f7 Mon Sep 17 00:00:00 2001 From: 202310715282 AHMAD RIZKY MAULANA SAMOSIR <202310715282@mhs.ubharajaya.ac.id> Date: Sat, 10 Oct 2026 14:10:09 +0700 Subject: [PATCH] update posttag --- pos_tagging.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pos_tagging.py b/pos_tagging.py index 87df8b0..266deef 100644 --- a/pos_tagging.py +++ b/pos_tagging.py @@ -1,8 +1,33 @@ - import stanza stanza.download('id') nlp = stanza.Pipeline('id', processors='tokenize,pos') doc = nlp("Budi sedang membaca buku sejarah di perpustakaan nasional.") +# Menampilkan hasil PoS tagging +print(f"Kalimat: {doc}\n") +print(f"{'Kata':<15} | {'Tag PoS (UPOS)':<15} | {'Deskripsi':<30}") +print("-" * 65) + +# Mapping sederhana untuk penjelasan tag UPOS +upos_desc = { + "ADJ": "Adjective (Kata Sifat)", + "ADP": "Adposition (Kata Depan/Preposisi)", + "ADV": "Adverb (Kata Keterangan)", + "AUX": "Auxiliary (Kata Bantu)", + "CCONJ": "Coordinating Conjunction (Kata Hubung Setara)", + "DET": "Determiner (Kata Penentu)", + "INTJ": "Interjection (Kata Seru)", + "NOUN": "Noun (Kata Benda)", + "NUM": "Numeral (Kata Bilangan)", + "PART": "Particle (Partikel)", + "PRON": "Pronoun (Kata Ganti)", + "PROPN": "Proper Noun (Nama Diri/Nama Khusus)", + "PUNCT": "Punctuation (Tanda Baca)", + "SCONJ": "Subordinating Conjunction (Kata Hubung Bertingkat)", + "SYM": "Symbol (Simbol)", + "VERB": "Verb (Kata Kerja)", + "X": "Other (Lain-lain)" +} + for sentence in doc.sentences: for word in sentence.words: print(f"{word.text:<15} | {word.upos:<15}")