Skip to content

Catalog.from_catalog

Catalog.from_catalog classmethod

from_catalog(catalog: Catalog) -> Catalog

Creates a new catalog from an existing one.

The new catalog copies the data of the original one without mutating it.

Example
import wordlevel as wl

cl = wl.Catalog.from_dict_of_freqs(
    {
        "before": {"good": 12, "bad": 8, "happy": 6, "sad": 4},
        "after": {"good": 5, "bad": 7, "happy": 3, "sad": 9},
    }
)

new_cl = wl.Catalog.from_catalog(cl)

Parameters:

Name Type Description Default

catalog

Catalog

An existing Catalog

required

Returns:

Type Description
Catalog

A new Catalog with the same internal data as the provided catalog

Source