Intelligent homework correcting method based on syntax tree and semantic analysis
By adopting a method based on syntax tree and semantic analysis in the intelligent job correction technology, the problem of inefficient and inaccurate comparison of existing technologies when processing complex expressions is solved, and more efficient and accurate job correction is achieved.
Patent Information
- Application Number
- CN202411656874.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing job intelligent correction technology is inefficient when processing complex expressions, easily ignores character order information, and methods based on semantic similarity cannot give accurate results.
The intelligent correction method of job answers is adopted based on syntax tree and semantic analysis. Through direct comparison of strings, formula recognition and syntax tree analysis, text cleaning and standardization processing, semantic vector encoding and cosine similarity comparison, SWRL semantic conversion and complex semantic comparison, and other steps, intelligent correction of job answers is achieved.
It improves the accuracy and efficiency of correction, overcomes the problem of traditional methods being insensitive to character order, and reduces the uncertainty in semantic similarity comparison, and obtains more accurate correction results.
Smart Images

Figure CN119578398A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent teaching technology, and in particular to an intelligent homework marking method based on syntax tree and semantic analysis. Background Art
[0002] With the rapid advancement of educational informatization, intelligent homework grading technology has become a key means to improve students' learning efficiency and reduce the tutoring burden of teachers and parents. Through intelligent technology, homework grading can not only automate a large number of repetitive tasks, but also provide more timely and accurate feedback to help students better understand knowledge points. This type of technology is expected to greatly improve the quality of education and teaching efficiency.
[0003] The current mainstream homework grading technologies are mainly divided into two categories: methods based on distance measurement and methods based on semantic similarity; methods based on distance measurement mostly use algorithms such as Levenshtein distance and edit distance to measure the similarity between two strings, by calculating the number of string editing operations or set intersection and comparison results. Although such methods are flexible and applicable to various scenarios, they are inefficient when processing complex expressions and tend to ignore the order information of characters; on the other hand, with the advancement of deep learning technology, grading methods based on semantic similarity have gradually emerged. By using deep neural networks (such as BERT, Transformer, etc.) to extract text semantic information, and then using cosine similarity and other means to calculate the proximity of semantic vectors, these methods perform well in semantic level comparison; however, such technologies can only judge the overall semantics of the text, and cannot give accurate results for texts that require strict logic and details, such as mathematical expressions.
[0004] Although traditional solutions can provide a certain degree of intelligence, the distance measurement-based calculation method used by traditional solutions is highly complex and insensitive to character order, which can easily lead to misjudgment. The method based on semantic similarity ignores detailed information and cannot process texts that require precise logic. Therefore, when faced with scenarios such as mathematical expressions and formulas that require strict comparison, existing technologies often find it difficult to provide accurate and efficient solutions. Therefore, there is an urgent need for an intelligent homework grading method based on syntax trees and semantic analysis to solve such problems. Summary of the invention
[0005] In view of the above existing problems, the present invention is proposed.
[0006] The present invention provides an intelligent homework grading method based on syntax tree and semantic analysis to solve the problems of existing intelligent homework grading methods, such as high computational complexity and long time consumption; insensitivity to the order of characters, which easily leads to misjudgment; and texts with highly similar semantics may be two completely different texts in essence, resulting in grading errors.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] The present invention provides a method for intelligently correcting homework based on syntax tree and semantic analysis, which comprises:
[0009] Step S1, input processing, receiving the homework answer S and the standard answer N to be corrected;
[0010] Step S2, direct string comparison, performing direct string comparison based on the answer S received in step S1 and the standard answer N;
[0011] Step S3, formula recognition and syntax tree parsing, judging whether S and N are both pure formulas, if it is detected that both are pure mathematical formulas, entering the formula parsing step;
[0012] Step S4: word segmentation and text cleaning. If S and N are not pure formulas, the input answer and the standard answer are cleaned and standardized, and then the character strings are compared again.
[0013] Step S5, compare the semantic vector encoding with the cosine similarity to determine whether S and N are both plain texts. If it is detected that both are plain texts, semantic vector encoding is performed and then compared;
[0014] Step S6, SWRL semantic transformation and complex semantic comparison, if S and N contain words and letters, use SWRL semantic web rule language to perform semantic transformation and comparison;
[0015] Step S7, finally outputting the correction result, and returning the final correction result according to the judgment results of steps S2 to S6.
[0016] Furthermore, in step S2, if the character strings are completely consistent, the correction result is determined to be correct and the process ends. If the character strings are not the same, the next step of processing is entered.
[0017] Furthermore, in the formula parsing step of step S3, the formula is parsed into a multi-branch syntax tree structure, and addition nodes and multiplication nodes are introduced to process the commutative law and associative law in mathematical expressions. The parsed syntax tree structures are compared to determine whether two formulas are equivalent.
[0018] Furthermore, in the formula analysis step of step S3:
[0019] If the structures of the syntax trees are the same, that is, the formulas are equivalent, the correction result is determined to be correct and the process ends;
[0020] If the syntax tree structures are different, the correction result is determined to be wrong and the process ends.
[0021] Furthermore, in step S4, if the character strings are completely consistent, the correction result is determined to be correct and the process ends; if the character strings are not the same, the process proceeds to the next step.
[0022] Furthermore, in step S4, text cleaning and standardization processing includes:
[0023] Use education-specific dictionaries for word segmentation recognition. For example, special terms such as "perpendicular bisector" and "inscribed triangle" are recognized as fixed concepts. Remove unnecessary spaces and punctuation marks to simplify input text.
[0024] Furthermore, in step S4, the text cleaning and standardization process further includes:
[0025] Unify the representation of formulas and use LaTeX to format mathematical expressions; standardize specific symbols (such as triangle symbols) so that they are consistent in input and standard answers; unify unit descriptions to avoid misjudgments due to inconsistent unit writing.
[0026] Furthermore, in step S4, based on the word segmentation, word analysis is performed using a special education dictionary.
[0027] Furthermore, in step S5, the semantic vector encoding and cosine similarity comparison method includes:
[0028] Through semantic vector encoding, the text S and N are converted into semantic vector representations, and the pre-trained Transformer model is used to convert the text into vector F s and F n , and calculate the semantic similarity through cosine similarity. If the cosine similarity of the semantic vector is greater than the preset threshold, the correction result is judged to be correct. If the similarity is lower than the threshold, it is judged to be wrong and the process ends.
[0029] Furthermore, in step S6, the semantic conversion and comparison are performed in the following manner:
[0030] Segment the student answer S and the standard answer N, extract key semantic relationships (such as points, lines, angles, etc. in geometry problems), and convert the parsed text into SWRL rules. For example, "Lines AB and CD intersect at point E" can be expressed as `Intersection(Line(AB),Line(CD),Point(E))`
[0031] Use an inference engine (such as Pellet) to perform rule reasoning, generate reasoning results for the two rules, compare the reasoning results of the student's answer S with the standard answer N, and determine whether the semantics are consistent. If the reasoning results are consistent, the answer is judged to be correct, otherwise it is judged to be wrong.
[0032] The beneficial effects of the present invention are:
[0033] The present invention, based on educational application scenarios, adopts a dictionary suitable for educational scenarios to improve the accuracy of word segmentation and part-of-speech recognition, and simultaneously performs text cleaning and text formatting to improve the accuracy of subsequent correction.
[0034] The present invention proposes a syntax tree suitable for formula parsing, which can compare formulas more simply and accurately.
[0035] The present invention adopts a semantic SWRL consistency representation method, which can more accurately compare whether the user answer and the standard answer are equivalent.
[0036] The present invention proposes a homework grading method that combines text cleaning, string comparison, formula semantic comparison, text semantic comparison, and rule semantic comparison, which can improve efficiency while taking into account the accuracy of grading. It overcomes the problem that traditional string comparison methods are insensitive to the order of characters and are prone to misjudgment. At the same time, it greatly reduces the uncertainty in semantic similarity comparison methods and obtains more accurate grading results. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0038] Figure 1 It is a flow chart of the intelligent homework correction method based on syntax tree and semantic analysis of the present invention;
[0039] Figure 2 It is a schematic diagram of the expression tree structure of the present invention. DETAILED DESCRIPTION
[0040] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0041] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0042] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0043] Example 1, reference Figure 1 and Figure 2 This embodiment provides a method for intelligently correcting homework based on syntax tree and semantic analysis, comprising the following steps:
[0044] First, for each formula or text string S to be corrected and the standard answer N, if the strings are the same, the correction is correct.
[0045] Specifically, the present invention uses a dictionary specially used in education to assist in word segmentation, for example, to identify special words such as "perpendicular bisector" and "inscribed triangle".
[0046] At the same time, the text is cleaned to remove extra spaces and punctuation marks, the formulas are uniformly expressed in Latex format, the text and symbol representation of triangles are unified, the description of units is unified, etc., to facilitate subsequent string comparison and semantic comparison.
[0047] Since the text has been preprocessed, the present invention directly compares whether the two character strings are identical. If they are identical, the correction is correct.
[0048] If it is a pure formula of S and N, enter the formula comparison module to analyze and compare the formula.
[0049] When S and N are in the form of pure formulas, the present invention converts S and N into syntax trees and performs comparison through the syntax trees.
[0050] like Figure 2 As shown, based on the traditional binary tree, the present invention designs a multi-tree syntax tree according to the characteristics of the expression.
[0051] Due to the commutative and associative properties of multiplication and addition in mathematical expressions, comparison on a traditional binary tree has a high degree of comparison complexity and cannot adapt to the characteristics of mathematical expressions.
[0052] Therefore, the present invention defines "continuous addition" and "continuous multiplication" nodes, and the sub-nodes of "continuous addition" and "continuous multiplication" satisfy the commutative law and the associative law, so that two expressions can be compared more conveniently and accurately to see whether they are equivalent.
[0053] like Figure 2 As shown, for the expression x 2 +y 2Take the analysis of +2xy=0 as an example. The left side is a traditional binary syntax tree structure, where each operator and operand is a node of the tree, and the expression is divided into a series of binary operations:
[0054] The top node is the equal sign =, and the left child node is the entire expression x 2 +y 2 +2xy, the right child node is a constant 0;
[0055] Expression x 2 +y 2 +2xy is split into multiple levels of binary operations:
[0056] The plus sign + is a top-level operator, and its left child is x. 2 , the right child node is y 2 +2xy;
[0057] y 2 +2xy is decomposed into another addition operation, with the left child being y 2 , the right child node is 2xy;
[0058] Each power operation x 2 and 2 Then decomposed into multiplication operations x·x and y·y respectively, and 2xy is decomposed into multiplication 2·x·y;
[0059] Although this binary tree structure can represent each operator and operand of the expression one by one, it cannot directly handle the commutative and associative laws of addition and multiplication, and will be affected by the order of terms when handling the equivalence of expressions. For example, if the order of x and y in the expression is different, the system will consider the two expressions to be unequal, or further judgment will be required on this basis.
[0060] The figure on the right shows the syntax tree structure of the present invention, which introduces consecutive addition nodes and consecutive multiplication nodes to process the commutative law and associative law of addition and multiplication. The specific structure is:
[0061] Add node: the entire expression x 2 +y 2 +2xy=0 is represented as an addition tree, with a root node of plus sign (+) and child nodes including x 2 ,y 2 and 2xy, all addition terms are directly used as child nodes of the continuous addition node, and the addition operation in the expression is no longer affected by the order of terms, that is, no matter x 2 +y 2 +2xy or y 2 +x 2 +2xy are all considered equivalent expressions.
[0062] Multiplication node: x 2It is represented as a multiplication node x·x, and 2xy is represented as a multiplication node 2·x·y. The multiplication node also allows commutativity in multiplication operations, that is, 2·x·y and 2·y·x are regarded as equivalent expressions. The traditional syntax tree needs to compare the order of multiplication operations one by one, but in the improved syntax tree, the multiplication node eliminates the dependence on the order of operands, greatly improving the efficiency of comparison of multiplication expressions.
[0063] In the actual correction step, when receiving the student's input answer S and the standard answer N is the formula x 2 +y 2 When +2xy=0, the following analysis and comparison are performed:
[0064] Syntax tree parsing:
[0065] First, S and N are parsed into a syntax tree structure. At this time, each addition and multiplication operation in the expression is mapped to a continuous addition node and a continuous multiplication node respectively. For the formula x 2 +y 2 +2xy=0, the root node of the parsed syntax tree is a concatenation node, which contains three items: x 2 ,y 2 and 2xy.
[0066] Formula comparison:
[0067] Comparing the parsed syntax trees, we can automatically identify the commutative and associative properties of addition and multiplication by using the addition and multiplication nodes, even if the order of the expressions entered by the students is different (e.g., y 2 +x 2 + 2xy = 0), it is still possible to determine that the two expressions are equivalent and give the correct correction result.
[0068] Greatly reduce the complexity of formula comparison, improve the accuracy of correction, and greatly improve the efficiency of processing complex formulas.
[0069] If S and N are pure text, semantic vectors are obtained through semantic encoding for comparison.
[0070] For S and N in the form of pure text, comparing the semantic information of the text can effectively measure whether S and N are equivalent. The present invention sends S and N to the pre-trained transformer network for semantic encoding respectively, obtains the semantic feature vectors Fs and Fn, and then calculates whether the cosine distance between the two satisfies and is greater than the threshold θ. If so, it means that S and N are equivalent and the correction is correct, otherwise the correction is wrong.
[0071] If it is a complex combination of words and letters of S and N, it is converted into semantics through SWRL and combined with formula comparison to make an equivalence judgment.
[0072] SWRL (Semantic Web Rule Language) is a rule language for the semantic web that can be used to represent and infer relationships and constraints between data in order to more richly describe semantic information. SWRL is widely used in various fields of the semantic web, including knowledge graph construction, data integration, intelligent reasoning, natural language processing, etc. Therefore, SWRL can be used to represent the semantic information of texts and thus perform semantic comparisons.
[0073] If S and N are complex combinations of words and letters, there is often a complex dependency relationship between words and letters, for example, N = "straight lines AB and CD compared to point E", S = "point D is the intersection of AB and CD". At this time, simply comparing letters and words cannot determine whether S and N are equivalent. Therefore, the present invention uses the consistency of the semantic description of SWRL to compare whether S and N are equivalent.
[0074] Specifically, the present invention proposes a homework grading method that combines text cleaning, string comparison, formula semantic comparison, text semantic comparison, and rule semantic comparison, which can improve efficiency while taking into account the accuracy of grading. It overcomes the problem that traditional string comparison methods are insensitive to the order of characters and are prone to misjudgment. At the same time, it greatly reduces the uncertainty in semantic similarity comparison methods and obtains more accurate grading results.
[0075] 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 preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for intelligent homework correction based on syntax tree and semantic analysis, characterized by: include, Step S1, input processing, receiving the homework answer S and the standard answer N to be corrected; Step S2, direct string comparison, performing direct string comparison based on the answer S received in step S1 and the standard answer N; Step S3, formula recognition and syntax tree parsing, judging whether S and N are both pure formulas, if it is detected that both are pure mathematical formulas, entering the formula parsing step; Step S4: word segmentation and text cleaning. If S and N are not pure formulas, the input answer and the standard answer are cleaned and standardized, and then the character strings are compared again. Step S5, compare the semantic vector encoding with the cosine similarity to determine whether S and N are both plain texts. If it is detected that both are plain texts, semantic vector encoding is performed and then compared; Step S6, SWRL semantic transformation and complex semantic comparison, if S and N contain words and letters, use SWRL semantic web rule language to perform semantic transformation and comparison; Step S7, finally outputting the correction result, and returning the final correction result according to the judgment results of steps S2 to S6.
2. According to claim 1, a method for intelligent homework correction based on syntax tree and semantic analysis is characterized in that: In step S2, if the character strings are completely consistent, the correction result is determined to be correct and the process ends. If the character strings are not the same, the next step of processing is entered.
3. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 2, characterized in that: In the formula parsing step of step S3, the formula is parsed into a multi-branch syntax tree structure, and the addition node and the multiplication node are introduced to process the commutative law and the associative law in the mathematical expression. The parsed syntax tree structures are compared to determine whether the two formulas are equivalent.
4. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 3, characterized in that: In the formula analysis step of step S3: If the structures of the syntax trees are the same, that is, the formulas are equivalent, the correction result is determined to be correct and the process ends; If the syntax tree structures are different, the correction result is determined to be wrong and the process ends.
5. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 4, characterized in that: In step S4, if the character strings are completely consistent, the correction result is determined to be correct and the process ends. If the character strings are not the same, the next step of processing is entered.
6. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 5, characterized in that: In step S4, text cleaning and standardization processing includes: Use an education-specific dictionary for word segmentation and remove extra spaces and punctuation.
7. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 6, characterized in that: In step S4, the text cleaning and standardization process further includes: Unify the representation of formulas and use LaTeX to format mathematical expressions; standardize specific symbols so that they are consistent in input and standard answers; and unify unit descriptions.
8. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 7, characterized in that: In step S4, based on the word segmentation, word analysis is performed using a special education dictionary.
9. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 8, characterized in that: In step S5, the semantic vector encoding and cosine similarity comparison method includes: Through semantic vector encoding, the text S and N are converted into semantic vector representations, and the pre-trained Transformer model is used to convert the text into vector F s and F n , and calculate the semantic similarity through cosine similarity. If the cosine similarity of the semantic vector is greater than the preset threshold, the correction result is judged to be correct. If the similarity is lower than the threshold, it is judged to be wrong and the process ends.
10. The method for intelligently correcting homework based on syntax tree and semantic analysis according to claim 9, characterized in that: In step S6, the semantic conversion and comparison are performed as follows: The student answer S and the standard answer N are segmented, the key semantic relations are extracted, the parsed text is converted into SWRL rules, the reasoning engine is used for rule reasoning, the reasoning results of the two rules are generated, and the reasoning results of the student answer S and the standard answer N are compared to determine whether the semantics are consistent. If the reasoning results are consistent, the answer is judged to be correct, otherwise it is judged to be wrong.
Citation Information
Patent Citations
Case knowledge base representation and case similarity obtaining method and system
CN104636430A
Formula-containing text semantic analysis method and apparatus
CN107301163A
An automatic scoring system based on a Wunsch algorithm
CN108985300A
Open test question answer scoring method and device, equipment and storage medium
CN114328874A
Correction method and device, electronic equipment and storage medium
CN118708687A
Cited By
Text sample recognition, analysis and labeling method and system and storage medium
CN119810844A
