stanford-oval / genie-toolkit

The Genie open source kit for voice assistant (formerly known as Almond)
Apache License 2.0
194 stars 35 forks source link

Creating Custom Entity #930

Closed vinith-reddy25 closed 2 years ago

vinith-reddy25 commented 2 years ago

I wanted to extract village name from a sentence. I have around "100" possible village names. As possible values are more than 10, I prefered to use "Entity" instead of "Enum". So, I tried to create a custom entity.

My thingpedia.tt is like (excluded other input/output parameters here): `**class @pro.ben { import loader from @org.thingpedia.generic_rest.v1(); import config from @org.thingpedia.config.none();

action pro_det(in req Village: Entity(pro.ben:villagename) #[prompt="Where is the program organised?"])

_[canonical="xyz"];

}**`

I updated entities.json with following code **{ "type": "pro.ben:village_name", "name": "village name", "is_well_known": 0, "has_ner_support": 1, "subtype_of": [] }**

Updated parameter-datasets.tsv with following line **entity en-US pro.ben:village_name parameter-datasets/pro.ben:village_name.json**

Then I added "pro.ben:village_name.json" file to "parameter-datasets" folder.

After that I generated train.tsv, eval.tsv. But, "Village" input parameter is not there. Custom entity is added properly. Can I know what is the issue?

sileix commented 2 years ago

Two issues: (1) the entities.json file should have the following format:

{
  "result": "ok",
  "data": [ .... ]
}

(2) you should declare your custom entity in your manifest. so entity village_name #[has_ner=true]; in your case after the import statements.

A way to debug this is to use a tt: entity type first to see if it gets generated correctly, to make sure the setup is fine. Then you can replace the parameter dataset with your owns to check if it's a dataset file issue. Last you can switch to your own entity to see if it's an entity declaration issue.