在python中通过操作次数编辑路径的权重而不是字符串的长度来规范编辑距离?

问题描述

我想通过操作次数来标准化编辑距离,而不是比较中最大字符串的长度。我正在尝试关注 this paper,而 this post 与我正在寻找的内容相近,只是它没有提供任何代码。这是我开始的微不足道的代码。我不确定我是否能够继续为此使用 nltk 的实现,但希望...

import pandas as pd
import numpy as np
import nltk
from nltk.metrics.distance import edit_distance as l2

A='ABBB'
B='AAAB'

raw_edit=l2(A,B)
length_norm_edit=l2(A,B)/max(len(A),len(B))
weight_norm_edit= #?? this is really what I'm asking for
marzal_edit= #?? python implementation of the *correctly normalized edit distance from the above linked Marzal paper

print(raw_edit,length_norm_edit,weight_norm_edit,marzal_edit)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)