Class EditDistance
Represents the result of an edit distance computation.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.EditDistance
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class EditDistance
Constructors
EditDistance()
Initializes a new instance with default values.
Declaration
public EditDistance()
EditDistance(Int32, Int32, Double)
Initializes a new instance with the specified parameters.
Declaration
public EditDistance(int sourceObjectCount, int targetObjectCount, double distance)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | sourceObjectCount | The number of source objects (needed for scoring). |
System.Int32 | targetObjectCount | The number of target objects (needed for scoring). |
System.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
public double Distance { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Item[Int32]
Retrieves the edit distance information at the specified index.
Declaration
public EditDistanceItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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
public List<EditDistanceItem> Items { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<EditDistanceItem> |
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 |
---|---|
System.Double |
SourceObjectCount
Gets the length of the source sequence.
Declaration
public int SourceObjectCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
TargetObjectCount
Gets the length of the target sequence.
Declaration
public int TargetObjectCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
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 |
---|---|---|
System.IO.TextWriter | wtr | The output text writer stream, which must be ready for writing. |
System.String | msg | A caption to add at the start of the output. |
FindSourceItemIndex(Int32)
Retrieves the edit operation index for a specified source sequence offset.
Declaration
public int FindSourceItemIndex(int sourceTokenOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | sourceTokenOffset | The sequence offset in the underlying source sequence. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the corresponding edit distance item, if found, or |
FindTargetItemIndex(Int32)
Retrieves the edit operation index for a specified target sequence offset.
Declaration
public int FindTargetItemIndex(int targetTokenOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | targetTokenOffset | The sequence offset in the underlying target sequence. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the corresponding edit distance item, if found, or |
SetResolutionAt(Int32, 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 |
---|---|---|
System.Int32 | index | The edit operation index. |
EditDistanceResolution | resolution | The edit distance resolution. |
SetSourceAt(Int32, Int32)
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 |
---|---|---|
System.Int32 | index | The edit operation index. |
System.Int32 | offset | The offsetin the source sequence. |
SetTargetAt(Int32, Int32)
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 |
---|---|---|
System.Int32 | index | The edit operation index. |
System.Int32 | offset | The offsetin the target sequence. |
Sort()
Sorts the edit distance items.
Declaration
public void Sort()