I would like to write a custom constructor for the ChoiceDict class in the Matrix’s Choices.py (I am working with a copy of that for MOM but I could eventually merge it into the Matrix’s copy if it seems useful).
Currently, ChoiceDict, which it the outer structure for any choices file as it gets loaded, can either be initialized empty or from a choices file. If it is initialized from a choices file, then it is assumed that on the LHS of every line there will be a full dictionary key (such as “verb-pc1_lrt1_lri1_feat1_name”).
I need a constructor which would accept a python dictionary (to remind, a ChoiceDict inherits from dict but is not a dict; it does various clever things with counting (and by the same token with adding and removing items) which drive me mad but I think this is needed for proper interaction with the website or something; similarly a ChoiceList inherits from list but is not a list).
I wrote an iterative function which assumes the morphotactics choices structure as the deepest: a position class (a dict) can contain a list of lexical rule types which can in turn contain lists of things (features and instances). So, three-level deep.
(1) Is there a deeper possible structure?
(2) What would be the base case if I wanted to write a recursive function? I first thought that the deepest level won’t have a “name” attribute but for example features do… Perhaps it’s just the fact that “there are no more lists among the members of this dict”? Doesn’t sound like a very satisfying base case…