dictionary

Nearly all of the functions of this library require key indexing, which means it deals with dictionaries internally. This module deals with loading dictionaries and handles automatically converting from python-style dictionaries to condensed (no excess white space) JSON-style dictionaries.

class libpgm.dictionary.Dictionary[source]

This class represents a JSON-style, key-indexable dictionary of data. It contains the attribute alldata and the method dictload.

alldata = None

An internal representation of a key-indexable dictionary.

dictload(path)[source]

Load a dictionary from a JSON-like text in a text file located at path into the attribute alldata.

In order for this function to execute successfully, the text file must have the proper formatting, particularly with regard to quotation marks. See discrete bayesian network for an example. Specifically, the function can get rid of excess whitespace, convert .x to 0.x in decimals, and convert None to null, but nothing else.

Arguments:

  1. path – Path to the text file (e.g. “mydictionary.txt”)

Attributes modified:

  1. alldata – The entire loaded dictionary.

The function also returns an error if nothing was loaded into alldata.

Previous topic

Welcome to libpgm!

Next topic

graphskeleton

This Page