The following code shows how to embed Google Ngram Viewer results in an IPython Notebook. Author: Fabio González.
from IPython.display import HTML
import string
def plot_ngram(text, start, end, corpus, smoothing):
'''
text: String with the n-gram to be searched. Words must be separated by spaces.
start: from year
end: to year
corpus: corpus to be used (21:Spanish, 15:English, etc. check https://books.google.com/ngrams for more)
smoothing: number of years to average
'''
text = string.join(text.split(),'+')
url = ("https://books.google.com/ngrams/graph?content=%s&year_start=%d&year_end=%d&corpus=%d&smoothing=%d"%
(text, start, end, corpus, smoothing))
return HTML("<iframe src=%s width=1000 height=650></iframe>"%url)
plot_ngram("esta es una prueba", 1800, 2000, 21, 3)