>>> import nltk
import dari nltk
>>> nltk.corpus.gutenberg.fileids()
pilih jenis korpusnya, dan akan keluar teks yang ada dalam korpus tersebut
['austen-emma.txt', 'austen-persuasion.txt', 'austen-sense.txt', 'bible-kjv.txt',
'blake-poems.txt', 'bryant-stories.txt', 'burgess-busterbrown.txt',
'carroll-alice.txt', 'chesterton-ball.txt', 'chesterton-brown.txt',
'chesterton-thursday.txt', 'edgeworth-parents.txt', 'melville-moby_dick.txt',
'milton-paradise.txt', 'shakespeare-caesar.txt', 'shakespeare-hamlet.txt',
'shakespeare-macbeth.txt', 'whitman-leaves.txt']
>>> emma = nltk.corpus.gutenberg.words('austen-emma.txt')
pilih teks dalam korpus tersebut
>>> len(emma)
hitung panjang teksnya
192427
mencari concordance
>>> emma = nltk.Text(nltk.corpus.gutenberg.words('austen-emma.txt'))
pilih teks
>>> emma.concordance("surprize")
cari concordance katanya
cara lain mengakses korpus
>>> from nltk.corpus import gutenberg
pilih nama korpusnya
>>> gutenberg.fileids()
tampilkan nama filenya
['austen-emma.txt', 'austen-persuasion.txt', 'austen-sense.txt', ...]
>>> emma = gutenberg.words('austen-emma.txt')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment