Struct
SimilarityScore<T>

Represents a score indicating the similarity of an item to a reference point.

Definition

Namespace:Telerik.Documents.AI.Core

Assembly:Telerik.Documents.AI.Core.dll

Type Parameters:

T

The type of the item being compared.

Syntax:

cs-api-definition
public readonly struct SimilarityScore<T>

Inherited Members ValueType.Equals(object)ValueType.GetHashCode()

Constructors

SimilarityScore(float, T)

Represents a score indicating the similarity of an item to a reference point.

Declaration

cs-api-definition
public SimilarityScore(float similarity, T item)

Parameters

similarity

float

The similarity score indicating how closely the item matches the comparison criteria. Higher values represent greater similarity.

item

T

The item of type T that is associated with the similarity score.

Remarks

This structure is used to encapsulate the similarity score of an item, along with the item itself. It is particularly useful in scenarios where items need to be ranked or sorted based on their similarity to a reference point. The Comparer ensures that items with the same similarity score are distinguished by a unique index, which is useful for operations that require distinct results.

Fields

Comparer

Gets a comparer that orders SimilarityScore<T> instances by descending similarity, using the unique index as a tiebreaker.

Declaration

cs-api-definition
public static readonly IComparer<SimilarityScore<T>> Comparer

Field Value

IComparer<SimilarityScore<T>>

Remarks

This comparer is useful for sorting collections of SimilarityScore<T> so that items with higher similarity values appear first. If two items have the same similarity, the one with the lower unique index is considered less than the other.

Properties

Item

Gets the item of type T.

Declaration

cs-api-definition
public T Item { get; }

Property Value

T

Similarity

Gets the similarity score between two compared entities.

Declaration

cs-api-definition
public float Similarity { get; }

Property Value

float

Methods

ToString()

Returns a string that represents the current object, including its similarity value and item.

Declaration

cs-api-definition
public override string ToString()

Returns

string

A string containing the similarity value and item of this instance, formatted for readability.

Overrides ValueType.ToString()