Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT: sorry, my sample code is buggy you need this kind of algorithms as first step on the parts that you will guess: <a href="http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring" rel="nofollow noreferrer">longest substring</a> or <a href="https://stackoverflow.com/questions/2892931/longest-common-substring-from-more-than-two-strings-python">this</a> </p> <p>you will need to add iteratives and some masking like explained above and by David, also on the sample below, the "L121" for DVD-RW is not guessed (as i have stated that i must be starting with 'common'). So you will need to find all the common consecutive subsequences and decide which one are relevant! (probably with a kind of maximization gain function )</p> <p>using the second link long_substr :</p> <pre><code>&gt;&gt;&gt; for x in d: for y in d: if x == y: continue common = long_substr([x, y]) length = len(common) if x.startswith(common) and y.startswith(common): print "\t".join((x, y, str(length), common)) </code></pre> <p>that produce => </p> <pre><code>0324311071068 0324311071134 10 0324311071 0324311071134 0324311071068 10 0324311071 1613519L121 1613518L121 6 161351 1613519L121 1613509L121 5 16135 WMAYUJ844900 WMAYUJ753738 6 WMAYUJ WMAYUJ844900 WMAYUJ072099 6 WMAYUJ WMAYUJ844900 WMAYUJ683739 6 WMAYUJ WMAYUJ753738 WMAYUJ844900 6 WMAYUJ WMAYUJ753738 WMAYUJ072099 6 WMAYUJ WMAYUJ753738 WMAYUJ683739 6 WMAYUJ 1613518L121 1613519L121 6 161351 1613518L121 1613509L121 5 16135 WMAYUJ072099 WMAYUJ844900 6 WMAYUJ WMAYUJ072099 WMAYUJ753738 6 WMAYUJ WMAYUJ072099 WMAYUJ683739 6 WMAYUJ WMAYUJ683739 WMAYUJ844900 6 WMAYUJ WMAYUJ683739 WMAYUJ753738 6 WMAYUJ WMAYUJ683739 WMAYUJ072099 6 WMAYUJ 608131237 608131234 8 60813123 1613509L121 1613519L121 5 16135 1613509L121 1613518L121 5 16135 608131234 608131237 8 60813123 </code></pre> <p>--- first buggy reply start here</p> <p>below is the first part of my reply, that could only help you to understand where i was wrong and may be give you some ideas : </p> <p>a sample using the Longest Common Subsequence probleme solver <a href="http://code.activestate.com/recipes/576869-longest-common-subsequence-problem-solver/" rel="nofollow noreferrer">LCS</a> with your particular need, that i can think of being a first step of a process of guessing what will be common ? </p> <p>it is in Python, but for the demo part, it can be easily readable (or can be cut and paste in IDLE (the python editor)) assumong that you use the ActiveState Code Recipes of the first link above</p> <p>this has to do with bio informatics (think of genes alignment)</p> <p>you will need something to decide what is the most interesting common sequence (may be having a minimal length? and then proceed with masking like already proposed by David or in my comment</p> <p>(at first i do not see that the LCS what not a LCS consecutive solver, while you will need it to be! SO my first usage of the LCS solver is buggy :( as it is not contiguous, i have MAYUJ8 or WMAYUJ7 and not WMAYUJ - which is shorter ! while solver find longest common characters without expecting them to be consectuive! - again sorry for that)</p> <pre><code>&gt;&gt;&gt; raw = """1613518L121 1613509L121 1613519L121 0324311071068 0324311071134 608131234 608131237 WMAYUJ753738 WMAYUJ072099 WMAYUJ683739 WMAYUJ844900""" &gt;&gt;&gt; d = dict() &gt;&gt;&gt; for line in raw.split("\n"): if not line.strip(): continue value = line.strip() d[value] = 1 &gt;&gt;&gt; for x in d: for y in d: if x == y: continue length = LCSLength(x, y) common = LCS(x,y) if length &gt;= 3 and x.startswith(common): print "\t".join((x, y, str(length), common)) </code></pre> <p>that produce => </p> <pre><code>0324311071068 0324311071134 10 0324311071 0324311071068 608131234 4 0324 0324311071134 0324311071068 10 0324311071 WMAYUJ844900 WMAYUJ753738 7 WMAYUJ8 WMAYUJ753738 WMAYUJ072099 7 WMAYUJ7 608131237 608131234 8 60813123 608131234 608131237 8 60813123 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload