Note that there are some explanatory texts on larger screens.

plurals
  1. POstring pattern match,the suffix array can solve this or have more solution?
    primarykey
    data
    text
    <p>i have a string that random generate by a special characters (B,C,D,F,X,Z),for example to generate a following string list:</p> <pre><code>B D Z Z Z C D C Z B D C B Z Z Z D X D B Z F Z B D C C Z B D C F Z .......... </code></pre> <p>i also have a pattern list, that is to match the generate string and return a best pattern and extract some string from the string.</p> <p><strong>string pattern</strong></p> <pre><code>B D C [D must appear before the C &gt;&gt; DC] B C F B D C F B X [if string have X,must be matched.] ....... </code></pre> <p>for example,</p> <p><code>B D Z Z Z C D C Z</code>,that have <code>B</code> and <code>DC</code>,so that can match by <code>B D C</code></p> <p><code>D B Z C F</code>,that have <code>B</code> and <code>C</code> and <code>F</code>,so that can match by <code>B C F</code></p> <p><code>D B Z D F</code>,that have <code>B</code> and <code>F</code>,so that can match by <code>B F</code></p> <p>.......</p> <p>now,i just think about <code>suffix array</code>.</p> <p>1.first convert a string to suffix array object.</p> <p>2.loop each a pattern,that find which suffix array can be matched.</p> <p>3.compare all matched patterns and get which is a best pattern.</p> <pre><code>var suffix_array=Convert a string to suffix array. var list=new List(); for (int i=0;i&lt;pattern length;i++){ if (suffix_array.match(pattern)) list.Add(pattern); } var max=list[0]; for (int i=1;i&lt;list.length;i++){ { if (list[i]&gt;max) max=list[i]; Write(list[i]); } </code></pre> <p>i just think this method is to complex,that need to build a tree for a pattern ,and take it to match suffix array.who have a more idea?</p> <p>====================update</p> <p>i get a best solution now,i create a new class,that have a B,C,D,X...'s property that is array type.each property save a position that appear at the string. now,if the B not appear at the string,we can immediately end this processing. we can also get all the C and D position,and then compare it whether can sequential appear(DC,DCC,CCC....)</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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