nltk - Frequency Distribution Comparison Python -
i'm using python , nltk study texts , want compare frequency distributions of parts of speech across different texts.
i can 1 text:
from nltk import * x_tagged = pos_tag(word_tokenize(open('/users/x.txt').read())) x_fd = freqdist([tag word, tag in x_tagged]) x_fd.plot(cumulative=true, title='part of speech distribution in corpus x')
i've tried add without luck. i've conditional frequency distribution example comparing count of 3 words across several texts, instead i'd lines represent 4 different texts, y-axis represent counts , x-axis represent different parts of speech. how compare texts y , z in same graph?
the freqdist.plot()
method convenience method.
you need write plotting logic (using matplotlib) include multiple frequency distributions in 1 plot.
the source code of plotting function of freqdist
might god point started. matplotlib has tutorial , beginners guide.
Comments
Post a Comment