Skip to content

[API Proposal]: Add EditDistance (Levenshtein) to TensorPrimitives for unEqual length <T> comparision. #112784

Description

@KungFuryKeyboard

Background and motivation

With the new Tensor api we now have

HammingBitDistance

HammingDistance(ReadOnlySpan, ReadOnlySpan)

This solves distance between 2 equal-length tensors of values.

However what about unequal lengths ?

Other languages which i don't want to write in implement such as rust implement 'Edit Distance' using Levenshtein Distance

Would it be possible to implement edit distance into the TensorPimatives api ? to support calculating edit distance in .net with unequal length strings or whatever ?

I work at a large financial institution, these methods are required for a lot of things.
we are primarily a dotnet shop.

for reference https://docs.rs/edit-distance/latest/edit_distance/

API Proposal

namespace System.Numerics.Tensor;


Enum DistanceAlgorithm {
  Levenshtein,
  DamerauLevenshtein,
 // ETC
}

Public static class TensorPrimitives {

    public static int EditDistance<T>(DistanceAlgorithm , ReadOnlySpan<T> x, ReadOnlySpan<T> y);
}

API Usage

using System.Numerics.Tensor;

var  result = TensorPrimitives.EditDistance(DistanceAlgorithm.Levenshtein, SomeStringSpanA,SomeStringSpanb)


### Alternative Designs

_No response_

### Risks

_No response_

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions