change bot.json config structure.
This commit is contained in:
parent
e1fb0d82e8
commit
3779704aac
|
|
@ -50,13 +50,13 @@ namespace BotSharp.Core.Engines
|
|||
Status = new AIResponseStatus(),
|
||||
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,
|
||||
Fulfillment = new AIResponseFulfillment { },
|
||||
Parameters = parameters,
|
||||
Metadata = new AIResponseMetadata
|
||||
{
|
||||
IntentName = doc.Sentences[0].Intent.Label
|
||||
IntentName = doc.Sentences[0].Intent?.Label
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace BotSharp.Core.Engines.NERs
|
|||
{
|
||||
return new List<OntologyEnum>
|
||||
{
|
||||
OntologyEnum.Location,
|
||||
OntologyEnum.DateTime
|
||||
};
|
||||
}
|
||||
|
|
|
|||
15
BotSharp.Core/Engines/NERs/README.md
Normal file
15
BotSharp.Core/Engines/NERs/README.md
Normal 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
|
||||
```
|
||||
|
|
@ -34,11 +34,10 @@ namespace BotSharp.Core.Engines.NERs
|
|||
|
||||
public async Task<bool> Predict(Agent agent, NlpDoc doc, PipeModel meta)
|
||||
{
|
||||
var config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
var client = new RestClient($"{config.GetSection("WitAi:url").Value}");
|
||||
var request = new RestRequest(config.GetSection("WitAi:resource").Value, Method.GET);
|
||||
request.AddHeader("Authorization", "Bearer " + config.GetSection("WitAi:serverAccessToken").Value);
|
||||
request.AddQueryParameter("v", config.GetSection("WitAi:version").Value);
|
||||
var client = new RestClient($"{Configuration.GetSection("WitAiEntityRecognizer:url").Value}");
|
||||
var request = new RestRequest(Configuration.GetSection("WitAiEntityRecognizer:resource").Value, Method.GET);
|
||||
request.AddHeader("Authorization", "Bearer " + Configuration.GetSection("WitAiEntityRecognizer:serverAccessToken").Value);
|
||||
request.AddQueryParameter("v", Configuration.GetSection("WitAiEntityRecognizer:version").Value);
|
||||
request.AddQueryParameter("q", doc.Sentences[0].Text);
|
||||
request.AddQueryParameter("verbose", "true");
|
||||
request.AddQueryParameter("autosuggest", "true");
|
||||
|
|
|
|||
|
|
@ -1,26 +1,29 @@
|
|||
{
|
||||
"RasaNlu": {
|
||||
"RasaAi": {
|
||||
"url": "http://localhost:5000"
|
||||
},
|
||||
|
||||
"WitAi": {
|
||||
"url": "https://api.wit.ai",
|
||||
"resource": "message",
|
||||
"serverAccessToken": "YLLK6SFAPXNYGMKAWLOREQ5MJQSX345L",
|
||||
"version": "20180811"
|
||||
},
|
||||
|
||||
"BotSharpAi": {
|
||||
"Lang": "en",
|
||||
|
||||
"Provider": "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": {
|
||||
"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",
|
||||
"biFeatures": "w pos chk shaped type"
|
||||
},
|
||||
"WitAiEntityRecognizer": {
|
||||
"url": "https://api.wit.ai",
|
||||
"resource": "message",
|
||||
"serverAccessToken": "SERVER_ACCESS_TOKEN",
|
||||
"version": "20180811"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue