snipsco / snips-nlu

Snips Python library to extract meaning from text
https://snips-nlu.readthedocs.io
Apache License 2.0
3.89k stars 514 forks source link

Add new parsing apis #724

Closed adrienball closed 5 years ago

adrienball commented 5 years ago

Description: This PR introduces 2 new parsing APIs. The first one allows to run intent classification only, and get back a list of intents along with their probability:

>>> nlu_engine.get_intents("turn the lights on")
[
 {
   "intentName": "turnLightOn",
   "probability": 0.6363648460343694
 },
 {
   "intentName": null,
   "probability": 0.2580088944934134
 },
 {
   "intentName": "turnLightOff",
   "probability": 0.22791834836267366
 },
 {
   "intentName": "setTemperature",
   "probability": 0.181781583254962
 }
]

The second API allows to extract the slots when the intent is already known:

>>> engine.get_slots(u"Hey, lights on in the lounge !", "turnLightOn")
[
 {
   "range": {
     "start": 22,
     "end": 28
   },
   "rawValue": "lounge",
   "value": {
     "kind": "Custom",
     "value": "living room"
   },
   "entity": "room",
   "slotName": "room"
 }
]

On top of these two new APIs, an optional top_n parameter is added to the parse method, allowing to perform intent parsing on the top_n most likely intents.

This should address https://github.com/snipsco/snips-nlu/issues/623, and cover the feature brought by @deeiip in https://github.com/snipsco/snips-nlu/pull/715.

Checklist:

codecov-io commented 5 years ago

Codecov Report

Merging #724 into develop will increase coverage by 0.27%. The diff coverage is 91.24%.

@@             Coverage Diff             @@
##           develop     #724      +/-   ##
===========================================
+ Coverage    88.16%   88.44%   +0.27%     
===========================================
  Files           65       66       +1     
  Lines         3853     3963     +110     
  Branches       735      765      +30     
===========================================
+ Hits          3397     3505     +108     
- Misses         347      349       +2     
  Partials       109      109
timtutt commented 5 years ago

When will there be a new release that includes this PR?

ClemDoum commented 5 years ago

Hi @timtutt a new release should be available by the end of the week or early next week