34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
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}")
|