MulaiMulai sekarang secara gratis

Memprediksi anotasi linguistik

Sekarang Anda akan mencoba salah satu paket model pralatih spaCy dan melihat prediksinya secara langsung. Silakan uji dengan teks Anda sendiri! Model bahasa Inggris kecil sudah tersedia sebagai variabel nlp.

Untuk mengetahui arti suatu tag atau label, Anda dapat memanggil spacy.explain di shell IPython. Contohnya: spacy.explain('PROPN') atau spacy.explain('GPE').

Latihan ini adalah bagian dari kursus

NLP Lanjutan dengan spaCy

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

text = "It’s official: Apple is the first U.S. public company to reach a $1 trillion market value"

# Process the text
doc = ____

for token in doc:
    # Get the token text, part-of-speech tag and dependency label
    token_text = ____.____
    token_pos = ____.____
    token_dep = ____.____
    # This is for formatting only
    print('{:<12}{:<10}{:<10}'.format(token_text, token_pos, token_dep))
Edit dan Jalankan Kode