Config.general.show_nested_entities is not working (with fix proposed)

Hi there. My name is Dr Pi Songsiritat. I am a GP from Australia. I am trying to make use of this wonderful project in my day-to-day work (so much thanks for making it open source). I have just come across an issue that I would like to report.

The issue is whether the config.general.show_nested_entities flag is True or False, there seems to be no effect to the output.

For example if the text is “chest pain” which matches 1) “chest pain” greedily 2) “chest” 3) “pain”, it seems to produce all 3 entities at the end at all time regardless of the flag.

In my use case where I built CDB from a comprehensive ontology such as SNOMED, the greedy matching alone is usually good enough without requiring nested concepts so this flag is very useful. For example “R knee arthroscopy” matching greedily as one concept would come with R laterality and procedure of arthroscopy automatically from entity information from SNOMED itself.

I think the post-processing logic just needs to respect the flag. The filter logic also appears to have problem. I will provide a fix for this.

Here is the pull request:-

Hi.

Thank you for the feedback as well as the solution!

I’ve reviewed your PR and it looks good. However, it’s currently failing some of the workflows. So it would be greatly appreciated if you could fix the issues there and we’ll be happy to include this in the next release.

The old code has got a hacky # type: ignore in it. Are you happy if I just add that back? Otherwise I would have to add a setter to linked_ents.

The ideal solution would ave been to call extend on the existing list. But since it had # type: ignore before, having it after won’t make it any worse.

Thanks for the contribution!