Levenshtein distance c# count error type

别说谁变了你拦得住时间么 提交于 2019-11-30 14:33:12

Seems like you could add counters for each of the operations:

                if (Answer[i - 1] == Guess[j - 1])
                    d[i, j] = d[i - 1, j - 1];  //no operation
                else
                {
                    int del = d[i-1, j] + 1;
                    int ins = d[i, j-1] + 1;
                    int sub = d[i-1, j-1] + 1;
                    int op = Math.Min(Math.Min(del, ins), sub);
                    d[i, j] = op;
                    if (i == j)
                    {
                        if (op == del)
                            ++deletions;
                        else if (op == ins)
                            ++insertions;
                        else
                            ++substitutions;
                    }
                }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!