Skip to content

Commit d63eaf2

Browse files
authored
Merge pull request #5 from PppBr/master
finish the Predict API by putting the predict result in pipeline
2 parents e8cbfa5 + 6e7f060 commit d63eaf2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

BotSharp.Core/Engines/CRFsuite/CRFsuiteEntityRecognizer.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ public async Task<bool> Predict(Agent agent, JObject data, PipeModel meta)
187187

188188
var entities = new List<NlpEntity>();
189189
//
190+
string[] entityProbabilityPairs = output.Split("\r");
191+
for (int i = 0 ; i < entityProbabilityPairs.Length ; i++)
192+
{
193+
string entityProbabilityPair = entityProbabilityPairs[i];
194+
string entity = entityProbabilityPair.Split(":")[0];
195+
decimal probability = decimal.Parse(entityProbabilityPair.Split(":")[1]);
196+
NlpEntity nlpentity = new NlpEntity();
197+
nlpentity.Entity = entity;
198+
nlpentity.Value = tokens[0][i].Text;
199+
nlpentity.Confidence = probability;
200+
entities.Add(nlpentity);
201+
}
202+
190203

191204

192205
data["entities"] = JObject.FromObject(entities);

0 commit comments

Comments
 (0)