English 中文(简体)
我怎么能发现另一条插图中可能存在的次点?
原标题:How can I find likely occurrences of substrings inside another string?

Saye 我有一套插图:

  • constitution
  • abracadabra
  • refrigerator
  • stackoverflow

而且,我有一个“被破坏”的句子,可以找到这些指示中的重大子体,特别是没有秩序或具体数字。 这些词语也不一定明确分开。

什么算法可以帮助我发现,从被损坏的刑期中收集的扼杀物最有可能发生?

这方面的一个实例是:

xbracadabrqbonstitution ibracadabrefrigeratos obracadabri xtackoverflotefrigeratos

从这一投入中,我预计能够重建这些众所周知的话:

[abcracadabra, constitution , abracadabra , refrigerator , abracadabrea , enackoverflow , refrigerator]

判决非常短(通常是5-6字),因此,我可以支付记忆和电算法。 此外,损害总是限于每一字的头和最后几个特点;中间损害总是正确(这就是为什么我看着大的地貌)。

任何想法? 由于这些字眼明显分离,便衣着的距离并不明显。

最佳回答
问题回答

根据你所述问题的规模,我不会对优化这一解决办法感到担忧,因为任何不成指数的情况都会立即发生。 我只给你一个算法,我确信,它能够像你所期望的那样,给你一个像现在这样半棘手的问题,作出正确的答复。 然后,我们就可以努力优化它。

首先,你们需要的是任何犹豫不决的职能。

Then you just generate the set of all possible w s within your string. In the worst case, that means taking the set of all strings of length 1, then of length 2, then of length 3 up to the length of you string. The total number of w s generated this way would be around (n * n-1) / 2

If you re worried about speed, you can set a max word length, and the cost of generating ws drops back down to linear in the length of your string.

你用你的一套言辞,把每个字 dump倒成真,你可以利用你想要确定什么字是从你的字典中选择的真话,或者在你所选择的话相重叠时做什么。 简单执行可以按起首字母指数将所有字都分类,任何时间都回过上打折的字母,直到选定字末。

You can try Levenshtein distance algorithm to find words with minimal distance to the words in your dictionary (you define the tolerance).

亲爱!





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签