FeatureMatrix

class corpustools.corpus.classes.lexicon.FeatureMatrix(name, feature_entries)[source]

An object that stores feature values for segments

Parameters:

name : str

Name to give the FeatureMatrix

feature_entries : list

List of dict with one dictionary per segment, requires the key of symbol which identifies the segment

Attributes

features Get a list of _features that are used in this feature system
name (str) An informative identifier for the feature matrix
possible_values (set) Set of values used in the FeatureMatrix
default_value (str) Default feature value, usually corresponding to unspecified _features
stresses (dict) Mapping of stress values to segments that bear that stress
places (dict) Mapping from place of articulation labels to a feature specification
manners (dict) Mapping from manner of articulation labels to a feature specification
height (dict) Mapping from vowel height labels to a feature specification
backness (dict) Mapping from vowel backness labels to a feature specification
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__(name, feature_entries)
add_feature(feature[, default]) Add a feature to the feature system
add_segment(seg, feat_spec) Add a segment with a feature specification to the feature system
categorize(seg) Categorize a segment into consonant/vowel, place of articulation, manner of articulation, voicing, vowel height, vowel backness, and vowel rounding.
default_fill(seg_list)
feature_match(features_to_match, ...)
param features_to_match:
 a list of strings representing features, e.g. [‘+voice’,’-nasal’]
features_to_segments(feature_description) Given a feature description, return the segments in the inventory
seg_to_feat_line(symbol) Get a list of feature values for a given segment in the order
set_major_class_features(source)
specify(seg[, assign_defaults])
valid_feature_strings() Get all combinations of possible_values and _features
validate() Make sure that all segments in the matrix have all the features.
add_feature(feature, default=None)[source]

Add a feature to the feature system

Attributes

feature (str) Name of the feature to add to the feature system
default (str, optional) If specified, set the value for all segments to this value, otherwise use the FeatureMatrix’s default_value
add_segment(seg, feat_spec)[source]

Add a segment with a feature specification to the feature system

Attributes

seg (str) Segment symbol to add to the feature system
feat_spec (dictionary) Dictionary with _features as keys and feature values as values
categorize(seg)[source]

Categorize a segment into consonant/vowel, place of articulation, manner of articulation, voicing, vowel height, vowel backness, and vowel rounding.

For consonants, the category is of the format:

(‘Consonant’, PLACE, MANNER, VOICING)

For vowels, the category is of the format:

(‘Vowel’, HEIGHT, BACKNESS, ROUNDED)

Diphthongs are categorized differently:

(‘Diphthong’, ‘Vowel’)

Parameters:

seg : Segment

Segment to categorize

Returns:

tuple or None

Returns categories according to the formats above, if any are unable to be calculated, returns None in those places. Returns None if a category cannot be found.

feature_match(features_to_match, segment_description)[source]
Parameters:
  • features_to_match – a list of strings representing features, e.g. [‘+voice’,’-nasal’]
  • segment_description – a dictionary of {feature_name:feature_value}
Returns:

True if features match up with the segment description, e.g. if {‘voice’:’+’, ‘nasal’:’-‘} is in the segment dictionary. Otherwise returns False.

features

Get a list of _features that are used in this feature system

Returns:

list

Sorted list of the names of all _features in the matrix

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 : str, list, or dict

Feature values that specify the segments, see above for format

Returns:

list of Segments

Segments that match the feature description

seg_to_feat_line(symbol)[source]

Get a list of feature values for a given segment in the order that features are return in get_feature_list

Use for display purposes

Returns:

list

List of feature values for the symbol, as well as the symbol itself

Attributes

symbol (str) Segment symbol to look up
segments

Return a list of segment symbols that are specified in the feature system

Returns:

list

List of all the segments with feature specifications

valid_feature_strings()[source]

Get all combinations of possible_values and _features

Returns:

list

List of valid feature strings

validate()[source]

Make sure that all segments in the matrix have all the features. If not, add an unspecified value for that feature to them.