internal ScoringProfile(string name, TextWeights textWeights, IList <ScoringFunction> functions, ScoringFunctionAggregation?functionAggregation) { Name = name; TextWeights = textWeights; Functions = functions; FunctionAggregation = functionAggregation; }
internal static ScoringProfile DeserializeScoringProfile(JsonElement element) { string name = default; TextWeights text = default; IList <ScoringFunction> functions = default; ScoringFunctionAggregation?functionAggregation = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("text")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } text = TextWeights.DeserializeTextWeights(property.Value); continue; } if (property.NameEquals("functions")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <ScoringFunction> array = new List <ScoringFunction>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ScoringFunction.DeserializeScoringFunction(item)); } } functions = array; continue; } if (property.NameEquals("functionAggregation")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } functionAggregation = property.Value.GetString().ToScoringFunctionAggregation(); continue; } } return(new ScoringProfile(name, text, functions, functionAggregation)); }
internal static TextWeights DeserializeTextWeights(JsonElement element) { TextWeights result = new TextWeights(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("weights")) { foreach (var property0 in property.Value.EnumerateObject()) { result.Weights.Add(property0.Name, property0.Value.GetDouble()); } continue; } } return(result); }
internal static ScoringProfile DeserializeScoringProfile(JsonElement element) { ScoringProfile result = new ScoringProfile(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { result.Name = property.Value.GetString(); continue; } if (property.NameEquals("text")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.TextWeights = TextWeights.DeserializeTextWeights(property.Value); continue; } if (property.NameEquals("functions")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Functions = new List <ScoringFunction>(); foreach (var item in property.Value.EnumerateArray()) { result.Functions.Add(ScoringFunction.DeserializeScoringFunction(item)); } continue; } if (property.NameEquals("functionAggregation")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.FunctionAggregation = property.Value.GetString().ToScoringFunctionAggregation(); continue; } } return(result); }