dhlab.api.nb_ngram_api

Module Contents

Functions

get_ngram

Fetch raw and relative frequencies for the terms.

make_word_graph

Get galaxy from ngram-database.

API

dhlab.api.nb_ngram_api.get_ngram(terms: str, corpus: str = 'avis', lang: str = 'nob') dict

Fetch raw and relative frequencies for the terms.

Call the :py:data:NGRAM_API. The frequencies are aggregated per year between 1800-2021.

Parameters:
  • terms (str) – comma separated string of words

  • corpus (str) – type of documents to search through

Returns:

table of annual frequency counts per term

dhlab.api.nb_ngram_api.make_word_graph(words: str, corpus: str = 'all', cutoff: int = 16, leaves: int = 0) networkx.DiGraph

Get galaxy from ngram-database.

Call the :py:obj:~dhlab.constants.GALAXY_API endpoint.

Parameters:
  • words (str) – comma-separated string of words

  • corpus (str) – document type: 'book', 'avis', or 'all',

  • cutoff (int) – Number of nodes to include.

  • leaves (int) – Set leaves=1 to get the leaves.

Returns:

A networkx.DiGraph with the results.