home << dhlab reference << dhlab.api.dhlab_api

ngram_book#

from dhlab.api.dhlab_api import ngram_book
ngram_book(word=['.'], title=None, period=None, publisher=None, lang=None, city=None, ddk=None, topic=None)[source]#

Count occurrences of one or more words in books over a given time period.

Call the API BASE_URL endpoint /ngram_book.

Filter the selection of books with metadata. Use % as wildcard where appropriate - no wildcards in word or lang.

Parameters:
  • word (str or list of str) – Word(s) to search for. Can be several words in a single string, separated by comma, e.g. "ord,ordene,orda".

  • title (str) – Title of a specific document to search through.

  • period (tuple of ints) – Start and end years or dates of a time period, given as (YYYY, YYYY) or (YYYYMMDD, YYYYMMDD).

  • publisher (str) – Name of a publisher.

  • lang (str) – Language as a 3-letter ISO code (e.g. "nob" or "nno")

  • city (str) – City of publication.

  • ddk (str) – Dewey Decimal Classification identifier.

  • topic (str) – Topic of the documents.

Returns:

a pandas.DataFrame with the resulting frequency counts of the word(s), spread across years. One year per row.

Return type:

DataFrame