home << dhlab reference

Ngram#

from dhlab import Ngram
class Ngram(words=None, from_year=None, to_year=None, doctype='bok', mode='relative', lang='nob', **kwargs)[source]#

Bases: DhlabObj

Top level class for ngrams

Ngram builder class.

Build Ngrams from the National Librarys collections. Use with book corpus or newspaper corpus. Lang parameter is only supported for book (bok) corpus. Defaults to None if doctype is avis.

Parameters:
  • words (str or list of str, optional) – words to examine, defaults to None

  • from_year (int, optional) – lower period cutoff, defaults to None

  • to_year (int, optional) – upper period cutoff, defaults to None

  • doctype (str, optional) – bok or avis , defaults to ‘bok’

  • mode (str, optional) – Frequency measure, defaults to ‘relative’

  • lang (str, optional) – nob, nno. Only use with docytype=’bok’, defaults to ‘nob’

  • kwargs – Keyword arguments for Ngram._ipython_display_() Ngram.plot()

compare(another_ngram)[source]#

Divide one ngram by another - measures difference

plot(smooth=4, **kwargs)[source]#
Parameters:

smooth – smoothing the curve