微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在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 举报,一经查实,本站将立刻删除。