<jupyter_start><jupyter_text>Chapter 7 fully illustrated using Jove<jupyter_code>import sys
sys.path[0:0] = ['../..','../../3rdparty'] # Put these at the head of the search path

from jove.DotBashers import *
from jove.Def_md2mc import *
from jove.Def_NFA   import *
from jove.Def_DFA   import *
from jove.Def_RE2NFA    import *
from jove.Def_NFA2RE    import *
dotObj_nfa(re2nfa("''"))
dotObj_nfa(re2nfa("a"))
dotObj_nfa(re2nfa("  (10)* (11)  "))
re2nfa("  (10)* (11)  ")
NFA1 = re2nfa("   (a+b+c)(p+q)*(m+n) " )
dotObj_nfa(mk_gnfa(NFA1))
GNFA1 = mk_gnfa(NFA1)
(Gnfa_fina, DO, REfinal) = del_gnfa_states(GNFA1)
REfinal
DO[0]
DO[1]
DO[2]
DO[5]
len(DO)
DO[13]
DO[15]
dotObj_dfa(comp_dfa(min_dfa(nfa2dfa(re2nfa(" (1+0)*(111+000+100+010+001)(1+0)* ")))))<jupyter_output>Generating LALR tables<jupyter_text>An NFA is a machine $(Q, \Sigma, \delta, Q_0, F)$ which is somewhat like a DFA except that 1. It can start from a __set__ of starting states $Q_0$    > i.e., the NFA can start from more than one starting state    2. Its transition function $\delta$ maps $Q\times (\Sigma\cup \{\varepsilon\})$ to $2^{Q}$    > i.e., the NFA takes a state $Q$ and a symbol and returns a set of states    You can see these aspects being illustrated in the NFA to follow  RE to NFA<jupyter_code>dotObj_nfa(re2nfa("''"))
dotObj_nfa(re2nfa("a"))
dotObj_nfa(re2nfa("ab"))
dotObj_nfa(re2nfa("a+b"))
dotObj_nfa(re2nfa("a*"))
dotObj_nfa(re2nfa("''*"))
nfromr = re2nfa("ab(a+b)*")
dotObj_nfa(nfromr)
dotObj_nfa(re2nfa("(01)*1+0"))<jupyter_output>Generating LALR tables<jupyter_text>NFA to RE<jupyter_code>mk_gnfa
help(mk_gnfa)
gnfromr = mk_gnfa(nfromr)
dotObj_gnfa(gnfromr)
del_gnfa_states
help(del_gnfa_states)
(Gf, DO, RE) = del_gnfa_states(gnfromr)
RE
DO[0]
DO[6]
DO[7]
DO[8]
DO[9]
dotObj_dfa(min_dfa(nfa2dfa(re2nfa(RE))))
min_dfa
min_dfa_brz<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1643243243243243, 'fraction_numerical': 0.04216216216216216, 'mean_word_length': 6.038022813688213, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '156389', 'license': 'Unlicense', 'n_tokens_mistral': 884, 'n_tokens_neox': 858, 'n_words': 180, 'path': 'notebooks/tutorial/Drive_NFA_9_26_17_Class.ipynb', 'repo_name': 'Thanhson89/JA', 'size': '1850'}