|
Function. PCP_Filtering(STP) |
| Method: |
While palindrome-contained pattern is found, do{
(µ, λ)←Find_PCP(trans(STP))
If palindrome-contained pattern is found, do {
For STP, combine fragments <(sµ, tµ, Tµ),…, (sµ+λ-1, tµ+λ-1, Tµ+λ-1)>, <(sµ+λ, tµ+λ, Tµ+λ),…, (sµ+2λ-1, tµ+2λ-1, Tµ+2λ-1)> and <(sµ+2λ, tµ+2λ, Tµ+2λ),…, (sµ+3λ-1, tµ+3λ-1, Tµ+3λ-1)> to form a new STP according to Definition 13.} }
Return STP
|
|
Sub-Function. Find_PCP(SP) |
Initialize V, LC and LCS as empty
Suppose SP = <s0, s1, …, sn>. For each path segment si in SP, do {
If V is not empty, do {
Get the position of the last element of V (say cur_pos_seg), and compare the last element of V with si. If they are reverse-order, let variable reverse-order be true. Otherwise, let variable reverse-order be false. }
Else let reverse-order be false.
Push si onto V.
For each candidate triple (b_pos, e_pos, cur_pos) in LC, do {
If cur_pos is “null”, let cur_pos be b_pos; otherwise, let cur_pos be added by 1.
Compare V[cur_pos] with si. If they are same, do {
Let this triple be (b_pos, e_pos, cur_pos) and update it in LC. If cur_pos equals to e_pos, then a palindrome-contained pattern is found. Let µbe b_pos, λbe e_pos-b_pos+1, return the pair of µand λ, and exit this sub-function. }
Else delete this candidate triple from LC. }
For each pair (inter_posi, e_posi) in LCS, do {
If inter_posi-1 0, and V[inter_posi-1] and si are reverse-order, set this pair as (inter_posi-1, e_posi) in LCS, and generate a new candidate (inter_posi-1, e_posi, “null”) in LC. Otherwise, delete this pair from LCS. }
If reverse-order is true, do {
Produce a candidate (cur_pos_seg, cur_pos_seg, “null”) and insert it to LC.
Generate a candidate suffix (cur_pos_seg, cur_pos_seg) and add it to LCS. } }
No palindrome-contained pattern is found. Return the pair of “null” and “null”.
|