A method and device for interactive teaching of regular language and automata theory
By constructing a regular language and automaton processing model and a string list generation model, the auxiliary teaching interactive method of regular language and automata theory is realized, solving the problems of complexity and low correction efficiency when students learn regular expressions, and improving improve learning efficiency and teaching quality.
Patent Information
- Application Number
- CN202411111929.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Computer science students encounter high complexity when learning regular languages and automaton theory, and it is difficult to evaluate the accuracy of regular expressions. Traditional manual correction is inefficient, resulting in insufficient learning efficiency and enthusiasm.
An auxiliary teaching interaction method of regular language and automaton theory is designed. By constructing a regular language and automaton processing model and a string list generation model, positive and negative example string lists are automatically generated to achieve real-time comparison and feedback. Using Thompson's construction algorithm and Dijkstra's algorithm perform automaton conversion and path generation to reduce teachers' work intensity.
It improves students' ability to write regular expressions and self-assessment, enables timely feedback, improves learning enthusiasm and teaching quality, and simplifies the review and grading process.
Smart Images

Figure CN118627940B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent teaching, and in particular to an auxiliary teaching interaction method and device of regular language and automaton theory. Background Art
[0002] A regular expression is an expression used to describe string pattern matching rules. It consists of characters and operators and can perform string matching, replacement, and search operations. It provides a flexible and powerful way to process text data, such as exact matching, wildcard matching, character ranges, repetition times, etc. In computer programming, regular expressions are widely used in text processing tasks, such as data validation, text parsing, log analysis, etc.
[0003] An automaton is an abstract computational model. Its simplest form is a finite state automaton, which consists of a set of states, input symbols, and state transition rules. In computational theory, finite state automatons are used to describe regular languages and finite state languages, and to solve problems such as string recognition and pattern matching. Automata have important applications in compiler theory, formal language theory, and other fields.
[0004] There is a close connection between regular expressions and automata. Regular expressions can usually be used to describe regular languages, and finite state automata can be used to understand and interpret these regular languages. Specifically, regular expressions can be converted into equivalent finite state automata to achieve string matching and recognition.
[0005] However, in higher education courses in computer science, the theoretical teaching of regular languages and automata is obscure and difficult to understand. Since the syntax of regular expressions is relatively complex and contains many characters, even professional computer workers find it difficult to immediately see the semantics of a complex regular expression; the automaton is expressed as a directed graph, and its meaning is also difficult to immediately derive from the directed graph. Therefore, most students often cannot evaluate the accuracy of their own answers. It is necessary to provide some positive and negative example strings for students to refer to, so as to improve students' ability to write regular expressions and to evaluate the correctness of their own regular expressions.
[0006] Secondly, the traditional paper-based homework grading is difficult to grade manually due to the complexity of regular language characters and symbols, as well as the complexity of directed graphs. It often takes several days for students to receive grades and feedback from teachers. Students cannot know their learning progress in a timely manner, which is not conducive to self-study and learning enthusiasm.
[0007] In summary, with the development of computer technology and the Internet, communication and feedback between teachers and students can be carried out in a more efficient way. At the same time, the number of students majoring in computer science is increasing. Regular language and automata theory are knowledge that students majoring in computer science must learn. It is necessary to propose an auxiliary teaching interaction method and device for regular language and automata theory to improve students' learning efficiency and enthusiasm for regular language and automata theory. Summary of the invention
[0008] The purpose of this application is to propose an auxiliary teaching interaction method and device for regular language and automata theory in response to the above-mentioned technical problems.
[0009] In a first aspect, the present invention provides an interactive teaching method for regular language and automata theory, comprising the following steps:
[0010] Obtaining questions, reference answers corresponding to the questions and student answers, the types of reference answers and student answers both include regular expressions, automata and natural languages;
[0011] If the type of the reference answer and / or the student answer is a regular expression or an automaton, a regular language and automaton processing model is constructed, and the reference answer and the student answer are respectively input into the regular language and automaton processing model to obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata;
[0012] Constructing a string list generation model, inputting a first group of deterministic finite state automata into the string list generation model to generate a first positive example string list and a first counter example string list, and inputting a second group of deterministic finite state automata into the string list generation model to generate a second positive example string list and a second counter example string list;
[0013] Compare the first positive example string list with the second positive example string list, and compare the first negative example string list with the second negative example string list, obtain a first comparison result and feedback it;
[0014] If the type of the reference answer and / or the student answer is natural language, the reference answer and the student answer are compared for similarity to obtain a second comparison result and feedback.
[0015] Preferably, the processing of the regular language and automaton processing model specifically includes:
[0016] If the type of the reference answer and / or the student answer is a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton by using the Thompson construction algorithm, and the non-deterministic finite state automaton is subjected to deterministic and minimization operations to obtain a pre-complement deterministic finite state automaton;
[0017] If the type of the reference answer and / or the student answer is an automaton, the reference answer and / or the student answer is converted into a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton using the Thompson construction algorithm, the non-deterministic finite state automaton is determinized and minimized, and converted into a pre-complement deterministic finite state automaton;
[0018] Performing a complement operation on the deterministic finite state automaton before complementation to obtain a deterministic finite state automaton after complementation, wherein the deterministic finite state automaton before complementation and the deterministic finite state automaton after complementation are a set of deterministic finite state automata;
[0019] Among them, the state of the deterministic finite state automaton before complementation includes an accepting state. When performing the complementation operation, the dead state is added to the deterministic finite state automaton before complementation. The complementation operation includes: converting the accepting state in the deterministic finite state automaton before complementation into a non-accepting state, and converting the non-accepting state in the deterministic finite state automaton before complementation into an accepting state.
[0020] Preferably, the processing of the string list generation model specifically includes:
[0021] Input a deterministic finite state automaton. The deterministic finite state automaton is represented by a directed graph. The directed graph consists of a set of states and a set of directed edges. The set of states includes the initial state and the accepting state. The i-th directed edge is represented by (E i ,T i ,E i+1 ), where E i Indicates the starting state of the directed edge connection, T i The symbol for a directed edge, E i+1 Indicates the terminal state of the directed edge connection;
[0022] Visit all states and directed edges of the deterministic finite state automaton and generate an adjacent edge table;
[0023] Starting from the initial state, a depth-first traversal algorithm is used to traverse the adjacent edge table and generate a first path set;
[0024] The paths in the first path set are processed by using the Dijkstra algorithm and the acceptance state covering algorithm to obtain a second path set, wherein all paths in the second path set start at an initial state and end at an acceptance state, and the end states of all paths in the second path set cover all acceptance states;
[0025] Traverse all paths in the second path set and generate a string list corresponding to the deterministic finite state automaton.
[0026] Preferably, all states and directed edges of the deterministic finite state automaton are accessed to generate an adjacent edge table, specifically including:
[0027] Construct an initially empty adjacency edge table, and set all states and directed edges of the deterministic finite state automaton at the initial moment to be unvisited;
[0028] If the deterministic finite state automaton has an unvisited state, selecting an unvisited state E1 and marking the state E1 as visited;
[0029] Determine whether there is an unvisited directed edge (E1, T1, E2) starting from state E1, where T1 represents the symbol of the directed edge starting from state E1, and E2 represents the terminal state connected by the directed edge starting from state E1. If not, return to the previous step, otherwise select an unvisited directed edge (E1, T1, E2), mark the directed edge (E1, T1, E2) as visited, and determine whether the state E2 connected by the directed edge (E1, T1, E2) has an outgoing edge. If state E2 has no outgoing edge, repeat this step until all directed edges starting from state E1 are marked as visited, otherwise visit all directed edges starting from state E2.
[0030] Select a directed edge (E2, T2, E3) with state E2 as the starting state, where T2 represents the symbol of the directed edge with state E2 as the starting state, and E3 represents the terminal state connected by the directed edge with state E2 as the starting state. Generate the adjacent opposite edge (E1, T1, E2, T2, E3) of state E1 according to the directed edge (E1, T1, E2) and the directed edge (E2, T2, E3). Determine whether the adjacent opposite edge (E1, T1, E2, T2, E3) is in the adjacent opposite edge table. If so, repeat this step until all directed edges with state E2 as the starting state have been selected. Otherwise, add the adjacent opposite edge (E1, T1, E2, T2, E3) to the adjacent opposite edge table, and repeat this step until all directed edges with state E2 as the starting state have been selected. When all directed edges with state E2 as the starting state have been selected, return to the previous step.
[0031] Repeat the above three steps until there is no unvisited state in the deterministic finite state automaton, and then end to obtain the adjacent edge table.
[0032] Preferably, starting from the initial state, a depth-first traversal algorithm is used to traverse the adjacent edge table and generate a first path set, specifically including:
[0033] Initialization step, constructing the path, the first path set and the label. The label indicates whether a new adjacent edge is added to the path in the traversal step of the current traversal state. Its value includes true and false. The path and the first path set at the initial moment are set to empty, the label at the initial moment is assigned to false, and all states of the deterministic finite state automaton at the initial moment and all adjacent edges in the adjacent edge table are set to unvisited;
[0034] In the input step, the initial state is input as the current traversal state;
[0035] A traversal step, traversing all adjacent edges of the current traversal state, and determining whether there are unvisited adjacent edges. If so, in response to determining that there is an unvisited simple loop in the adjacent edges of the current traversal state, wherein the simple loop represents an adjacent edge (E1, T1, E2, T2, E1) from state E1 to state E1, an unvisited simple loop is selected to be added to the path. In response to determining that there is no unvisited simple loop in the adjacent edges of the current traversal state, an unvisited adjacent edge of the current traversal state is selected to be added to the path, and all adjacent edges contained in the path are marked as visited, and the last state of the path is used as the current traversal state, and the label is assigned to true, and this step is repeated. Otherwise, in response to determining that the path is not empty and the label is true, the path is added to the first path set, and the recursion ends with the current traversal state being the current layer of the recursive state. In response to determining that the path is not empty and the label is false, the recursion ends with the current traversal state being the current layer of the recursive state.
[0036] Determine whether the current traversal state is the initial state. If so, set the path to empty, assign the label to false, and return to the incoming step. Otherwise, delete several adjacent edges at the end of the path, and use the final state of the path after deleting the adjacent edges as the current traversal state. At this time, the path is the path after deleting the adjacent edges, so as to return to the previous recursive layer, assign the label to false, and return to the traversal step.
[0037] In response to determining that the path is empty, the unvisited adjacent edges in the adjacent edge table are added to the first path set, and the process ends to obtain the first path set.
[0038] Preferably, the deterministic finite state automaton before complementation is input into the string generation model to generate a list of positive example strings; and the deterministic finite state automaton after complementation is input into the string generation model to generate a list of negative example strings.
[0039] In a second aspect, the present invention provides an auxiliary teaching interactive device for regular language and automata theory, comprising:
[0040] A question data acquisition module is configured to acquire questions, reference answers corresponding to the questions, and student answers, wherein the types of the reference answers and student answers include regular expressions, automata, and natural languages;
[0041] an automaton generation module, configured to construct a regular language and automaton processing model if the type of the reference answer and / or the student answer is a regular expression or an automaton, input the reference answer and the student answer into the regular language and automaton processing model respectively, and obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata;
[0042] a string list generation module configured to construct a string list generation model, input the first group of deterministic finite state automata into the string list generation model to generate a first positive example string list and a first negative example string list, input the second group of deterministic finite state automata into the string list generation model to generate a second positive example string list and a second negative example string list;
[0043] A first scoring module is configured to compare the first positive example string list with the second positive example string list, and compare the first negative example string list with the second negative example string list, obtain a first comparison result and feedback it;
[0044] The second scoring module is configured to compare the reference answer and the student answer for similarity if the type of the reference answer and / or the student answer is natural language, obtain a second comparison result and provide feedback.
[0045] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0046] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0047] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] (1) The interactive teaching method for regular language and automata theory proposed in the present invention automatically generates corresponding string lists from reference answers and student answers by designing regular language and automata processing models and string list generation models, so as to compare student answers and reference answers in real time and provide feedback on the comparison results. This allows students to more clearly understand the accuracy of their submitted answers by observing the generated string lists, so that students can get timely feedback while learning, improve their ability to write regular expressions and evaluate the correctness of their own regular expressions, effectively enhance students' enthusiasm and efficiency in learning regular language and automata theory, and effectively improve the teaching quality of regular language and automata theory courses.
[0050] (2) In the auxiliary teaching interactive method of regular language and automata theory proposed in the present invention, the paths in the first path set cover the transitions between each pair of adjacent states in the deterministic finite state automata, thereby improving the quality and comprehensiveness of the paths. Furthermore, the Dijkstra algorithm and the acceptance state coverage algorithm are used to process the paths in the first path set, so that each path completely traverses the deterministic finite state automata and generates a complete string list. By observing the generated string list, students can more clearly understand the accuracy of the answers they submit, thereby helping students to quickly understand regular languages and automata.
[0051] (3) The auxiliary teaching interaction method of regular language and automata theory proposed in the present invention compares the reference answers with the students' answers, and can complete intelligent review and automatic grading based on the comparison results, thereby reducing the workload of teachers and realizing efficient teaching interaction of regular language and automata theory. The comparison results are fed back to students for their reference, so that students can more clearly understand the accuracy of the answers they submitted, master the theory in practice, and achieve better practice effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A flowchart of the interactive method for auxiliary teaching of regular language and automata theory according to an embodiment of the present application;
[0054] Figure 2 It is a general framework diagram of the application of the regular language and automaton theory auxiliary teaching interactive method in the teaching system of the embodiment of the present application;
[0055] Figure 3 A deterministic finite state automaton for the regular expression "(0|10)(0|1)*01" of an embodiment of the present application;
[0056] Figure 4 A flowchart of generating an adjacency pair table of a deterministic finite state automaton according to an embodiment of the present application;
[0057] Figure 5 A flowchart of generating a first path set according to an embodiment of the present application;
[0058] Figure 6 A deterministic finite state automaton after complementation of the regular expression "(0|10)(0|1)*01" of an embodiment of the present application;
[0059] Figure 7 is the first comparison result of the embodiment of the present application;
[0060] Figure 8 A schematic diagram of an interactive device for assisting teaching of regular language and automata theory according to an embodiment of the present application;
[0061] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] Figure 1 An auxiliary teaching interaction method of regular language and automaton theory provided by an embodiment of the present application is shown, comprising the following steps:
[0064] S1, obtain the questions, the reference answers corresponding to the questions and the student answers, and the types of the reference answers and the student answers include regular expressions, automata and natural languages.
[0065] Specifically, teachers upload descriptions of questions and corresponding reference answers through the teaching system. There are many types of questions: (1) Draw the corresponding automaton based on the regular expression, (2) Write the correct regular expression based on the automaton provided in the question, (3) Give a regular expression that defines the language based on the description of the regular language, (4) Based on the given regular expression, use natural language to describe the regular language it defines. The reference answers corresponding to question types (1), (2), (3), and (4) are automaton, regular expression, regular expression, and natural language, respectively.
[0066] S2. If the type of the reference answer and / or the student answer is a regular expression or an automaton, a regular language and automaton processing model is constructed, and the reference answer and the student answer are respectively input into the regular language and automaton processing model to obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata.
[0067] In a specific embodiment, the processing of the regular language and automaton processing model specifically includes:
[0068] If the type of the reference answer and / or the student answer is a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton by using the Thompson construction algorithm, and the non-deterministic finite state automaton is subjected to deterministic and minimization operations to obtain a pre-complement deterministic finite state automaton;
[0069] If the type of the reference answer and / or the student answer is an automaton, the reference answer and / or the student answer is converted into a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton using the Thompson construction algorithm, the non-deterministic finite state automaton is determinized and minimized, and converted into a pre-complement deterministic finite state automaton;
[0070] Performing a complement operation on the deterministic finite state automaton before complementation to obtain a deterministic finite state automaton after complementation, wherein the deterministic finite state automaton before complementation and the deterministic finite state automaton after complementation are a set of deterministic finite state automata;
[0071] Among them, the state of the deterministic finite state automaton before complementation includes an accepting state. When performing the complementation operation, the dead state is added to the deterministic finite state automaton before complementation. The complementation operation includes: converting the accepting state in the deterministic finite state automaton before complementation into a non-accepting state, and converting the non-accepting state in the deterministic finite state automaton before complementation into an accepting state.
[0072] Specifically, the regular language and automaton processing model will process the reference answer and / or the student answer and convert it into a non-deterministic finite state automaton (NFA), wherein the algorithm for converting the regular expression into the non-deterministic finite state automaton adopts the Thompson construction algorithm, which is a classic algorithm. It constructs a non-deterministic finite state automaton based on recursion and basic structures such as connection, selection and closure; further, the non-deterministic finite state automaton is determined and minimized and converted into a deterministic finite state automaton (DFA). Modern computer technology has mature toolkits available for the processing of regular expressions and automata, such as the dkbrics.jar package in JAVA. In a deterministic finite state automaton, entering a dead state will cause the DFA to loop infinitely and cannot be transferred to a new state, and the dead state will generally be hidden. In an embodiment of the present application, when performing a complement operation on a deterministic finite state automaton before complementation, it is necessary to display the dead state completely before complementation.
[0073] S3, construct a string list generation model, input the first group of deterministic finite state automata into the string list generation model, generate a first positive example string list and a first counter example string list, input the second group of deterministic finite state automata into the string list generation model, generate a second positive example string list and a second counter example string list.
[0074] In a specific embodiment, the processing of the string list generation model specifically includes:
[0075] Input a deterministic finite state automaton. The deterministic finite state automaton is represented by a directed graph. The directed graph consists of a set of states and a set of directed edges. The set of states includes the initial state and the accepting state. The i-th directed edge is represented by (E i ,T i ,E i+1 ), where E i Indicates the starting state of the directed edge connection, T i The symbol for a directed edge, E i+1 Indicates the terminal state of the directed edge connection;
[0076] Visit all states and directed edges of the deterministic finite state automaton and generate an adjacent edge table;
[0077] Starting from the initial state, a depth-first traversal algorithm is used to traverse the adjacent edge table and generate a first path set;
[0078] The paths in the first path set are processed by using the Dijkstra algorithm and the acceptance state covering algorithm to obtain a second path set, wherein all paths in the second path set start at an initial state and end at an acceptance state, and the end states of all paths in the second path set cover all acceptance states;
[0079] Traverse all paths in the second path set and generate a string list corresponding to the deterministic finite state automaton.
[0080] Specifically, the Dijkstra algorithm is used to expand the paths in the first path set. When generating a string list of the deterministic finite state automaton after complementation, since the deterministic finite state automaton after complementation may have multiple accepting states, if the paths in the first path set do not terminate in the accepting state, the paths are expanded to the nearest accepting state during expansion. The accepting state covering algorithm is further used to perform accepting state covering processing on all the paths after the expansion processing to obtain the second path set, so that the termination states of all the paths in the second path set cover all the accepting states.
[0081] Specifically, after the adjacent edge table is generated, an edge coverage path set, i.e., a first path set, is generated based on the adjacent edge table, which satisfies the edge coverage criterion. The edge coverage criterion is one of the important coverage criteria in automaton testing. The edge coverage criterion satisfies that the test path covers the transition between each pair of adjacent states in the automaton as much as possible. The edge coverage criterion helps to improve the quality and comprehensiveness of the test path. Therefore, the test path generated according to the edge coverage criterion is enough to accurately find out the defects and deficiencies of the current automaton. Furthermore, there may be more than one acceptance state of a deterministic finite state automaton, and all acceptance states constitute an acceptance state set. Due to the characteristics of the depth-first traversal algorithm, in the generated first path set, not every acceptance state in the acceptance state set has a path terminating there. In the matching process of regular expressions, different acceptance states often have important significance. Therefore, after the Dijkstra algorithm is used to expand the paths in the first path set, an acceptance state coverage algorithm is also designed to ensure that at least one path for each acceptance state terminates there.
[0082] In a specific embodiment, all states and directed edges of a deterministic finite state automaton are accessed to generate an adjacent edge table, specifically including:
[0083] Construct an initially empty adjacency edge table, and set all states and directed edges of the deterministic finite state automaton at the initial moment to be unvisited;
[0084] If the deterministic finite state automaton has an unvisited state, selecting an unvisited state E1 and marking the state E1 as visited;
[0085] Determine whether there is an unvisited directed edge (E1, T1, E2) starting from state E1, where T1 represents the symbol of the directed edge starting from state E1, and E2 represents the terminal state connected by the directed edge starting from state E1. If not, return to the previous step, otherwise select an unvisited directed edge (E1, T1, E2), mark the directed edge (E1, T1, E2) as visited, and determine whether the state E2 connected by the directed edge (E1, T1, E2) has an outgoing edge. If state E2 has no outgoing edge, repeat this step until all directed edges starting from state E1 are marked as visited, otherwise visit all directed edges starting from state E2.
[0086] Select a directed edge (E2, T2, E3) with state E2 as the starting state, where T2 represents the symbol of the directed edge with state E2 as the starting state, and E3 represents the terminal state connected by the directed edge with state E2 as the starting state. Generate the adjacent opposite edge (E1, T1, E2, T2, E3) of state E1 according to the directed edge (E1, T1, E2) and the directed edge (E2, T2, E3). Determine whether the adjacent opposite edge (E1, T1, E2, T2, E3) is in the adjacent opposite edge table. If so, repeat this step until all directed edges with state E2 as the starting state have been selected. Otherwise, add the adjacent opposite edge (E1, T1, E2, T2, E3) to the adjacent opposite edge table, and repeat this step until all directed edges with state E2 as the starting state have been selected. When all directed edges with state E2 as the starting state have been selected, return to the previous step.
[0087] Repeat the above three steps until there is no unvisited state in the deterministic finite state automaton, and then end to obtain the adjacent edge table.
[0088] In a specific embodiment, starting from an initial state, a depth-first traversal algorithm is used to traverse the adjacent edge table and generate a first path set, which specifically includes:
[0089] Initialization step, constructing the path, the first path set and the label. The label indicates whether a new adjacent edge is added to the path in the traversal step of the current traversal state. Its value includes true and false. The path and the first path set at the initial moment are set to empty, the label at the initial moment is assigned to false, and all states of the deterministic finite state automaton at the initial moment and all adjacent edges in the adjacent edge table are set to unvisited;
[0090] In the input step, the initial state is input as the current traversal state;
[0091] A traversal step, traversing all adjacent edges of the current traversal state, and determining whether there are unvisited adjacent edges. If so, in response to determining that there is an unvisited simple loop in the adjacent edges of the current traversal state, wherein the simple loop represents an adjacent edge (E1, T1, E2, T2, E1) from state E1 to state E1, an unvisited simple loop is selected to be added to the path. In response to determining that there is no unvisited simple loop in the adjacent edges of the current traversal state, an unvisited adjacent edge of the current traversal state is selected to be added to the path, and all adjacent edges contained in the path are marked as visited, and the last state of the path is used as the current traversal state, and the label is assigned true, and this step is repeated. Otherwise, in response to determining that the path is not empty and the label is true, the path is added to the first path set, and the recursion ends with the current traversal state being the current layer of the recursive state. In response to determining that the path is not empty and the label is false, the recursion ends with the current traversal state being the current layer of the recursive state.
[0092] Determine whether the current traversal state is the initial state. If so, set the path to empty, assign false to the label, and return to the incoming step. Otherwise, delete several adjacent edges at the end of the path, and use the final state of the path after deleting the adjacent edges as the current traversal state. At this time, the path is the path after deleting the adjacent edges, so as to return to the previous recursive layer, assign false to the label, and return to the traversal step.
[0093] In response to determining that the path is empty, the unvisited adjacent edges in the adjacent edge table are added to the first path set, and the process ends to obtain the first path set.
[0094] Specifically, if state E1 and state E3 of the adjacent edge (E1, T1, E2, T2, E3) represent the same state, that is, E1=E3, then the adjacent edge (E1, T1, E2, T2, E1) is a simple circuit, and when selecting the adjacent edge, the simple circuit is given priority. The depth-first traversal algorithm is implemented by recursion. Assume that the previous traversal state and the current traversal state are both A, and the previous traversal state is C. After traversing the current traversal state A and adding an adjacent edge, the first path is obtained. The final state of the first path is B. When the traversal of state B is completed, that is, there is no adjacent edge of state B that has not been visited, and the recursion of this layer with state B as the recursive state ends. At this time, return to the previous recursion layer. It is necessary to delete the two adjacent edges at the end of the first path to obtain the second path. The final state of the second path is state A; the traversal of state A is completed, that is, there is no adjacent edge of state A that has not been visited, and the recursion of this layer with state A as the recursive state ends. At this time, return to the previous recursion layer. It is necessary to delete an adjacent edge at the end of the second path to obtain the third path. The final state of the third path is C.
[0095] In a specific embodiment, the pre-complement deterministic finite state automaton is input into a string generation model to generate a list of positive example strings; and the post-complement deterministic finite state automaton is input into the string generation model to generate a list of negative example strings.
[0096] S4, comparing the first positive example string list with the second positive example string list, and comparing the first negative example string list with the second negative example string list, obtaining a first comparison result and feeding it back.
[0097] Specifically, when the question type is (1), (2), or (3), the corresponding reference answer and / or student answer type is a regular expression or automaton. The system accepts the regular expression or automaton provided by the teacher and automatically generates a positive example string list and a negative example string list. After the student completes the question, the system automatically generates a positive example string list and a negative example string list based on the regular expression or automaton submitted by the student. By comparing the positive example string list and the negative example string list of the teacher and the student, intelligent review and automatic scoring are performed to obtain the comparison result, and the comparison result is fed back.
[0098] When the type of the reference answer and / or the student answer is a regular expression or an automaton, the overall framework diagram of the application of the regular language and automaton theory auxiliary teaching interaction method in the teaching system of the embodiment of the present application is as follows: Figure 2 As shown, the specific process is as follows:
[0099] 1. In the question generation module of the teaching system, the teacher uploads the question and the corresponding reference answer through the human-computer interaction interface. The reference answer type is a regular expression;
[0100] 2. The regular expression uploaded by the teacher is automatically generated into a first string list through the regular language and automaton processing model and the string list generation model. The first string list includes a first positive example string list and a first negative example string list. The topic, the regular expression and the first string list constitute the topic data, which is stored in the database of the teaching system data storage module;
[0101] 3. In the student answering module of the teaching system, students answer the questions uploaded by the teacher through the human-computer interaction interface and upload regular expressions or automata;
[0102] 4. Automatically generate a second string list using the regular expression or automaton uploaded by the student through the regular language and automaton processing model and the string list generation model, wherein the second string list includes a second positive example string list and a second negative example string list;
[0103] 5. The automatic scoring and automatic feedback module of the teaching system will automatically obtain the first string list and the second string list, and compare them to obtain a first comparison result, feed back the first comparison result to the student, and store it in the database of the data storage module for the convenience of the teacher to review, wherein the first comparison result includes the difference between the first string list and the second string list and the final score.
[0104] use Figure 2 The example question provided in the article "It consists of only two elements, 0 and 1, and starts with 0 or 10 and ends with 01" is explained in detail. The specific steps are as follows:
[0105] 1. In the question generation module of the teaching system, the teacher uploads the above question and the corresponding reference answer through the human-computer interaction interface. The reference answer is the regular expression "(0|10)(0|1)*01";
[0106] 21. Input the regular expression "(0|10)(0|1)*01" into the regular language and automaton processing model and convert it into Figure 3 The pre-complement deterministic finite state automaton shown in FIG. 1 is expressed as a directed graph, which consists of a set of states and a set of directed edges. The set of states includes the initial state A and the accepting state D. State F is a dead state. Here, state F is hidden and not shown in FIG. Figure 3 As shown in , the set of accepted states is ;
[0107] 221. Input the complement pre-deterministic finite state automaton into the string list generation model. First, refer to Figure 4 The flowchart shown in the figure visits all states and directed edges of the deterministic finite state automaton before complementation and generates an adjacent edge table. The detailed steps are as follows:
[0108] 2211. Construct an initially empty adjacent edge table, and set all states and directed edges of the pre-complement deterministic finite state automaton at the initial moment to be unvisited;
[0109] 2212. The state set of the deterministic finite state automaton before the complementation Select an unvisited state and mark the selected state as visited, with the initial state A as the first selected state;
[0110] 2213. Visit all directed edges starting from the initial state A, select an unvisited directed edge (A, 0, B), and mark the directed edge (A, 0, B) as visited;
[0111] 2214. At this time, state B has outgoing edges, namely (B, 1, B) and (B, 0, C). These two directed edges can respectively form the adjacent opposite edges of the initial state A with the directed edge (A, 0, B), namely (A, 0, B, 1, B) and (A, 0, B, 0, C). These two adjacent opposite edges are not repeated in the adjacent opposite edge table. They are added to the adjacent opposite edges of the initial state A in the adjacent opposite edge table. Return to step 2213. The initial state A still has an unvisited directed edge (A, 1, E), and at this time, state E has an outgoing edge (E, 0, B). The initial state A still has an adjacent opposite edge (A, 1, E, 0, B), which is added to the adjacent opposite edge table.
[0112] 2215. Status Set For the remaining unvisited states, refer to steps 2212 to 2214 to perform corresponding operations to generate an adjacent edge table, as shown in Table 1;
[0113] Table 1 Adjacent edge table
[0114]
[0115] 222. Secondly, refer to Figure 5 The flowchart shown in the figure starts from the initial state A of the deterministic finite state automaton before complementation, and uses the depth-first traversal algorithm to traverse the adjacent edge table generated in the above steps, and generates the first path set. The detailed steps are described as follows:
[0116] 2221. Construct a path, a first path set and a label, set the path and the first path set at the initial moment to be empty, assign the label at the initial moment to be false, and set all states of the deterministic finite state automaton at the initial moment and all adjacent edges in the adjacent edge table to be unvisited;
[0117] 2222. Pass the initial state A as the current traversal state;
[0118] 2223. Start traversal: Select an unvisited adjacent edge (A, 0, B, 0, C) from the adjacent edge table of the initial state A. At this time, the path is (A, 0, B, 0, C), and mark the adjacent edge (A, 0, B, 0, C) as visited. Set state C as the current traversal state and assign true to the label.
[0119] Select an unvisited adjacent edge in the adjacent edge table of state C, give priority to simple loops, and select (C, 0, C, 0, C). At this time, the path is (A, 0, B, 0, C, 0, C, 0, C), and mark the adjacent edges (C, 0, C, 0, C) and (B, 0, C, 0, C) as visited. Set state C as the current traversal state and assign the label value to true.
[0120] Select an unvisited adjacent edge in the adjacent edge table of state C, give priority to simple loops, and select (C, 1, D, 0, C). At this time, the path is (A, 0, B, 0, C, 0, C, 0, C, 1, D, 0, C), and mark the adjacent edges (C, 1, D, 0, C) and (C, 0, C, 1, D) as visited. Set state C as the current traversal state and assign the label value to true.
[0121] Select an unvisited adjacent edge in the adjacent edge table of state C, select (C,1,D,1,B), then the path is (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B), and mark the adjacent edges (C,1,D,1,B) and (D,0,C,1,D) as visited, take state B as the current traversal state, and assign the label value to true;
[0122] Select an unvisited adjacent edge in the adjacent edge table of state B, select (B,1,B,1,B), then the path is (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,1,B,1,B), and mark the adjacent edges (B,1,B,1,B) and (D,1,B,1,B) as visited, take state B as the current traversal state, and assign the label value to true;
[0123] Select an unvisited adjacent edge in the adjacent edge table of state B, select (B,1,B,0,C), then the path is (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,1,B,1,B,1,B,0,C), and mark the adjacent edge (B,1,B,0,C) as visited, take state C as the current traversal state, and assign the label value to true;
[0124] State C has no unvisited adjacent edges, and the label is true. Add the path (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,1,B,1,B,1,B,0,C) to the first path set, and the current layer recursion ends;
[0125] 2224. Delete the adjacent edges (B,1,B,0,C) and (B,1,B,1,B) at the end of the path (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,1,B,1,B,0,C) to get the path (A,0,B,0,C,0,C,0,C,0,C,1,D,0,C,1,D,1,B) after deleting the adjacent edges. Take state B as the current traversal state, return to the previous recursive layer, and assign the label to false.
[0126] Execute the corresponding operation of step 2223, select an unvisited adjacent edge in the adjacent edge table of state B, select (B, 0, C, 1, D), then the path is (A, 0, B, 0, C, 0, C, 0, C, 1, D, 0, C, 1, D, 1, B, 0, C, 1, D), and mark the adjacent edges (B, 0, C, 1, D) and (D, 1, B, 0, C) as visited, and use state D as the current traversal state , assign the label to true; select an unvisited adjacent edge in the adjacent edge table of state D, select (D,0,C,0,C), then the path is (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,0,C,1,D,0,C,0,C), and mark the adjacent edge (D,0,C,0,C) as visited, take state C as the current traversal state, and assign the label to true;
[0127] There is no unvisited adjacent edge in state C, and the label is true. Add the path (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,0,C,1,D,0,C,0,C) to the first path set, end the current layer recursion, and return to the previous layer recursion. Delete the adjacent edge (D,0,C,0,C) at the end of the path to get the path after deleting the adjacent edge (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,0,C,1,D). Take state D as the current traversal state and assign the label to false.
[0128] State D does not have any unvisited adjacent edges, and the label is false. The path (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,0,C,1,D) is not added to the first path set. The current layer recursion ends, and the previous layer recursion is directly returned. The adjacent edge (B,0,C,1,D) at the end of the path is deleted to obtain the path (A,0,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B) after deleting the adjacent edges. State B is used as the current traversal state, and the label is assigned to false.
[0129] There is no unvisited adjacent edge in state B. Referring to the above analysis, return to the previous recursive layer until the path after deleting the adjacent edge is (A, 0, B, 0, C). Use state C as the current traversal state and assign the label to false. There is no unvisited adjacent edge in state C. Do not add the path (A, 0, B, 0, C) to the first path set. The current recursive layer ends and returns to the previous recursive layer. Delete the adjacent edge (A, 0, B, 0, C) at the end of the path to obtain the path (A) after deleting the adjacent edge. Use the initial state A as the current traversal state, so set the path to empty, assign the label to false, return to step 2222, and pass the initial state A in as the current traversal state.
[0130] Execute the corresponding operation of step 2223, select an unvisited adjacent edge (A, 1, E, 0, B) from the adjacent edge table of the initial state A, and the path is (A, 1, E, 0, B), and mark the adjacent edge (A, 1, E, 0, B) as visited, and use state B as the current traversal state, assign the label to true, and there is no unvisited adjacent edge in state B, and add the path (A, 1, E, 0, B) to the first path set; referring to the above analysis, execute the corresponding operation of step 2223, add the path (A, 0, B, 1, B) to the first path set, return to the previous recursive layer, delete the adjacent edge (A, 0, B, 1, B) at the end of the path, use the initial state A as the current traversal state, set the path to empty, return to step 2222, and pass the initial state A in as the current traversal state;
[0131] 2225. There is no unvisited adjacent edge in state A, and the path is empty. At this time, there are still two adjacent edges (E, 0, B, 1, B) and (E, 0, B, 0, C) in the adjacent edge table that have not been visited. The two adjacent edges (E, 0, B, 1, B) and (E, 0, B, 0, C) are added to the first path set, as shown in Table 2;
[0132] Table 2 The first path set generated by the pre-complement deterministic finite state automaton corresponding to the reference answer
[0133]
[0134] Then, the Dijkstra algorithm is used to extend the paths in the first path set to obtain the extended paths, and the acceptance state covering algorithm is used to perform acceptance state covering processing on all the extended paths to obtain the second path set. As shown in Table 3, all the paths in the second path set start at the initial state A and end at the acceptance state D, and the end states of all the paths in the second path set have covered the acceptance state set. All accepting states in ;
[0135] 224. Traverse all paths in the second path set to generate a first positive example string list corresponding to the pre-complement deterministic finite state automaton, as shown in Table 3;
[0136] Table 3 The second path set generated by the pre-complement deterministic finite state automaton corresponding to the reference answer and the corresponding first positive example string list
[0137]
[0138] 23. Perform the complement operation on the pre-complement deterministic finite state automaton. At this time, the state F is displayed. The accepting state in the pre-complement deterministic finite state automaton is converted to a non-accepting state, and the non-accepting state is converted to an accepting state, and the following is obtained: Figure 6 The deterministic finite state automaton after complementation shown in the figure accepts the state set as ,refer to Figure 4 , Figure 5 The flowchart shown in step 223 and step 224 generates an adjacent edge table and a first path set according to the complemented deterministic finite state automaton corresponding to the reference answer, and uses the Dijkstra algorithm to expand the paths in the first path set so that the paths start at the initial state A and end at the accepting state, thereby obtaining the first path set after expansion, as shown in Table 4; According to Table 4, the ending state of the paths in the first path set after expansion has covered the accepting state set The acceptance state covering algorithm is used to cover the states B, C, and F in all the paths after the expansion. The specific steps are as follows: select the first path (A,1,E,0,B,1,B,1,B,1,B,0,C,0,C,0,C,1,D,0,C,1,D,1,B,0,C,1,D,0,C,0,C), and reduce one directed edge from the end of the path in turn to touch the uncovered acceptance state E to obtain the path (A,1,E). Continue to reduce one directed edge from the end of the path in turn to touch the uncovered acceptance state A to obtain the path (A). Add the paths (A,1,E) and (A) to the first path set after the expansion to obtain the second path set. At this time, the acceptance state set Each accepting state in has at least one path terminating. The first counterexample string list corresponding to the complemented deterministic finite state automaton is generated according to the second path set, as shown in Table 5, where ε represents an empty string;
[0139] Table 4 The first path set after expansion processing
[0140]
[0141] Table 5 The second path set generated by the deterministic finite state automaton after complementation corresponding to the reference answer and the corresponding first counterexample string list
[0142]
[0143] 3. In the student answering module of the teaching system, students answer the questions uploaded by the teacher through the human-computer interaction interface and upload the regular expression "(0|1)*01";
[0144] 4. Generate a second string list by processing the regular expression or automaton uploaded by the student through the regular language and automaton processing model and the string list generation model, referring to steps 21 to 23, wherein the second string list includes a second positive example string list and a second negative example string list;
[0145] 5. The automatic scoring and automatic feedback module of the teaching system automatically obtains the first positive example string list, the first negative example string list, the second positive example string list and the second negative example string list, compares the first positive example string list with the second positive example string list, and compares the first negative example string list with the second negative example string list to obtain a first comparison result, such as Figure 7 As shown, the student's answer correctly accepted "0101" and correctly rejected "ε", and the final score was 7 / 10. The scoring basis was: the basic score was 5 points, and if a misjudgment was made on this basis, that is, the string was incorrectly accepted or rejected, 1 point was deducted, and if the string was correctly accepted or rejected, 1 point was added; the first comparison result was fed back to the student and stored in the database of the data storage module for the teacher to consult.
[0146] S5: If the type of the reference answer and / or the student answer is natural language, the reference answer and the student answer are compared for similarity to obtain a second comparison result and provide feedback.
[0147] Specifically, when the question type is (4), the corresponding reference answer and / or student answer type is natural language. The system accepts the correct natural language description provided by the teacher, compares the correct natural language description provided by the teacher with the natural language description submitted by the student for similarity, and automatically scores them to obtain a second comparison result, which is then fed back as feedback.
[0148] The above steps S1-S5 do not necessarily represent the order between the steps, but are represented by step symbols, and the order between the steps can be adjusted.
[0149] Further references Figure 8 As an implementation of the methods shown in the above figures, the present application provides an embodiment of an auxiliary teaching interactive device for regular language and automaton theory, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0150] The embodiment of the present application provides an auxiliary teaching interactive device for regular language and automata theory, including:
[0151] The question data acquisition module 1 is configured to acquire questions, reference answers corresponding to the questions, and student answers, wherein the types of the reference answers and student answers include regular expressions, automata, and natural languages;
[0152] The automaton generation module 2 is configured to construct a regular language and automaton processing model if the type of the reference answer and / or the student answer is a regular expression or an automaton, input the reference answer and the student answer into the regular language and automaton processing model respectively, and obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata;
[0153] The string list generation module 3 is configured to construct a string list generation model, input the first group of deterministic finite state automata into the string list generation model to generate a first positive example string list and a first negative example string list, and input the second group of deterministic finite state automata into the string list generation model to generate a second positive example string list and a second negative example string list;
[0154] A first scoring module 4 is configured to compare the first positive example string list with the second positive example string list, and compare the first negative example string list with the second negative example string list, obtain a first comparison result and feedback;
[0155] The second scoring module 5 is configured to compare the reference answer and the student answer for similarity if the type of the reference answer and / or the student answer is natural language, obtain a second comparison result and feedback it.
[0156] The embodiment of the present application provides an auxiliary teaching interaction method and device for regular language and automata theory, which can assist teachers in teaching the relevant knowledge of regular language and automata theory, and utilize the mutual conversion between regular expressions and automata and the automatic generation of positive example string lists and negative example string lists of regular expressions to provide real-time feedback when students complete the questions assigned by teachers, thereby helping students to quickly understand regular languages and automata, and helping students of computer majors to learn and master the relevant knowledge of the theory and application of regular languages and automata in courses such as "Compiler Principles", "Computational Theory", and "Data Structures and Algorithms", and can also complete intelligent review and automatic grading, effectively improving the teaching feedback interaction efficiency of related courses.
[0157] Fig. 9 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Fig. 9 As shown, the electronic device of this embodiment includes: a processor 901 and a memory 902; wherein the memory 902 is used to store computer-executable instructions; the processor 901 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.
[0158] Optionally, the memory 902 may be independent or integrated with the processor 901 .
[0159] When the memory 902 is independently provided, the electronic device further includes a bus 903 for connecting the memory 902 and the processor 901 .
[0160] The embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When the processor 901 executes the computer execution instructions, the above method is implemented.
[0161] The embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by the processor 901, the above method is implemented.
[0162] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0163] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0164] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit. The above-mentioned module-composed unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0165] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor 901 to perform some steps of the methods of various embodiments of the present application.
[0166] It should be understood that the processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor 901 may be any conventional processor 901, etc. The steps of the method disclosed in the invention may be directly embodied in the execution of the hardware processor 901, or may be executed by a combination of hardware and software modules in the processor 901.
[0167] The memory 902 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disk.
[0168] The bus 903 may be an Industry Standard Architecture (ISA), a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus 903 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus 903 in the drawings of the present application is not limited to only one bus 903 or one type of bus 903.
[0169] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0170] An exemplary storage medium is coupled to the processor 901, so that the processor 901 can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor 901. The processor 901 and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor 901 and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0171] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0172] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An interactive teaching method for regular language and automata theory, characterized in that: The following steps are involved: Obtaining a question, a reference answer corresponding to the question, and a student answer, wherein the types of the reference answer and the student answer both include regular expressions, automata, and natural languages; If the type of the reference answer and / or the student answer is a regular expression or an automaton, a regular language and automaton processing model is constructed, and the reference answer and the student answer are respectively input into the regular language and automaton processing model to obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata. The processing process of the regular language and automaton processing model specifically includes: If the type of the reference answer and / or the student answer is a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton using the Thompson construction algorithm, and the non-deterministic finite state automaton is subjected to deterministic and minimization operations to obtain a pre-complement deterministic finite state automaton; If the type of the reference answer and / or the student answer is an automaton, convert the reference answer and / or the student answer into a regular expression, use the Thompson construction algorithm to convert the reference answer and / or the student answer into a non-deterministic finite state automaton, perform determinization and minimization operations on the non-deterministic finite state automaton, and convert it into a pre-complement deterministic finite state automaton; Performing a complement operation on the pre-complement deterministic finite state automaton to obtain a post-complement deterministic finite state automaton, wherein the pre-complement deterministic finite state automaton and the post-complement deterministic finite state automaton are a group of deterministic finite state automata; The state of the pre-complement deterministic finite state automaton includes an accepting state. When performing a complement operation, a dead state is added to the pre-complement deterministic finite state automaton. The complement operation includes: converting the accepting state in the pre-complement deterministic finite state automaton into a non-accepting state, and converting the non-accepting state in the pre-complement deterministic finite state automaton into an accepting state; Construct a string list generation model, input the first group of deterministic finite state automata into the string list generation model to generate a first positive example string list and a first negative example string list, input the second group of deterministic finite state automata into the string list generation model to generate a second positive example string list and a second negative example string list, input the pre-complement deterministic finite state automata into the string generation model to generate a positive example string list; input the post-complement deterministic finite state automata into the string generation model to generate a negative example string list; the processing process of the string list generation model specifically includes: Input a deterministic finite state automaton, wherein the deterministic finite state automaton is expressed as a directed graph, wherein the directed graph consists of a set of states and a set of directed edges, wherein the set of states includes an initial state and an accepting state, and the i-th directed edge is represented as (E i ,T i ,E i+1 ), where E i Indicates the starting state of the directed edge connection, T i The symbol for a directed edge, E i+1 Indicates the terminal state of the directed edge connection; Access all states and directed edges of the deterministic finite state automaton to generate an adjacent edge table; Starting from the initial state, traverse the adjacent edge table using a depth-first traversal algorithm and generate a first path set; Using the Dijkstra algorithm and the acceptance state covering algorithm to process the paths in the first path set, a second path set is obtained, all the paths in the second path set start at an initial state and end at an acceptance state, and the end states of all the paths in the second path set cover all the acceptance states; Traversing all paths in the second path set to generate a string list corresponding to the deterministic finite state automaton; Compare the first positive example string list with the second positive example string list, and compare the first negative example string list with the second negative example string list, obtain a first comparison result and feed it back; If the type of the reference answer and / or the student answer is natural language, the reference answer and the student answer are compared for similarity to obtain a second comparison result and feed it back.
2. The interactive teaching method of regular language and automata theory according to claim 1, characterized in that: The step of accessing all states and directed edges of the deterministic finite state automaton and generating an adjacent edge table specifically includes: Constructing an initially empty adjacent edge table, and setting all states and directed edges of the deterministic finite state automaton at the initial moment to be unvisited; If the deterministic finite state automaton has an unvisited state, selecting an unvisited state E1 and marking the state E1 as visited; Determine whether there is an unvisited directed edge (E1, T1, E2) starting from the state E1, wherein T1 represents the symbol of the directed edge starting from the state E1, and E2 represents the terminal state connected by the directed edge starting from the state E1. If not, return to the previous step. Otherwise, select an unvisited directed edge (E1, T1, E2), mark the directed edge (E1, T1, E2) as visited, and determine whether the state E2 connected by the directed edge (E1, T1, E2) has an outgoing edge. If the state E2 has no outgoing edge, repeat this step until all directed edges starting from the state E1 are marked as visited. Otherwise, visit all directed edges starting from the state E2. Select a directed edge (E2, T2, E3) with the state E2 as the starting state, where T2 represents the symbol of the directed edge with the state E2 as the starting state, and E3 represents the terminal state of the directed edge connection with the state E2 as the starting state, and generate the adjacent opposite edge (E1, T1, E2, T2, E3) of the state E1 according to the directed edge (E1, T1, E2) and the directed edge (E2, T2, E3), and determine whether the adjacent opposite edge (E1, If the state E2 is the starting state, then the adjacent edge (E1, T1, E2, T2, E3) is in the adjacent edge table. If so, repeat this step until all directed edges starting from the state E2 have been selected. Otherwise, add the adjacent edge (E1, T1, E2, T2, E3) to the adjacent edge table, and repeat this step until all directed edges starting from the state E2 have been selected. When all directed edges starting from the state E2 have been selected, return to the previous step. Repeat the above three steps until there is no unvisited state in the deterministic finite state automaton, and then end to obtain the adjacent edge table.
3. The interactive teaching method of regular language and automata theory according to claim 2, characterized in that: The step of traversing the adjacent edge table using a depth-first traversal algorithm from the initial state and generating a first path set specifically includes: Initialization step, constructing a path, a first path set and a label, wherein the label indicates whether a new adjacent edge is added to the path in the traversal step of the current traversal state, and its value includes true and false, setting the path and the first path set at the initial moment to empty, assigning the label at the initial moment to false, and setting all states of the deterministic finite state automaton at the initial moment and all adjacent edges in the adjacent edge table to unvisited; In the step of inputting, the initial state is input as the current traversal state; A traversal step, traversing all adjacent edges of the current traversal state, determining whether there are unvisited adjacent edges, if so, in response to determining that there is an unvisited simple loop in the adjacent edges of the current traversal state, wherein a simple loop represents an adjacent edge (E1, T1, E2, T2, E1) from state E1 to state E1, then selecting an unvisited simple loop to join the path, in response to determining that there is no unvisited simple loop in the adjacent edges of the current traversal state, then selecting a current traversal state. The unvisited adjacent edges of the state are added to the path, all the adjacent edges contained in the path are marked as visited, and the final state of the path is used as the current traversal state, the label is assigned to be true, and this step is repeated; otherwise, in response to determining that the path is not empty and the label is true, the path is added to the first path set, and the recursion ends with the current level of the current traversal state being the recursive state; in response to determining that the path is not empty and the label is false, the recursion ends with the current level of the current traversal state being the recursive state; Determine whether the current traversal state is the initial state. If so, set the path to empty, assign the label to false, and return to the incoming step. Otherwise, delete several adjacent edges at the end of the path, and use the final state of the path after deleting the adjacent edges as the current traversal state. At this time, the path is the path after deleting the adjacent edges, so as to return to the previous recursive layer, assign the label to false, and return to the traversal step. In response to determining that the path is empty, the unvisited adjacent edges in the adjacent edge table are added to the first path set, and the process ends to obtain the first path set.
4. An interactive teaching device for regular language and automata theory, characterized in that: include: A question data acquisition module is configured to acquire questions, reference answers corresponding to the questions, and student answers, wherein the types of the reference answers and student answers include regular expressions, automata, and natural languages; The automaton generation module is configured to construct a regular language and automaton processing model if the type of the reference answer and / or the student answer is a regular expression or an automaton, input the reference answer and the student answer into the regular language and automaton processing model respectively, and obtain a first group of deterministic finite state automata and a second group of deterministic finite state automata. The processing process of the regular language and automaton processing model specifically includes: If the type of the reference answer and / or the student answer is a regular expression, the reference answer and / or the student answer is converted into a non-deterministic finite state automaton using the Thompson construction algorithm, and the non-deterministic finite state automaton is subjected to deterministic and minimization operations to obtain a pre-complement deterministic finite state automaton; If the type of the reference answer and / or the student answer is an automaton, convert the reference answer and / or the student answer into a regular expression, use the Thompson construction algorithm to convert the reference answer and / or the student answer into a non-deterministic finite state automaton, perform determinization and minimization operations on the non-deterministic finite state automaton, and convert it into a pre-complement deterministic finite state automaton; Performing a complement operation on the pre-complement deterministic finite state automaton to obtain a post-complement deterministic finite state automaton, wherein the pre-complement deterministic finite state automaton and the post-complement deterministic finite state automaton are a group of deterministic finite state automata; The state of the pre-complement deterministic finite state automaton includes an accepting state. When performing a complement operation, a dead state is added to the pre-complement deterministic finite state automaton. The complement operation includes: converting the accepting state in the pre-complement deterministic finite state automaton into a non-accepting state, and converting the non-accepting state in the pre-complement deterministic finite state automaton into an accepting state; The string list generation module is configured to construct a string list generation model, input the first group of deterministic finite state automata into the string list generation model to generate a first positive example string list and a first negative example string list, input the second group of deterministic finite state automata into the string list generation model to generate a second positive example string list and a second negative example string list, input the pre-complement deterministic finite state automata into the string generation model to generate a positive example string list; input the post-complement deterministic finite state automata into the string generation model to generate a negative example string list; the processing process of the string list generation model specifically includes: Input a deterministic finite state automaton, wherein the deterministic finite state automaton is expressed as a directed graph, wherein the directed graph consists of a set of states and a set of directed edges, wherein the set of states includes an initial state and an accepting state, and the i-th directed edge is represented as (E i ,T i ,E i+1 ), where E i Indicates the starting state of the directed edge connection, T i The symbol for a directed edge, E i+1 Indicates the terminal state of the directed edge connection; Access all states and directed edges of the deterministic finite state automaton to generate an adjacent edge table; Starting from the initial state, traverse the adjacent edge table using a depth-first traversal algorithm and generate a first path set; Using the Dijkstra algorithm and the acceptance state covering algorithm to process the paths in the first path set, a second path set is obtained, all the paths in the second path set start at an initial state and end at an acceptance state, and the end states of all the paths in the second path set cover all the acceptance states; Traversing all paths in the second path set to generate a string list corresponding to the deterministic finite state automaton; A first scoring module is configured to compare the first positive example string list with the second positive example string list, and compare the first negative example string list with the second negative example string list, obtain a first comparison result and feedback it; The second scoring module is configured to compare the reference answer and the student answer for similarity if the type of the reference answer and / or the student answer is natural language, obtain a second comparison result and provide feedback.
5. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Emergency management system and method for public emergencies
CN101976376A
Self-adaptive recommendation method for online programming teaching and related equipment
CN115985152A
