Class EditDistance
Represents the result of an edit distance computation.
Inherited Members
Namespace: SdlSdl.LanguagePlatformCoreEditDistance
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
public class EditDistance
Constructors
EditDistance()
Initializes a new instance with default values.
Declaration
public EditDistance()
EditDistance(int, int, double)
Initializes a new instance with the specified parameters.
Declaration
public EditDistance(int sourceObjectCount, int targetObjectCount, double distance)
Parameters
Type | Name | Description |
---|---|---|
int | sourceObjectCount | The number of source objects (needed for scoring). |
int | targetObjectCount | The number of target objects (needed for scoring). |
double | distance | The score representing the edit distance between the source and the target objects. |
Properties
Distance
Gets or sets the standard distance score as a floating-point value representing the total cost of edit operations. Note that this value should not be used for TM operations. It only computes the basic costs of the transformation, but does not compute a match score (which also depends on the lengths of the sequences). For TM applications, use Score instead.
Declaration
[DataMember]
public double Distance { get; set; }
Property Value
Type | Description |
---|---|
double |
this[int]
Retrieves the edit distance information at the specified index.
Declaration
public EditDistanceItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index in the collection of edit operations. |
Property Value
Type | Description |
---|---|
EditDistanceItem | The EditDistanceItem at the specified index. If the index is invalid, an exception is thrown. |
Items
Gets or sets the list of edit operations.
Declaration
[DataMember]
public List<EditDistanceItem> Items { get; set; }
Property Value
Type | Description |
---|---|
ListEditDistanceItem |
Score
Gets the edit distance score as a floating-point value between 0 and 1. The score depends on the length of the input vectors while the standard distance only represents the sum of the costs of all edit operations. Use this Score for TM applications.
Declaration
public double Score { get; }
Property Value
Type | Description |
---|---|
double |
SourceObjectCount
Gets the length of the source sequence.
Declaration
[DataMember]
public int SourceObjectCount { get; }
Property Value
Type | Description |
---|---|
int |
TargetObjectCount
Gets the length of the target sequence.
Declaration
[DataMember]
public int TargetObjectCount { get; }
Property Value
Type | Description |
---|---|
int |
Methods
Add(EditDistanceItem)
Adds a new edit distance operation to the list.
Declaration
public void Add(EditDistanceItem item)
Parameters
Type | Name | Description |
---|---|---|
EditDistanceItem | item | The item to add. No consistency checks are performed. |
AddAtStart(EditDistanceItem)
Inserts a new edit distance operation at the beginning of the list.
Declaration
public void AddAtStart(EditDistanceItem item)
Parameters
Type | Name | Description |
---|---|---|
EditDistanceItem | item | The item to add. No consistency checks are performed. |
Dump(TextWriter, string)
Textually writes the edit distance information to a stream, for debugging purposes.
Declaration
public void Dump(TextWriter wtr, string msg)
Parameters
Type | Name | Description |
---|---|---|
TextWriter | wtr | The output text writer stream, which must be ready for writing. |
string | msg | A caption to add at the start of the output. |
FindSourceItemIndex(int)
Retrieves the edit operation index for a specified source sequence offset.
Declaration
public int FindSourceItemIndex(int sourceTokenOffset)
Parameters
Type | Name | Description |
---|---|---|
int | sourceTokenOffset | The sequence offset in the underlying source sequence. |
Returns
Type | Description |
---|---|
int | The zero-based index of the corresponding edit distance item, if found, or |
FindTargetItemIndex(int)
Retrieves the edit operation index for a specified target sequence offset.
Declaration
public int FindTargetItemIndex(int targetTokenOffset)
Parameters
Type | Name | Description |
---|---|---|
int | targetTokenOffset | The sequence offset in the underlying target sequence. |
Returns
Type | Description |
---|---|
int | The zero-based index of the corresponding edit distance item, if found, or |
SetResolutionAt(int, EditDistanceResolution)
Sets the edit distance resolution for the edit distance item at the specified index.
Declaration
public void SetResolutionAt(int index, EditDistanceResolution resolution)
Parameters
Type | Name | Description |
---|---|---|
int | index | The edit operation index. |
EditDistanceResolution | resolution | The edit distance resolution. |
SetSourceAt(int, int)
Sets the source offset for the edit operation at the specific index. This is necessary if indices have been changed in the underlying sequence.
Declaration
public void SetSourceAt(int index, int offset)
Parameters
Type | Name | Description |
---|---|---|
int | index | The edit operation index. |
int | offset | The offsetin the source sequence. |
SetTargetAt(int, int)
Sets the target offset for the edit operation at the specific index. This is necessary if indices have been changed in the underlying sequence.
Declaration
public void SetTargetAt(int index, int offset)
Parameters
Type | Name | Description |
---|---|---|
int | index | The edit operation index. |
int | offset | The offsetin the target sequence. |
Sort()
Sorts the edit distance items.
Declaration
public void Sort()