parsing - searching strings for keywords: questions about the "failure function" -
I got a question on the failure function description from "Compiler: Principles, Techniques and Tools" "ORA Dragon Book
First, the quote:
To speedy process the text string and find those stars for a keyword, for the keyword b 1 b 2 ... b n , and position, failure function, F (S) in that keyword ... The purpose is that < B> s Ub> 1 b 2 .. - b f (s) b all> 1 ... b The oldest prefix is , which is also a suffix of all> 1 ... b s . Reason F (s) is important if we < Sub> L b 2 b sub> n to match the text string, and we match the previous condition, But we fail (i.e., the next position of the text string is not b s + l ), then the longest prefix of F (B) B is 1 . B n Which might possibly match the text string to that point on which we are, of course, the next character of the text string should be f (s) +1 otherwise we still have problems and one still The small prefix, which b
f (s) .
So, the question is: 1. 1. If we match the text, then why f (s) the longest b 1 .. b n is the prefix that matches the string? I think - is the longest prefix.
2. The next character of the text string should be sub> f (s) +1 , why? In this situation, we have a mismatch, is there anything in it that is all around?
f) is the longest prefix of the situation that can match the entire keyword. This idea is not an attempt to match the keyword from the beginning, but to locate the situation where the keyword appears.
Consider the search for the word 'aba' in the 'abbaaba' text. This match fails after the first three, but it is not necessary to retry the second 'A' because we know if the next letter is 'B' (which is), then we have a match Could.
Comments
Post a Comment