Inventory

class corpustools.corpus.classes.lexicon.Inventory(update=False)[source]
Inventories contain information about a Corpus’ segmental inventory. This class exists mainly for the purposes of saving and loading user data. When a user loads a corpus into PCT, the Inventory is passed to the constructor of an InventoryModel (corpustoolsguimodels). The InventoryModel is what the user will interact with, and it has several useful functions for analyzing, modifying and sorting the contents of an inventory. The InventoryModel is also connected with an InventoryView (corpustoolsgui

iews) for the purposes of displaying inventory charts in PCT.

User data is saved using Python’s built-in pickle module. However, Qt objects (like the InventoryModel) cannot be pickled. Instead, the data from the model is copied to this Inventory class, which is a native Python object and can be properly pickled.
Parameters:

data : dict, optional

Mapping from segment symbol to Segment objects

Attributes

_features (list) List of all _features used as specifications for segments possible_values : set Set of values that segments use for _features stresses : dict Mapping of stress values to segments that bear that stress places : dict Mapping from place of articulation labels to sets of segments manners : dict Mapping from manner of articulation labels to sets of segments height : dict Mapping from vowel height labels to sets of segments backness : dict Mapping from vowel backness labels to sets of segments vowel_features : str Feature value (i.e., ‘+voc’) that separates vowels from consonants voice_feature : str Feature value (i.e., ‘+voice’) that codes voiced obstruents diph_feature : str Feature value (i.e., ‘+diphthong’ or ‘.high’) that separates diphthongs from monophthongs rounded_feature : str Feature value (i.e., ‘+round’) that codes rounded vowels

Methods

__init__([update])
features_to_segments(feature_description) Given a feature description, return the segments in the inventory
initDefaults()
items()
keys()
save(model) Takes an InventoryModel as input, and updates attributes.
update(source)
update_features(specifier)
valid_feature_strings() Get all combinations of possible_values and _features
values()
features_to_segments(feature_description)[source]

Given a feature description, return the segments in the inventory that match that feature description

Feature descriptions should be either lists, such as [‘+feature1’, ‘-feature2’] or strings that can be separated into lists by ‘,’, such as ‘+feature1,-feature2’.

Parameters:

feature_description : string or list

Feature values that specify the segments, see above for format

Returns:

list of Segments

Segments that match the feature description

save(model)[source]

Takes an InventoryModel as input, and updates attributes. This is called in main.py in saveCorpus().

valid_feature_strings()[source]

Get all combinations of possible_values and _features

Returns:

list

List of valid feature strings