change bot.json config structure.

This commit is contained in:
Haiping 2018-08-12 13:42:27 -05:00
parent e1fb0d82e8
commit 3779704aac
5 changed files with 36 additions and 18 deletions

View file

@ -50,13 +50,13 @@ namespace BotSharp.Core.Engines
Status = new AIResponseStatus(), Status = new AIResponseStatus(),
Result = new AIResponseResult Result = new AIResponseResult
{ {
Score = doc.Sentences[0].Intent.Confidence, Score = doc.Sentences[0].Intent == null ? 0 : doc.Sentences[0].Intent.Confidence,
ResolvedQuery = doc.Sentences[0].Text, ResolvedQuery = doc.Sentences[0].Text,
Fulfillment = new AIResponseFulfillment { }, Fulfillment = new AIResponseFulfillment { },
Parameters = parameters, Parameters = parameters,
Metadata = new AIResponseMetadata Metadata = new AIResponseMetadata
{ {
IntentName = doc.Sentences[0].Intent.Label IntentName = doc.Sentences[0].Intent?.Label
} }
} }
}; };

View file

@ -29,6 +29,7 @@ namespace BotSharp.Core.Engines.NERs
{ {
return new List<OntologyEnum> return new List<OntologyEnum>
{ {
OntologyEnum.Location,
OntologyEnum.DateTime OntologyEnum.DateTime
}; };
} }

View file

@ -0,0 +1,15 @@
# Extend Botsharp's entity recognition capabilities
## Expand with Facebook Duckling
Duckling is a Haskell library that parses text into structured data. A Haskell environment is required.
```
sudo apt install haskell-stack
```
Clone ducking from github
```
git clone https://github.com/facebook/duckling
cd duckling
stack setup
stack build
```

View file

@ -34,11 +34,10 @@ namespace BotSharp.Core.Engines.NERs
public async Task<bool> Predict(Agent agent, NlpDoc doc, PipeModel meta) public async Task<bool> Predict(Agent agent, NlpDoc doc, PipeModel meta)
{ {
var config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration"); var client = new RestClient($"{Configuration.GetSection("WitAiEntityRecognizer:url").Value}");
var client = new RestClient($"{config.GetSection("WitAi:url").Value}"); var request = new RestRequest(Configuration.GetSection("WitAiEntityRecognizer:resource").Value, Method.GET);
var request = new RestRequest(config.GetSection("WitAi:resource").Value, Method.GET); request.AddHeader("Authorization", "Bearer " + Configuration.GetSection("WitAiEntityRecognizer:serverAccessToken").Value);
request.AddHeader("Authorization", "Bearer " + config.GetSection("WitAi:serverAccessToken").Value); request.AddQueryParameter("v", Configuration.GetSection("WitAiEntityRecognizer:version").Value);
request.AddQueryParameter("v", config.GetSection("WitAi:version").Value);
request.AddQueryParameter("q", doc.Sentences[0].Text); request.AddQueryParameter("q", doc.Sentences[0].Text);
request.AddQueryParameter("verbose", "true"); request.AddQueryParameter("verbose", "true");
request.AddQueryParameter("autosuggest", "true"); request.AddQueryParameter("autosuggest", "true");

View file

@ -1,26 +1,29 @@
{ {
"RasaNlu": { "RasaAi": {
"url": "http://localhost:5000" "url": "http://localhost:5000"
}, },
"WitAi": {
"url": "https://api.wit.ai",
"resource": "message",
"serverAccessToken": "YLLK6SFAPXNYGMKAWLOREQ5MJQSX345L",
"version": "20180811"
},
"BotSharpAi": { "BotSharpAi": {
"Lang": "en", "Lang": "en",
"Provider": "SpaCyProvider", "Provider": "SpaCyProvider",
"SpaCyProvider": { "SpaCyProvider": {
"Url": "http://localhost:5005" "url": "http://localhost:5005"
},
"Pipe": "SpaCyTokenizer, CRFsuiteEntityRecognizer, FasttextClassifier",
"SpaCyTokenizer": {
"url": "http://localhost:5005"
}, },
"Pipe": "SpaCyTokenizer, CRFsuiteEntityRecognizer, WitAiEntityRecognizer, FasttextClassifier",
"CRFsuiteEntityRecognizer": { "CRFsuiteEntityRecognizer": {
"fields": "y w pos chk", "fields": "y w pos chk",
"uniFeatures": "w wl pos chk shape shaped type p1 p2 p3 p4 s1 s2 s3 s4 2d 4d d&a d&- d&/ d&, d&. up iu au al ad ao cu cl ca cd cs", "uniFeatures": "w wl pos chk shape shaped type p1 p2 p3 p4 s1 s2 s3 s4 2d 4d d&a d&- d&/ d&, d&. up iu au al ad ao cu cl ca cd cs",
"biFeatures": "w pos chk shaped type" "biFeatures": "w pos chk shaped type"
},
"WitAiEntityRecognizer": {
"url": "https://api.wit.ai",
"resource": "message",
"serverAccessToken": "SERVER_ACCESS_TOKEN",
"version": "20180811"
} }
} }
} }