The potato problem: pluralizing words in MultiContainerInterfaces
MultiContainerInterface attempts to pluralize the term for the objects it contains, however it does not always do this correctly. As a result, a user must use the incorrect pluralization of some words in order to get a MultiContainerInterface extension to work. See extensions tutorial and #585. I'm not sure where this behavior is defined.
English morphology is irregular and difficult, and it will be hard to get this right every time without adding unnecessary dependencies or complicated code. I propose that we stop attempting to pluralize words and just use the singular form as they are entered. Another option that could work would be to have the user explicitly enter the plural form of the word they wish to use instead of attempting to automatically pluralize the word.
This is actually behavior of ObjectMapper. The class method is here:
https://github.com/NeurodataWithoutBorders/pynwb/blob/a4fc53d80010075fc33623a8ede2fee99bf9c612/src/pynwb/form/build/map.py#L385
This change seems reasonable. My only request is existing classes that depend on this behavior do not change relevant attribute names to accommodate the change in the default behavior of ObjectMapper. Two options for addressing this after removing pluralizing from ObjectMapper.convert_dt_name
- Extend
ObjectMapperto overrideconvert_dt_nameto pluralize, and register this new subclass as the mapper for those classes that relied on this behavior. - Extend
ObjectMapper(specifically, the constructor) on a per class basis, and useObjectMapper.map_specin the constructor to map the relevant specifications/attributes
@ajtritt Could you please add comments to describe the intended transform of the name here? https://github.com/NeurodataWithoutBorders/pynwb/blob/a4fc53d80010075fc33623a8ede2fee99bf9c612/src/pynwb/form/build/map.py#L394-L395 I'm not up on my regular expressions syntax.
@bendichter You can feed it into https://regex101.com/ as well.
@t-b Thanks that's very helpful
@bendichter that converts camel case to underscored eg TimeSeries to time_series