# Synonyms

**URL:** <https://support.prodi.gy/t/synonyms/1887>\
**Category:** Uncategorized\
**Tags:** usage, ner, medical\
**Created:** [August 10, 2019, 2:25pm UTC](https://support.prodi.gy/t/synonyms/1887 "2019-08-10T14:25:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aph61](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/aph61/32/417_2.png) [@aph61](https://support.prodi.gy/u/aph61)\
**Post date:** [August 10, 2019, 2:25pm UTC](https://support.prodi.gy/t/synonyms/1887/1 "2019-08-10T14:25:55Z")

</div>

Hi,

I've a small data set of 10 data points on "Lipitor 5mg" (same as Atorvastatin, but branded), 5 data points on "Atorvastatin 10mg", and 5 on "Atorvastatin 20mg". When I do a regular term.teach they are all identified as drug, but not as a statin since I have too few data points.

```
{"label": "DRUG", "patterns": [{lower: "Lipitor"}, {"lower": 5mg}]}
{"label": "DRUG", "patterns": [{lower: "Atorvastatin"}, {"lower": 10mg}]}
{"label": "DRUG", "patterns": [{lower: "Atorvastatin"}, {"lower": 20mg}]}

```

I like to map all drugs to the single entry Atorvastatin in the vocabulary that is used further in the analysis. I tried

```
{"name": "Atorvastatin", "label": "DRUG", "patterns": 
[
[{lower: "Lipitor"}, {"lower": 5mg}],
[{lower: "Atorvastatin"}, {"lower": 10mg}],
[{lower: "Atorvastatin"}, {"lower": 20mg}],
]}

```

but I don't know if I get what I need. I could not find a smart way to verify it. In the ideal case I have a sentence where I have only the drug Atorvastatin, nothing else

suggestions?

thanks

Andreas

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [August 13, 2019, 9:51am UTC](https://support.prodi.gy/t/synonyms/1887/2 "2019-08-13T09:51:58Z")

</div>

I hope I understand the question correctly. But I think you probably want to focus on training your model to recognise `DRUG` (_any_ drug) until it's reasonably good at it. You can then add a rule-based component on top later that normalises them and groups them into subtypes. I actually outlined a very similar approach here:

> [@Nested labels for NER](https://support.prodi.gy/t/nested-labels-for-ner/696/5):
>
> One thing you could do is add a second [pipeline component](https://spacy.io/usage/processing-pipelines#custom-components) after the entity recognizer that looks for DRUG entities and then sets a custom attribute on those entities specifying a list of subtypes (e.g. ent.\_.entity\_subtypes). Here’s an example of a rule-based solution – but you could obviously also swap out the dictionary for a statistical solution, or a combination. from spacy.tokens import Span # dictionary of lowercase entities mapped to subtypes DRUG\_SUBTYPES = { 'citalopram': ['ANTID…
