delph-in / pydelphin

Python libraries for DELPH-IN
https://pydelphin.readthedocs.io/
MIT License
79 stars 27 forks source link

TDL/TFS refinements #295

Open goodmami opened 4 years ago

goodmami commented 4 years ago

The delphin.tfs module is a core piece that defines the behavior of feature structures, then delphin.tdl subclasses these to create the AVM class, which is basically the same but the values of features are expected to be TDL Terms. AVM is also multiply-inheriting so it is also a TDL Term. This setup causes some unnecessary complexity and inefficiency (see #294).

I kept the FeatureStructure class separate from AVM because I expected to support non-TDL feature structures, such as on tokens. I think I can reduce this complexity a bit without breaking backward compatibility. The basic idea is to move much of the class modeling of delphin.tdl into delphin.tfs (imports would retain the backward compatibility), so that delphin.tdl is almost solely for decoding and encoding TDL files. This is also nice because delphin.tdl was a bit overloaded already. The AVM and FeatureStructure class could possibly be merged, as well. And maybe I would relax the requirement for AVM values to be Terms, instead relying on duck typing and only raising errors if something can't be serialized to TDL (meaning that in-memory TDL structures can contain things that cannot be serialized).