BM25SimilarityAlgorithm.java

  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.
  3. //
  4. // Code generated by Microsoft (R) AutoRest Code Generator.
  5. // Changes may cause incorrect behavior and will be lost if the code is
  6. // regenerated.
  7. package com.azure.search.documents.indexes.models;

  8. import com.azure.core.annotation.Fluent;
  9. import com.fasterxml.jackson.annotation.JsonProperty;
  10. import com.fasterxml.jackson.annotation.JsonTypeId;
  11. import com.fasterxml.jackson.annotation.JsonTypeInfo;
  12. import com.fasterxml.jackson.annotation.JsonTypeName;

  13. /**
  14.  * Ranking function based on the Okapi BM25 similarity algorithm. BM25 is a TF-IDF-like algorithm that includes length
  15.  * normalization (controlled by the 'b' parameter) as well as term frequency saturation (controlled by the 'k1'
  16.  * parameter).
  17.  */
  18. @JsonTypeInfo(
  19.         use = JsonTypeInfo.Id.NAME,
  20.         include = JsonTypeInfo.As.EXISTING_PROPERTY,
  21.         property = "@odata.type",
  22.         visible = true)
  23. @JsonTypeName("#Microsoft.Azure.Search.BM25Similarity")
  24. @Fluent
  25. public final class BM25SimilarityAlgorithm extends SimilarityAlgorithm {

  26.     /*
  27.      * The @odata.type property.
  28.      */
  29.     @JsonTypeId
  30.     @JsonProperty(value = "@odata.type", required = true)
  31.     private String odataType = "#Microsoft.Azure.Search.BM25Similarity";

  32.     /*
  33.      * This property controls the scaling function between the term frequency
  34.      * of each matching terms and the final relevance score of a document-query
  35.      * pair. By default, a value of 1.2 is used. A value of 0.0 means the score
  36.      * does not scale with an increase in term frequency.
  37.      */
  38.     @JsonProperty(value = "k1")
  39.     private Double k1;

  40.     /*
  41.      * This property controls how the length of a document affects the
  42.      * relevance score. By default, a value of 0.75 is used. A value of 0.0
  43.      * means no length normalization is applied, while a value of 1.0 means the
  44.      * score is fully normalized by the length of the document.
  45.      */
  46.     @JsonProperty(value = "b")
  47.     private Double b;

  48.     /**
  49.      * Get the k1 property: This property controls the scaling function between the term frequency of each matching
  50.      * terms and the final relevance score of a document-query pair. By default, a value of 1.2 is used. A value of 0.0
  51.      * means the score does not scale with an increase in term frequency.
  52.      *
  53.      * @return the k1 value.
  54.      */
  55.     public Double getK1() {
  56.         return this.k1;
  57.     }

  58.     /**
  59.      * Set the k1 property: This property controls the scaling function between the term frequency of each matching
  60.      * terms and the final relevance score of a document-query pair. By default, a value of 1.2 is used. A value of 0.0
  61.      * means the score does not scale with an increase in term frequency.
  62.      *
  63.      * @param k1 the k1 value to set.
  64.      * @return the BM25SimilarityAlgorithm object itself.
  65.      */
  66.     public BM25SimilarityAlgorithm setK1(Double k1) {
  67.         this.k1 = k1;
  68.         return this;
  69.     }

  70.     /**
  71.      * Get the b property: This property controls how the length of a document affects the relevance score. By default,
  72.      * a value of 0.75 is used. A value of 0.0 means no length normalization is applied, while a value of 1.0 means the
  73.      * score is fully normalized by the length of the document.
  74.      *
  75.      * @return the b value.
  76.      */
  77.     public Double getB() {
  78.         return this.b;
  79.     }

  80.     /**
  81.      * Set the b property: This property controls how the length of a document affects the relevance score. By default,
  82.      * a value of 0.75 is used. A value of 0.0 means no length normalization is applied, while a value of 1.0 means the
  83.      * score is fully normalized by the length of the document.
  84.      *
  85.      * @param b the b value to set.
  86.      * @return the BM25SimilarityAlgorithm object itself.
  87.      */
  88.     public BM25SimilarityAlgorithm setB(Double b) {
  89.         this.b = b;
  90.         return this;
  91.     }
  92. }