internal KnowledgeBaseAnswer(IReadOnlyList <string> questions, string answer, double?confidenceScore, int?id, string source, IReadOnlyDictionary <string, string> metadata, KnowledgeBaseAnswerDialog dialog, AnswerSpan answerSpan) { Questions = questions; Answer = answer; ConfidenceScore = confidenceScore; Id = id; Source = source; Metadata = metadata; Dialog = dialog; AnswerSpan = answerSpan; }
internal static KnowledgebaseAnswer DeserializeKnowledgebaseAnswer(JsonElement element) { Optional <IReadOnlyList <string> > questions = default; Optional <string> answer = default; Optional <double> confidenceScore = default; Optional <int> id = default; Optional <string> source = default; Optional <IReadOnlyDictionary <string, string> > metadata = default; Optional <KnowledgebaseAnswerDialog> dialog = default; Optional <AnswerSpan> answerSpan = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("questions")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } questions = array; continue; } if (property.NameEquals("answer")) { answer = property.Value.GetString(); continue; } if (property.NameEquals("confidenceScore")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } confidenceScore = property.Value.GetDouble(); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } id = property.Value.GetInt32(); continue; } if (property.NameEquals("source")) { source = property.Value.GetString(); continue; } if (property.NameEquals("metadata")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } metadata = dictionary; continue; } if (property.NameEquals("dialog")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } dialog = KnowledgebaseAnswerDialog.DeserializeKnowledgebaseAnswerDialog(property.Value); continue; } if (property.NameEquals("answerSpan")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value); continue; } } return(new KnowledgebaseAnswer(Optional.ToList(questions), answer.Value, Optional.ToNullable(confidenceScore), Optional.ToNullable(id), source.Value, Optional.ToDictionary(metadata), dialog.Value, answerSpan.Value)); }
public static KnowledgebaseAnswer KnowledgebaseAnswer(IEnumerable <string> questions = null, string answer = null, double?confidenceScore = null, int?id = null, string source = null, IReadOnlyDictionary <string, string> metadata = null, KnowledgebaseAnswerDialog dialog = null, AnswerSpan answerSpan = null) { questions ??= new List <string>(); metadata ??= new Dictionary <string, string>(); return(new KnowledgebaseAnswer(questions?.ToList(), answer, confidenceScore, id, source, metadata, dialog, answerSpan)); }
public static TextAnswer TextAnswer(string answer = null, double?confidenceScore = null, string id = null, AnswerSpan answerSpan = null, int?offset = null, int?length = null) { return(new TextAnswer(answer, confidenceScore, id, answerSpan, offset, length)); }
internal static TextAnswer DeserializeTextAnswer(JsonElement element) { Optional <string> answer = default; Optional <double> confidenceScore = default; Optional <string> id = default; Optional <AnswerSpan> answerSpan = default; Optional <int> offset = default; Optional <int> length = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("answer")) { answer = property.Value.GetString(); continue; } if (property.NameEquals("confidenceScore")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } confidenceScore = property.Value.GetDouble(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("answerSpan")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value); continue; } if (property.NameEquals("offset")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } offset = property.Value.GetInt32(); continue; } if (property.NameEquals("length")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } length = property.Value.GetInt32(); continue; } } return(new TextAnswer(answer.Value, Optional.ToNullable(confidenceScore), id.Value, answerSpan.Value, Optional.ToNullable(offset), Optional.ToNullable(length))); }