Alice’s online skills hackathon took place last Saturday. It is a pity that no one wrote here about the results, it is interesting to read the stories of the winners. But since there weren’t anyone who wishes, I’ll share my story.

I make a voice interface for managing a brokerage account, I already wrote about it on Habr - Alice, buy Yandex shares . At some point, I needed to extract the price in different currencies from the request. I am sure that I am not the first to encounter such a problem, so I tried to find ready-made intents or named entities on GitHub, but I did not find anything. There was a hackathon on the nose, many developers in one place, I thought, if everyone shares his ideas, then the entities will be typed into a whole library. This is how the idea for the Entity Library repository was born.

User Entities in Dialogs


When I say “buy one share of Yandex” to a smart column, it goes through the internal magic of the Yandex.Dialogs platform, then it gets into the web hook that I specified as the skill handler. Here's what comes in the handler:

"request": { "command": "купи одну акцию яндекс", "original_utterance": "купи одну акцию яндекс", "nlu": { "tokens": [ "купи", "1", "акцию", "яндекс" ], ... "intents": { "market.order": { "slots": { "amount": { "type": "YANDEX.NUMBER", "tokens": { "start": 1, "end": 2 }, "value": 1 }, "unit": { "type": "OperationUnit", "tokens": { "start": 2, "end": 3 }, "value": "share" }, "figi": { "type": "EFigi", "tokens": { "start": 3, "end": 4 }, "value": "BBG006L8G4H1" }, "operation": { "type": "OperationType", "tokens": { "start": 0, "end": 1 }, "value": "buy" } } } } }, ... }, 

Pay attention to the CDMY0CDMY slot, which contains the Yandex stock identifier, the so-called FIGI (Financial Instrument Global Identifier), which is necessary for interaction with the Tinkoff Investment trading platform API. The EFigi data type is a user entity that I described in the Entities section when creating a skill in the Yandex.Dialogs platform. Here is a snippet of the description:

entity EFigi: values: BBG005DXJS36: %exact TCS %lemma тиньков(банк)? тинькоф(банк)? тинькофф(банк)? ти си эс (груп)? BBG006L8G4H1: %exact YNDX %lemma яндекс яндекса BBG004730JJ5: %exact MOEX %lemma Московская Биржа Мосбиржа BBG002B2J5X0: %exact KRKNP %lemma [Саратовский НПЗ акции привилегированные] [Саратовский нефтеперерабатывающий завод акции привилегированные]... 

Thanks to the mechanism of entities, in the handler code, I do not need to do additional manipulations on the input data to get the FIGI. The Dialogue Platform converts the security name to FIGI for me.

I use EFigi as a non-terminal grammar and slot type in intents. Intents are such regular expressions on steroids in Dialogs. Thanks to intents, Dialogs understand what data needs to be extracted from a user request and passed to the handler. Here is an example of intent for a stock market buying/selling team at a market price:

slots: operation: source: $Operation type: OperationType figi: source: $Stock type: Efigi amount: source: $Amount type: YANDEX.NUMBER unit: source: $Unit type: OperationUnit root: $Operation [$Amount $Unit $Stock] $Operation: $OperationType $Amount: $YANDEX.NUMBER $Unit: $OperationUnit $Stock: $EFigi 

It looks like regular expressions.

Entity Library for Dialogs


During the skills development hackathon for Alice, I created the alice-entities-library repository , started it there EFigi entity and went to GitHub to look for repositories that contain a description of user entities. I expected that I would find hundreds of repositories, contact the developers and suggest sending pool requests to the entity library.

I searched for repositories by tags: yandex-dialogs, alice-skills, yandex-alice and alice-sdk. It turned out that few people use tags on GitHub, I managed to find just one repository containing ELang entity description file. By coincidence, the author of the repository was David - one of the organizers of the hackathon. I suggested that David add the ELang entity to the library and after a few minutes I received a pool request from him.

Other members of the online hackathon ignored my chat messages suggesting replenishment of the entity library. Perhaps in the midst of the struggle, there was no time for this. In truth, I was a little upset, but in the end I added a link to the repository in sameoldmadness/awesome-alice .

Instead of a conclusion


Dear skill developers for Alice, I ask you to post the source code on GitHub whenever possible so that others can learn.

Please add the yandex-dialogs, alice-skills and yandex-alice tags to the repositories so others can find your skills on GitHub.

Create the CDMY1CDMY directory in your repository and place the files with the description of the entities that you wrote for the skill so that others can reuse your work.

Before describing a new entity, take a look at the entity library , you may already have what you need. And if not, then please add your entities to the library.

Source