< Summary

Class:Azure.Search.Documents.Indexes.Models.BM25Similarity
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\BM25Similarity.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\BM25Similarity.Serialization.cs
Covered lines:29
Uncovered lines:15
Coverable lines:44
Total lines:118
Line coverage:65.9% (29 of 44)
Covered branches:13
Total branches:22
Branch coverage:59% (13 of 22)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-100%50%
get_K1()-100%100%
get_B()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-46.67%25%
DeserializeBM25Similarity(...)-78.95%83.33%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\BM25Similarity.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8namespace Azure.Search.Documents.Indexes.Models
 9{
 10    /// <summary> Ranking function based on the Okapi BM25 similarity algorithm. BM25 is a TF-IDF-like algorithm that in
 11    public partial class BM25Similarity : SimilarityAlgorithm
 12    {
 13        /// <summary> Initializes a new instance of BM25Similarity. </summary>
 014        public BM25Similarity()
 15        {
 016            ODataType = "#Microsoft.Azure.Search.BM25Similarity";
 017        }
 18
 19        /// <summary> Initializes a new instance of BM25Similarity. </summary>
 20        /// <param name="oDataType"> . </param>
 21        /// <param name="k1"> This property controls the scaling function between the term frequency of each matching te
 22        /// <param name="b"> This property controls how the length of a document affects the relevance score. By default
 1623        internal BM25Similarity(string oDataType, double? k1, double? b) : base(oDataType)
 24        {
 1625            K1 = k1;
 1626            B = b;
 1627            ODataType = oDataType ?? "#Microsoft.Azure.Search.BM25Similarity";
 1628        }
 29
 30        /// <summary> This property controls the scaling function between the term frequency of each matching terms and 
 1831        public double? K1 { get; set; }
 32        /// <summary> This property controls how the length of a document affects the relevance score. By default, a val
 1833        public double? B { get; set; }
 34    }
 35}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\BM25Similarity.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Text.Json;
 9using Azure.Core;
 10
 11namespace Azure.Search.Documents.Indexes.Models
 12{
 13    public partial class BM25Similarity : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 217            writer.WriteStartObject();
 218            if (Optional.IsDefined(K1))
 19            {
 020                if (K1 != null)
 21                {
 022                    writer.WritePropertyName("k1");
 023                    writer.WriteNumberValue(K1.Value);
 24                }
 25                else
 26                {
 027                    writer.WriteNull("k1");
 28                }
 29            }
 230            if (Optional.IsDefined(B))
 31            {
 032                if (B != null)
 33                {
 034                    writer.WritePropertyName("b");
 035                    writer.WriteNumberValue(B.Value);
 36                }
 37                else
 38                {
 039                    writer.WriteNull("b");
 40                }
 41            }
 242            writer.WritePropertyName("@odata.type");
 243            writer.WriteStringValue(ODataType);
 244            writer.WriteEndObject();
 245        }
 46
 47        internal static BM25Similarity DeserializeBM25Similarity(JsonElement element)
 48        {
 1649            Optional<double?> k1 = default;
 1650            Optional<double?> b = default;
 1651            string odataType = default;
 12852            foreach (var property in element.EnumerateObject())
 53            {
 4854                if (property.NameEquals("k1"))
 55                {
 1656                    if (property.Value.ValueKind == JsonValueKind.Null)
 57                    {
 1658                        k1 = null;
 1659                        continue;
 60                    }
 061                    k1 = property.Value.GetDouble();
 062                    continue;
 63                }
 3264                if (property.NameEquals("b"))
 65                {
 1666                    if (property.Value.ValueKind == JsonValueKind.Null)
 67                    {
 1668                        b = null;
 1669                        continue;
 70                    }
 071                    b = property.Value.GetDouble();
 072                    continue;
 73                }
 1674                if (property.NameEquals("@odata.type"))
 75                {
 1676                    odataType = property.Value.GetString();
 77                    continue;
 78                }
 79            }
 1680            return new BM25Similarity(odataType, Optional.ToNullable(k1), Optional.ToNullable(b));
 81        }
 82    }
 83}