如何在Python中找到两个字符串之间的类似子串?

时间:2016-10-22 16:19:33

标签: python

我们说我有两个包含相似(但不完全相同)子串的字符串:

A = """Here is a test of a sentence with a few words in it. 
The rest of this sentence is different, though."""

B = """And here is a test of a sent;ence with a few wordz in it, 
as well. The quick brown fox jumped over the lazy dogs."""

我怎样才能在它们之间得到类似的文字,即"这是对一个句子的测试,其中包含几个单词"在A和"这里是对发送的测试;在其中有几个wordz"在B?

编辑:据我所知,这与计算编辑距离不同。当然,我可以计算"句子"之间的编辑距离。并且"发送; ence",但这并不能帮助我识别匹配的子串。

0 个答案:

没有答案