X hits on this document

Powerpoint document

Python for NLP and the Natural Language Toolkit - page 37 / 47

117 views

0 shares

0 downloads

0 comments

37 / 47

Conditional Frequency Distributions (continued)

To access the frequency distribution for a condition, use the indexing operator :                                                        >>> cfdist['a']                                                              <FreqDist with 0 outcomes>

# Record lengths of some words starting with 'a'       for word in 'apple and arm'.split():                       cfdist['a'].inc(len(word))

# How many are 3 characters long?                                                >>> cfdist['a'].freq(3)                                                0.66667

To list accessed conditions, use the conditions method:

   >>> cfdist.conditions()                                                     ['a']

Document info
Document views117
Page views117
Page last viewedMon Dec 05 14:50:35 UTC 2016
Pages47
Paragraphs392
Words1978

Comments