- 279>>>forfileidin gutenberg.fileids():
- 280... raw = gutenberg.raw(fileid)
- 281... num_chars = len(raw)
- 282... words = gutenberg.words(fileid)
- 283... num_words = len(words)
- 284... sents = gutenberg.sents(fileid)
- 285... num_sents = len(sents)
- 286... vocab = set([w.lower()forwin gutenberg.words(fileid)])
- 287... num_vocab = len(vocab)
- 288...print("%d %d %d %s"% (num_chars, num_words, num_sents, fileid))
- 289 ...
- 290887071 192427 7752 austen-emma.txt
- 291466292 98171 3747 austen-persuasion.txt
- 292673022 141576 4999 austen-sense.txt
- 2934332554 1010654 30103 bible-kjv.txt
- 29438153 8354 438 blake-poems.txt
- 295249439 55563 2863 bryant-stories.txt
- 29684663 18963 1054 burgess-busterbrown.txt
- 297144395 34110 1703 carroll-alice.txt
- 298457450 96996 4779 chesterton-ball.txt
- 299406629 86063 3806 chesterton-brown.txt
- 300320525 69213 3742 chesterton-thursday.txt
- 301935158 210663 10230 edgeworth-parents.txt
- 3021242990 260819 10059 melville-moby_dick.txt
- 303468220 96825 1851 milton-paradise.txt
- 304112310 25833 2163 shakespeare-caesar.txt
- 305162881 37360 3106 shakespeare-hamlet.txt
- 306100351 23140 1907 shakespeare-macbeth.txt
- 307711215 154883 4250 whitman-leaves.txt
- 308
- 309>>> raw[:1000]
- 310 "[Leaves of Grass by Walt Whitman 1855]\n\n\nCome, said my soul,\nSuch verses fo
- 311r my Body let us write, (forwe are one,)\nThat should I afterreturn,\nOr, long
- 312, long hence,in other spheres,\nThere to some group of mates the chants resumin
- 313g,\n(Tallying Earth's soil, trees, winds, tumultuous waves,)\nEver with pleas'd
- 314smile I may keep on,\nEverandever yet the verses owning--as, first, I hereand
- 315now\nSigningforSouland Body, set to them my name,\n\nWalt Whitman\n\n\n\n[BO
- 316OK I. INSCRIPTIONS]\n\n} One's-Self I Sing\n\nOne's-self I sing, a simple sepa
- 317rate person,\nYet utter the word Democratic, the word En-Masse.\n\nOf physiology
- 318 fromtop to toe I sing,\nNot physiognomy alone nor brain aloneisworthyfor th
- 319e Muse, I say\n the Form completeis worthier far,\nThe Female equally with t
- 320he Male I sing.\n\nOf Life immenseinpassion, pulse,andpower,\nCheerful,for
- 321freest action form'd under the laws divine,\nThe Modern Man I sing.\n\n\n\n} As
- 322I Ponder'd in Silence\n\nAs I ponder'dinsilence,\nReturning upon my poems, c"
- 323>>>324>>> words
- 325['[','Leaves','of','Grass','by','Walt','Whitman', ...]
- 326>>> sents
- 327[['[','Leaves','of','Grass','by','Walt','Whitman','1855',']'], ['Come',
- 328 ',','said','my','soul',',','Such','verses','for','my','Body','let','u
- 329s', 'write', ',', '(', 'for', 'we', 'are', 'one', ',)', 'That', 'should', 'I', '
- 330after', 'return', ',', 'Or', ',', 'long', ',', 'long', 'hence', ',', 'in', 'othe
- 331r', 'spheres', ',', 'There', 'to', 'some', 'group', 'of', 'mates', 'the', 'chant
- 332s', 'resuming', ',', '(', 'Tallying', 'Earth', "'", 's', 'soil', ',', 'trees', '
- 333,', 'winds', ',', 'tumultuous', 'waves', ',)', 'Ever', 'with', 'pleas', "'", 'd'
- 334,'smile','I','may','keep','on',',','Ever','and','ever','yet','the','
- 335verses', 'owning', '--', 'as', ',', 'first', ',', 'I', 'here', 'and', 'now', 'Si
- 336gning', 'for', 'Soul', 'and', 'Body', ',', 'set', 'to', 'them', 'my', 'name', ',
- 337 '], ...]
来源: http://www.bubuko.com/infodetail-1947509.html