Commit 2286e06c authored by Vladimír Štill's avatar Vladimír Štill
Browse files

evalweb: Allow working with canonical automata in convert

parent 6fcd8620
......@@ -13,6 +13,8 @@ bp = Blueprint('eval', __name__, url_prefix='/reg')
tasks = {'DFA': 'DFA',
'TOT': 'Totální DFA',
'MIN': 'Minimální DFA',
'CAN': 'Kanonický automat',
'MIC': 'Mininální kanonický automat',
'EFA': 'NFA (s ε-kroky)',
'NFA': 'NFA bez ε-kroků',
'GRA': 'Regulární gramatika',
......@@ -22,6 +24,8 @@ tasks = {'DFA': 'DFA',
convs = {'DFA': 'DFA',
'TOT': 'Totální DFA',
'MIN': 'Minimální DFA',
# 'CAN': 'Kanonický automat', # TODO
# 'MIC': 'Mininální kanonický automat', # TODO
'EFA': 'NFA (s ε-kroky)',
'NFA': 'NFA bez ε-kroků',
'GRA': 'Regulární gramatika'}
......
......@@ -6,48 +6,34 @@ examples: Dict[Tuple[str, str], Tuple[str, str]] = {}
convert_examples: Dict[str, str] = {}
teacher_dfa = "(0,a)=1 (1,b)=0 final={0}"
student_dfa = "(A,a)=B (B,b)=C (C,a)=B final={A,C}"
teacher_dfa_total = parser.dfa_to_str(parser.str_to_dfa(teacher_dfa).total())
teacher_efa = r"(A,a)={B} (A,\e)={D} (B,b)={A} final={A,D}"
student_nfa = parser.nfa_to_str(parser.str_to_nfa(teacher_efa)
.eliminate_epsilon())
student_dfa = "(A,a)=B (B,b)=C (C,a)=B final={A,C}"
student_efa = r"(A,a)={B} (A,\e)={D} (B,b)={C} (C,a)={B} final={C,D}"
student_gra = "S -> aS' | \\e\nS' -> bA | b\nA -> aS'"
student_reg = "(ab)^*"
student_efa = r"(A,a)={B} (A,\e)={D} (B,b)={C} (C,a)={B} final={C,D}"
examples[('DFA', 'DFA')] = (teacher_dfa, student_dfa)
examples[('DFA', 'TOT')] = (teacher_dfa, teacher_dfa_total)
examples[('DFA', 'MIN')] = (teacher_dfa, teacher_dfa_total)
examples[('DFA', 'EFA')] = (teacher_dfa, student_efa)
examples[('DFA', 'NFA')] = (teacher_dfa, student_nfa)
examples[('DFA', 'GRA')] = (teacher_dfa, student_gra)
examples[('DFA', 'REG')] = (teacher_dfa, student_reg)
examples[('EFA', 'DFA')] = (teacher_efa, student_dfa)
examples[('EFA', 'TOT')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'MIN')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'EFA')] = (teacher_efa, student_efa)
examples[('EFA', 'NFA')] = (teacher_efa, student_nfa)
examples[('EFA', 'GRA')] = (teacher_efa, student_gra)
examples[('EFA', 'REG')] = (teacher_efa, student_reg)
teacher_forms = [('DFA', teacher_dfa),
('EFA', teacher_efa),
('GRA', student_gra),
('REG', student_reg)]
examples[('GRA', 'DFA')] = (student_gra, student_dfa)
examples[('GRA', 'TOT')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'MIN')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'EFA')] = (student_gra, student_efa)
examples[('GRA', 'NFA')] = (student_gra, student_nfa)
examples[('GRA', 'GRA')] = (student_gra, student_gra)
examples[('GRA', 'REG')] = (student_gra, student_reg)
student_forms = [('DFA', student_dfa),
('TOT', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
.total())),
('MIN', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
.minimize())),
('CAN', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
.total().canonize())),
('MIC', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
.minimize().canonize())),
('EFA', student_efa),
('NFA', parser.nfa_to_str(parser.str_to_nfa(student_efa)
.eliminate_epsilon())),
('GRA', student_gra),
('REG', student_reg)]
examples[('REG', 'DFA')] = (student_reg, student_dfa)
examples[('REG', 'TOT')] = (student_reg, teacher_dfa_total)
examples[('REG', 'MIN')] = (student_reg, teacher_dfa_total)
examples[('REG', 'EFA')] = (student_reg, student_efa)
examples[('REG', 'NFA')] = (student_reg, student_nfa)
examples[('REG', 'GRA')] = (student_reg, student_gra)
examples[('REG', 'REG')] = (student_reg, student_reg)
for tt, te in teacher_forms:
for st, se in student_forms:
examples[(tt, st)] = (te, se)
convert_examples['DFA'] = teacher_dfa
convert_examples['EFA'] = student_nfa
convert_examples['GRA'] = student_gra
convert_examples['REG'] = student_reg
convert_examples = dict(student_forms)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment