There is a LuaLaTeX-package "selnolig" to achieve this goal. Its wordlists and rules could probably be adapted. There is also a thorough discussion of this challenge in the documentation.
https://www.ctan.org/pkg/selnolig

Best regards,
Florian

____________________________________________

Florian Grammel

Copenhagen, Denmark