Header image by https://unsplash.com/@v2osk

Extract named entities using Azure Cognitive Services

Aymen Furter
Apr 1, 2022

This year I helped to build drugplug as part of Hack Zurich. One key feature of the app is the extraction of relevant information or warnings out of a drug leaflet. We used Azure Cognitive Services in combination with fuse.js (for fuzzy search) for this purpose.

Integrating Text Analytics into our “data pipeline” was super easy. The following code will extract the named entities and store them as an array.

const entityResults = await client.recognizeEntities( [text] );
for (let document of entityResults) {
if (document.entities) {
processedEntities = {}
for (let entity of document.entities) {
if (!drug[element.key]) {
drug[element.key] = [];
}
var tag = {};
tag.name = entity.text;
tag.category = entity.category;
drug[element.key].push(tag);
}
}
};

We then displayed those entities within our Single Page Application:

The complete code is available on github.

--

--

Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.