dhlab.ngram.ngram¶
Module Contents¶
Classes¶
API¶
- class dhlab.ngram.ngram.Ngram(words=None, from_year=None, to_year=None, doctype='bok', mode='relative', lang='nob', **kwargs)¶
Bases:
dhlab.text.dhlab_object.DhlabObjTop level class for ngrams
Initialization
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 toNoneif doctype isavis.- 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) –
bokoravis, 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()
- property ngram¶
- plot(smooth=4, **kwargs)¶
- Parameters:
smooth – smoothing the curve
- compare(another_ngram)¶
Divide one ngram by another - measures difference
- _ipython_display_()¶
- class dhlab.ngram.ngram.NgramBook(words=None, title=None, publisher=None, city=None, lang='nob', from_year=None, to_year=None, ddk=None, subject=None, **kwargs)¶
Bases:
dhlab.ngram.ngram.NgramExtract ngrams using metadata with functions to be inherited.
Initialization
Create Dhlab Ngram from metadata
- Parameters:
words (str or list of str optional) – words to examine, defaults to None
title (type, optional) – description, defaults to None
publisher (type, optional) – description, defaults to None
city (type, optional) – description, defaults to None
lang (str, optional) – description, defaults to ‘nob’
from_year (type, optional) – description, defaults to None
to_year (type, optional) – description, defaults to None
ddk (type, optional) – description, defaults to None
subject (type, optional) – description, defaults to None
- Returns:
description
- Return type:
type
- class dhlab.ngram.ngram.NgramNews(words=None, title=None, city=None, from_year=None, to_year=None, **kwargs)¶
Bases:
dhlab.ngram.ngram.Ngram