Algorithm Analysis Based on DFA sensitive word query and dfa algorithm analysis
Article copyright by the author Li Xiaohui and blog park a total of, if reproduced Please clearly indicated in the source: http://www.cnblogs.com/naaoveGIS/1. Background
To filter sensitive words in a project, you can select the following solutions:
A. After the sensitive phrase is directly woven into a String, the indexOf metho
ArticleDirectory
2.1 subset Construction Method
2.2 examples of subset Constructor
Subset construction of more than 2.3 first states
2.4 DFA status symbol Index
2.5 Implementation of the subset Construction Method
2.6 DFA dead state
3.1 minimize DFA
3.2 DFA minimization example
3.3 char
the figure:
Figure 3.2
A determined state machine representation of the regular expression ba*b
Figure 3.3
An indeterminate state machine representation of the regular expression ba*b
The starting state of the state machine in Figure 3.3 reads the character B and jumps to the middle two states, so the state machine is nondeterministic. In contrast, the state machine in Figure 3.2, although the function is consistent with the state machine in Figure 3.3, is OK. We can also use a special edge f
On the last we introduced two kinds of models with poor automata-deterministic finite automata and non-deterministic automata, and the final conversion from regular expression through NFA to DFA algorithm. Some students say it is still difficult to understand how the NFA converted to DFA. So at the beginning of this article I would like to cite one more example to see what happens after the NFA is converted
regular expression ba*b
Figure 3.3
A non-deterministic state machine representation of the regular expression ba*b
The state machine's starting state in Figure 3.3 is read into the character B and can jump to two states in the middle, so this state machine is nondeterministic. Instead, the state machine in Figure 3.2, although functionally consistent with the state machine in Figure 3.3, is deterministic. We can also use a special edge to transform the state. We use the ε edge to indicate that
In the previous article, an NFA equivalent to a regular expression was obtained, and this article explains how to convert from NFA to DFA and to simplify the DFA and character classes.
I. The representation of the DFA
The representation of the DFA is similar to the NFA, but it is much simpler and requires only one me
Statement
This article summarizes NFA-to-DFA conversion in compilation principles. The code references lexical analysis in compilation principles.Conversion Method
NFA is not sure about the finite state machine, while DFA is about the finite state machine.
In essence, NFA is equivalent to the DFA constructed by NFA, but there may be multiple paths that exit fr
We all know Graminit. c defines the content related to the actual application of Python syntax rules, including some typical types. If you want to know which four typical types are involved, you can read the following articles to learn about it.
Grammar. hGraminit. c defines the DFA (Deterministic Finite Automaton) that includes Python syntax rules. For details about DFA, see Compilers: Principles, Techniqu
.
2.DFA and NFA understand DFA and NFAThe regular expression engine is divided into two categories, a class called DFA (deterministic with poor automata), and another class called NFA (non-deterministic with poor automata). Two types of engines to work smoothly, must have a regular and a text string, a pinch in the hand, a eat down.
, which greatly extends and enhances the functions of regular expressions. Later, he and Brian kernighan, author of C programming language, have invented the popular awk text editing language. By 1986, regular expressions had a leap. First, Henry Spencer, a top-level hacker in C language, released a library of Regular Expressions written in C Language (not called open source at the time) in the form of source code, so as to bring the mysteries of regular expressions into the ordinary house, then
This is a great problem. The application of AC automata in the construction transfer diagram DFAThe DFA transfer diagram is a diagram showing the state of the transfer process, and the DFA diagram can be used to find out the number of any DNA length, any stateTo find out the DFA matrix using automata, there| DP[N][0] dp[n][1] [... dp[n][m] |=|dp[1][0] dp[1][1] ..
A program to be converted into a lexical analyzer, the task of the lexical analyzer is to convert the character stream into lexical notation flow, the core of the transformation is a poor automaton representation, there is a poor self-motive and state conversion diagram a bit similar, but it is not a graph, but a recognizer, it is the character of each input to identify and judge, In order to determine the final state or state set and path that it can reach, there are two kinds of poor automata,
The first two articles I and II) are just intuitive lexical analysis of the Tiny source program of the clearly given teaching language. In fact, it cannot be called ), it is not general. the lexical analysis for the C ++ source program is also quite simple, with insufficient consideration ). The following is our course experiment. We need to design and analyze the source program based on the finite automaton DFA method learned in the class to extract
Java implements sensitive word filtering (DFA algorithm) and javadfa
Before writing, Alan recommended a article from http://cmsblogs.com /? For a blog post with p = 1031, refer to some sections to describe the blog.
When filtering sensitive words, do you not need to explain them too much? To put it bluntly, you must be able to detect certain words in the project (for example, when entering xxoo-Related Words). In many projects, there will be a sensiti
sensitive word, there is the corresponding treatment, this way to speak White is to find a deal with one.Advantages: So easy. Java code to achieve basic no difficulty.Disadvantage: This efficiency let my heart run over 100,000 grass mud horse, and match is not some egg pain, if it is English you will find a very silent thing, such as English A is a sensitive word, then I if is an English document, that program its sister's have to deal with how many times sensitive words? Who can tell me?② lege
The meaning of the question is hard to understand...
The finite state automation DFA is such an ordered group
Using DFA for string recognition requires you to do the following: the input of the automation is the string α over Σ. initially the automation is in State S. each step it reads the first character C of the input string and changes its state to Phi (u, c) Where U is the current state. after that th
Today's project is carried out with the completion of Python, which needs to be used to do keyword checking, filter classification, and use the former C language to do this kind of thing. With clues, very efficient, memory is small, check fast.Arriving in Python, the first idea is to pip the C language Python module based on the appearance. Unfortunately, we didn't find a suitable one, assuming I would write a Python module in C. I wrote one, but I still do not have the ability.Only can be writt
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.