我需要在 B 中找到“部分”存在于 A 中的所有字符串。
B = [ "Hello World!", "Hello Stack Overflow!", "Foo Bar!", "Food is nice...", "Hej" ]
A = [ "World", "Foo" ]
C = B.FuzzyCompare(A) // C = [ "Hello World!", "Foo Bar!", "Food is nice..." ]
我一直在研究使用 Levenshtein Distance Algorithm
对于问题的“模糊”部分,以及 LINQ对于迭代。
但是,A * B 通常会导致超过 15 亿次比较。
我该怎么办?有没有办法快速“几乎比较”两个字符串列表?
最佳答案
也许简单地比较子字符串就足够了,这样效率会高得多:
var C = B.Where(s1 => A.Any(s2 => s1.IndexOf(s2, StringComparison.OrdinalIgnoreCase) >= 0)).ToList();
关于C# - 两个大字符串数组的模糊比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38332395/