Method, apparatus, electronic device and storage medium for constructing text evaluation model
By constructing a text evaluation model, and automatically processing the characteristics of Chinese characters' structure, we solve the problem of human evaluation, and realize the accurate and automated evaluation of Chinese characters' structure and the reduction of errors.
Patent Information
- Application Number
- CN202211570552.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-12-06
AI Technical Summary
In the prior art, the evaluation of Chinese character structure mainly relies on human observation, and it is difficult to accurately judge and provide writing correction guidance, and there are difficulty and errors in judgment.
By obtaining the stroke information of the sample text, performing feature extraction and matching, building a text evaluation model, and automatically assessing the Chinese character structure to reduce artificial labeling errors.
It realizes automated evaluation of Chinese character structure, improves the accuracy and efficiency of evaluation, reduces artificial errors, and improves students' learning efficiency.
Smart Images

Figure CN116959008B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a method, device, electronic device, and storage medium for constructing a text evaluation model. Background Art
[0002] The structure of Chinese characters refers to the arrangement and combination of strokes, as well as the placement of multiple radicals and components within a character. Current assessments of Chinese character structure primarily focus on the length, angle, position, shape, size, height, width, and distance between strokes, as well as the size and position of radicals and components. This extensive set of assessment dimensions, combined with the difficulty of providing correct judgment and correction guidance based solely on visual observation, places excessive demands on calligraphy teachers and presents a certain level of difficulty. Summary of the Invention
[0003] The present application provides a method, device, electronic device and storage medium for constructing a text evaluation model to solve some or all of the problems in the prior art.
[0004] In a first aspect, the present application provides a method for constructing a text evaluation model, the method comprising:
[0005] Obtaining an evaluation text set and a preset number of sample texts under each of a plurality of structural types;
[0006] Splitting the sample characters in the first structural type into strokes to obtain a plurality of stroke information of the first structural type, wherein the first structural type is any one of all structural types;
[0007] Performing feature extraction on multiple stroke information in the first structural type to obtain a feature library of the first structural type;
[0008] Matching the first evaluation text in the evaluation text set with the features of the feature library of each structural type respectively, determining the structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and the weight of each evaluation target, wherein the first evaluation text is any one in the evaluation text set;
[0009] A text evaluation model is constructed based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target.
[0010] In this way, we first obtain the set text structure type and a preset number of sample characters under each structure type, perform stroke splitting and feature extraction on the sample characters, determine the feature library of each structure type, and then match the evaluation text with the feature library in the structure type respectively. When the match is successful, the structure type is determined to be the structure type of the evaluation text. According to the structure type corresponding to each evaluation text in the evaluation text set, the evaluation target corresponding to each structure type and the weight of each evaluation target, a text evaluation model is constructed. Through this text evaluation model, automatic evaluation of text can be realized, reducing the error problem and error probability of annotation. At the same time, all text belonging to the structure type can be evaluated according to the divided structure type, thereby improving the text migration ability of the structure evaluation.
[0011] In combination with the first aspect, in a first embodiment of the first aspect of the present invention, the sample characters in the first structural type are split into strokes to obtain a plurality of stroke information under the first structural type, including:
[0012] Input the sample text into the trained stroke segmentation model to obtain at least one stroke image corresponding to the sample text;
[0013] Screening out at least one target stroke image from all stroke images according to the preset evaluation strokes in the first structural type;
[0014] Get the stroke information corresponding to all target stroke images respectively.
[0015] This method uses a trained model to split strokes, which is more applicable than other methods when the amount of text is large. The split strokes are first screened according to the structural type to determine the target stroke image that needs to be evaluated. The stroke information is extracted for the target stroke image under the structural type, and the stroke information of non-structural types can be removed, providing a reliable basis for the subsequent extraction of stroke information features.
[0016] In combination with the first embodiment of the first aspect, in a second embodiment of the first aspect of the present invention, feature extraction is performed on the plurality of stroke information in the first structure type, specifically including one or more of the following methods:
[0017] performing feature extraction on the length feature of the target stroke image in the first structural type;
[0018] and / or,
[0019] performing feature extraction on angle features of the target stroke image in the first structural type;
[0020] and / or,
[0021] Feature extraction is performed on the distance features of the target stroke image in the first structure type.
[0022] In this way, the features of stroke information can be extracted more comprehensively, making the evaluation criteria more comprehensive and specific.
[0023] In combination with the second embodiment of the first aspect, in a third embodiment of the first aspect of the present invention, feature extraction is performed on the length feature of the target stroke image in the first structural type, including:
[0024] For the target stroke image, extract a preset number of contour points;
[0025] Performing straight line fitting on a preset number of contour points to obtain a first angle;
[0026] Rotating the target stroke image according to the first angle to rotate the target stroke image to a horizontal direction;
[0027] Determine the maximum circumscribed rectangle corresponding to the target stroke image according to the contour points;
[0028] The longest side in the largest circumscribed rectangle is used as the length feature of the target stroke image.
[0029] In this way, the target stroke image is first rotated to the horizontal direction, and then the longest side in the maximum circumscribed rectangle of the target stroke image is used as the length feature of the target stroke image. The length feature of the target stroke image can be accurately extracted. At the same time, the use of the maximum circumscribed rectangle is also conducive to the program's calculation processing.
[0030] In combination with the second embodiment of the first aspect, in a fourth embodiment of the first aspect of the present invention, feature extraction is performed on the angle features of the target stroke image in the first structural type, including:
[0031] Extracting a preset number of contour points from the target stroke image;
[0032] Performing straight line fitting on a preset number of contour points to obtain a first angle;
[0033] Segment the target stroke image and obtain the inscribed circle of each segment;
[0034] Perform straight line fitting on the centers of all segmented inscribed circles, and obtain a second angle between the fitted straight line and the horizontal direction;
[0035] An angle feature of the target stroke image is determined according to the first angle and the second angle.
[0036] In this way, after the contour points are fitted with straight lines, the target stroke image is segmented and a straight line fitting is performed using the inscribed circle of each segment. After the second fitting, the angle of the obtained target stroke image can be more accurate and more in line with the actual angle characteristics of the target stroke image.
[0037] In combination with any one of the second embodiment to the fourth embodiment of the first aspect, in a fifth embodiment of the first aspect of the present invention, when the stroke information includes at least two stroke images, feature extraction is performed on the distance features of the target stroke image in the first structure type, including:
[0038] The distance between the centroid of the first target stroke image and the centroid of the second target stroke image is used as the distance feature of the first target stroke image and the second target stroke image, wherein the first target stroke image is any one of the at least two target stroke images, and the second target stroke image is any one of the at least two target stroke images.
[0039] In combination with the first aspect, in a sixth embodiment of the first aspect of the present invention, after constructing the text evaluation model based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target, the method further includes:
[0040] Obtaining a first text image of a text to be evaluated;
[0041] Performing text recognition on the first text image to determine a second text image and at least one structural type corresponding to the text to be evaluated, where the second text image is an evaluation text image of the first text image;
[0042] Determining a difference in evaluation target values between a first text image and a second text image of a first evaluation target in an i-th structural type, where the i-th structural type is any one of at least one structural type;
[0043] Determine the structural type evaluation result of the i-th structural type according to the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target;
[0044] The text evaluation results of the text to be evaluated are determined based on the evaluation results of all structural types.
[0045] In this way, using the constructed text assessment model for assessment can save teacher resources, avoid errors caused by manual annotation, and improve students' learning efficiency.
[0046] In a second aspect, the present application provides a device for constructing a text evaluation model, which includes: an acquisition module, a stroke segmentation module, an extraction module, a matching module, and a construction module;
[0047] An acquisition module, used to acquire an evaluation text set and a preset number of sample texts under each of a plurality of structural types;
[0048] a stroke splitting module, configured to split the sample characters in a first structural type into strokes and obtain a plurality of stroke information of the first structural type, wherein the first structural type is any one of all structural types;
[0049] An extraction module, configured to extract features from a plurality of stroke information in the first structural type to obtain a feature library of the first structural type;
[0050] a matching module, configured to match a first evaluation text in the evaluation text set with features of a feature library for each structural type, respectively, to determine a structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and a weight of each evaluation target, wherein the first evaluation text is any one of the evaluation text sets;
[0051] The construction module is used to construct a text evaluation model based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target.
[0052] Optionally, the device further includes: a processing module and a screening module; the processing module is configured to input a sample text into a trained stroke segmentation model to obtain at least one stroke image corresponding to the sample text;
[0053] a screening module, configured to screen out at least one target stroke image from all stroke images according to preset evaluation strokes in the first structural type;
[0054] The acquisition module is also used to respectively acquire the stroke information corresponding to all target stroke images.
[0055] Optionally, the device includes:
[0056] an extraction module, specifically configured to extract length features of the target stroke image in the first structural type;
[0057] and / or,
[0058] an extraction module, specifically configured to extract angle features of the target stroke image in the first structural type;
[0059] and / or,
[0060] The extraction module is specifically used to extract the distance features of the target stroke image in the first structure type.
[0061] Optionally, the device includes: a fitting module, a rotation module, and a determination module;
[0062] The extraction module is further used to extract a preset number of contour points from the target stroke image;
[0063] A fitting module, configured to perform straight line fitting on a preset number of contour points to obtain a first angle;
[0064] a rotation module, configured to rotate the target stroke image according to the first angle to rotate the target stroke image to a horizontal direction;
[0065] The determination module is used to determine the maximum circumscribed rectangle corresponding to the target stroke image according to the contour points; and use the longest side in the maximum circumscribed rectangle as the length feature of the target stroke image.
[0066] Optionally, the device further comprises: a segmentation module;
[0067] An extraction module, specifically used to extract a preset number of contour points from the target stroke image;
[0068] A fitting module, specifically configured to perform straight line fitting on a preset number of contour points to obtain a first angle;
[0069] A segmentation module is used to segment the target stroke image and obtain the inscribed circle of each segment;
[0070] The fitting module is further used to perform straight line fitting on the centers of all segmented inscribed circles, and obtain a second angle between the fitted straight line and the horizontal direction;
[0071] The determination module is further configured to determine an angle feature of the target stroke image according to the first angle and the second angle.
[0072] Optionally, the device includes:
[0073] The determination module is also used to use the distance between the center of mass of the first target stroke image and the center of mass of the second target stroke image as the distance feature of the first target stroke image and the second target stroke image, wherein the first target stroke image is any one of the at least two target stroke images, and the second target stroke image is any one of the at least two target stroke images.
[0074] Optionally, the device includes: a text recognition module;
[0075] The acquisition module is further used to acquire a first text image of the text to be evaluated;
[0076] A text recognition module is configured to perform text recognition on the first text image, determine a second text image and at least one structural type corresponding to the text to be evaluated, wherein the second text image is an evaluation text image of the first text image;
[0077] The determination module is further configured to determine the evaluation target value difference between the first text image and the second text image of the first evaluation target in the i-th structure type, where the i-th structure type is any one of at least one structure type; determine the structure type evaluation result of the i-th structure type according to the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target respectively; and determine the text evaluation result of the text to be evaluated according to all the structure type evaluation results.
[0078] In a third aspect, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus;
[0079] The memory is used to store a computer program;
[0080] When the processor is used to execute the program stored on the memory, it implements the steps of the text evaluation model construction method according to any one of the embodiments in the first aspect.
[0081] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the text evaluation model construction method according to any one of the embodiments in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] Figure 1 It is a schematic flowchart of a text evaluation model construction method provided by an embodiment of the present invention;
[0083] Figure 2 It is a schematic diagram of the structure type provided by the present invention;
[0084] Figure 3 It is a schematic diagram of the character "half" provided by an embodiment of the present invention;
[0085] Figure 4 It is a schematic diagram of the character "this" provided by an embodiment of the present invention;
[0086] Figure 5 It is a schematic diagram of the character "multiply" provided by an embodiment of the present invention;
[0087] Figure 6 It is a schematic flowchart of the length feature extraction method provided by an embodiment of the present invention;
[0088] Figure 7 It is a schematic diagram of the character "field" provided by an embodiment of the present invention;
[0089] Figure 8 It is a schematic flowchart of the angle feature extraction method provided by an embodiment of the present invention;
[0090] Figure 9Schematic diagrams of the Chinese characters "Bao" and "Bie" provided by embodiments of the present invention;
[0091] Figure 10 Schematic flowchart of a text evaluation method provided by an embodiment of the present invention;
[0092] Figure 11 Another schematic flowchart of a text evaluation method provided by the present invention;
[0093] Figure 12 Schematic diagram of the structure of a text evaluation model construction device provided by an embodiment of the present invention;
[0094] Figure 13 Schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0095] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0096] For ease of understanding of the embodiments of the present invention, the following will further explain and illustrate with specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation to the embodiments of the present invention.
[0097] In response to the technical problems mentioned in the background art, the embodiments of the present application provide a method for constructing a text evaluation model. Specifically, refer to Figure 1 as shown in Figure 1 Schematic flowchart of a method for constructing a text evaluation model provided by an embodiment of the present invention. The steps of this method include:
[0098] Step 110: Obtain a set of evaluation texts and a preset number of sample texts under each of multiple structure types.
[0099] Specifically, the set of evaluation texts can be a set of evaluation texts of standard characters of multiple Chinese characters, such as regular script, Song typeface, etc. A fixed font size can be set. The structure types can refer to a text structure guide sticker to determine the structure types to be distinguished, such as upper-lower structure, left-right structure, etc.
[0100] In an optional example, the structure types that can be divided are exemplified as follows:
[0101] I) Basic structure category - left-right structure
[0102] 1) The left is small and the right is large / the left is large and the right is small / the left and right are the same shape
[0103] 2) Left shorter, right longer / Left longer, right shorter / Left and right equal length
[0104] 3) Narrow left and wide right / Wide left and narrow right / Equal width on both sides
[0105] 4) Left high, right low / Left low, right high / Left and right level
[0106] 2) Types of interframe structures
[0107] 1) Parallel vertical strokes
[0108] 2) Horizontal and vertical
[0109] 3) Evenly spaced
[0110] Of course, there are also some other structural categories, such as Figure 2 As shown, the specific text setting structure type can be determined based on actual needs, and no further restrictions are made here.
[0111] Step 120 : Split the sample characters in the first structural type into strokes to obtain a plurality of stroke information under the first structural type.
[0112] Specifically, the first structure type is any one of all structure types.
[0113] Optionally, the sample characters in the first structural type are split into strokes to obtain multiple stroke information of the first structural type, including:
[0114] Input the sample text into the trained stroke segmentation model to obtain at least one stroke image corresponding to the sample text;
[0115] Screening out at least one target stroke image from all stroke images according to the preset evaluation strokes in the first structural type;
[0116] Get the stroke information corresponding to all target stroke images respectively.
[0117] Specifically, we can first use a deep learning model, such as a deep convolutional model, to train a semantic segmentation model for stroke classification, and input the sample text into the semantic segmentation model to perform stroke splitting. Because the sample text already has a structural type, the strokes after the sample text split also have a structural type. According to the structural type, the strokes under the structural type are screened to select the strokes that need to be evaluated.
[0118] In an alternative example, for example Figure 3The character "half" belongs to the horizontal and vertical structure classification. The strokes to be evaluated are horizontal or vertical. The selected strokes are the two horizontal strokes and one vertical stroke shown by the dotted lines in the figure. The two horizontal strokes and one vertical stroke are the target stroke images, and the stroke information is the stroke information of each of these three strokes or the information between the strokes. For example, the combination of a short horizontal stroke and a vertical stroke, or the combination of a long horizontal stroke and a vertical stroke. At the same time, this character also belongs to the same-stroke parallel structure. The strokes to be evaluated are two horizontal strokes, and their stroke information can include the long horizontal stroke, the short horizontal stroke, and the stroke information of the combination of the two horizontal strokes. In this way, when using the trained model for stroke splitting, it is more applicable than other methods when the amount of text is large. First, filter the split strokes according to the structure type to determine the target stroke images to be evaluated, and extract the stroke information for the target stroke images under the structure type, which can remove the stroke information that does not belong to this structure type and provide a reliable basis for extracting the features of the stroke information in the subsequent steps.
[0119] Step 130: Extract features from multiple stroke information in the first structure type to obtain the feature library of the first structure type.
[0120] Specifically, extract features from each of the multiple stroke information split in the first structure type, and extract the commonality of all features in the first structure type to form the feature library of the first structure type.
[0121] In an optional example, the way to obtain the feature commonality can be to cluster the features. For example, the K-means mean clustering method. According to the clustering results, extract the commonality of the features. Taking the horizontal and vertical structure as an example, the extracted feature library can include the following feature rules:
[0122] Rule 1: Determine the strokes to be matched by judging whether the stroke contours intersect.
[0123] Rule 2: The angular difference between the horizontal and vertical combinations is within a specific range.
[0124] Rule 3: Eliminate all characters whose ratio of the area of the circumscribed rectangle of the horizontal and vertical combinations to the area of the circumscribed rectangle of the whole character is less than the set threshold.
[0125] Rule 4: The ratio of the horizontal stroke to be matched to the width of the whole character is greater than the set threshold, and the ratio of the vertical stroke to the height of the whole character is greater than the set threshold.
[0126] Rule 5: Judge whether the intersection of the horizontal and vertical strokes is in the middle part of the horizontal stroke or the vertical stroke.
[0127] Step 140: Match the first evaluation characters in the evaluation text set with the features of the feature library of each structure type respectively to determine the structure type corresponding to the first evaluation characters, at least one evaluation target corresponding to the structure type, and the weight of each evaluation target.
[0128] Step 150: Construct a text evaluation model according to the structural types corresponding to all the evaluation texts in the evaluation text set, the evaluation objectives corresponding to each structural type, and the weights of each evaluation objective.
[0129] Specifically, after determining the feature library corresponding to each structural type, compare the features of each text in the evaluation text set with the feature library. The evaluation text set can be the standard characters of all Chinese characters to be evaluated. For example, the evaluation text can be split into strokes, and then features are extracted based on the split strokes. The extracted features are matched with the features in the feature library of the structural type. When the features of the evaluation text conform to all the features under a certain structural type, it is confirmed that the evaluation text has this structural type. Screen the strokes to be evaluated as evaluation objectives according to this structural type, and determine the weight of each evaluation objective. The determination standard of the weight can be evenly distributed according to the number of evaluation objectives, or according to other bases. For example, according to the proportion of the area of the maximum bounding rectangle of the evaluation objective in the sum of the areas of the maximum bounding rectangles of all evaluation objectives, determine the weight of each evaluation objective. Construct an evaluation model according to the structural types of all evaluation texts in the evaluation text set, the evaluation objectives corresponding to each structural type, and the weights corresponding to the evaluation objectives.
[0130] In an optional example, for example, in Figure 4 the character "本" shown, under the horizontal and vertical structure type, the evaluated strokes are the long horizontal stroke, the short horizontal stroke, and the vertical stroke. The evaluation objectives are the stroke combinations: the combination of the long horizontal stroke and the vertical stroke (evaluation objective 1), the combination of the short horizontal stroke and the vertical stroke (evaluation objective 2). The area of the maximum bounding rectangle of evaluation objective 1 is area 1, and the area of the maximum bounding rectangle of evaluation objective 2 is area 2. Then the weight of evaluation objective 1 is the proportion of area 1 in the sum of area 1 and area 2.
[0131] Through this method, first obtain the set text structure types and a preset number of sample characters under each structure type, perform stroke splitting and feature extraction on the sample characters, determine the feature library of each structure type, and then match the evaluation texts with the feature libraries in the structure types respectively. When the match is successful, determine this structure type as the structure type of the evaluation text. Construct a text evaluation model according to the structural types corresponding to the evaluation texts in each evaluation text set, the evaluation objectives corresponding to each structural type, and the weights of each evaluation objective. Through this text evaluation model, automated evaluation of texts can be achieved, reducing the problems of annotation errors and the probability of errors. At the same time, according to the divided structural types, all texts belonging to this structural type can be evaluated, improving the text migration ability of structural evaluation.
[0132] Optionally, perform feature extraction on multiple stroke information in the first structural type, specifically including one or more of the following methods:
[0133] Extract the length feature of the target stroke image in the first structural type;
[0134] And / or,
[0135] Extract the angle feature of the target stroke image in the first structural type;
[0136] And / or,
[0137] Extract the distance feature between the target stroke images in the first structural type.
[0138] Specifically, the stroke information is the characteristic information of the target stroke image in the stroke information. When the stroke information to be evaluated is a single stroke, the ways to extract features from the stroke information may include, but are not limited to, the following ways:
[0139] Extract the length feature of the target stroke image, or extract the angle feature of the target stroke image, or extract both the length feature and the angle feature of the target stroke.
[0140] When the stroke information to be evaluated includes two or more strokes, such as the horizontal and vertical stroke combination in a horizontal and vertical structure, in addition to extracting the features of each stroke separately, the distance feature between the two strokes can also be extracted.
[0141] In an optional example, such as Figure 5 For the character "乘" shown in, the target stroke image to be evaluated is the horizontal and vertical combination shown by the dotted line in the figure, and the features to be extracted also include the distance feature between the horizontal stroke and the vertical stroke.
[0142] Optionally, extracting the length feature of the target stroke image in the first structural type includes the method steps as Figure 6 shown:
[0143] Step 610, extract a preset number of contour points from the target stroke image.
[0144] Step 620, perform a linear fitting on the preset number of contour points to obtain the first angle.
[0145] Specifically, extracting a preset number of points from the contour of the target stroke image can be at preset positions, such as the points including the topmost, bottommost, leftmost, rightmost points and other points. Perform a curve fitting, that is, a linear fitting, based on the selected contour points, and use the angle between the line and the horizontal direction as the first angle. The more the number of selected contour points, the more accurate the result of the linear fitting.
[0146] In an optional example, such as Figure 8For the character "场", the result of linearly fitting the left-falling stroke is shown as the dashed line in the figure, and the angle between this dashed line and the horizontal direction is taken as the first angle.
[0147] Step 630: Rotate the target stroke image according to the first angle to rotate the target stroke image to the horizontal direction.
[0148] Specifically, in an optional example, for example Figure 7 the left-falling stroke of the character "场", rotate the image of the stroke according to the first angle to the horizontal direction.
[0149] Step 640: Determine the minimum bounding rectangle corresponding to the target stroke image according to the contour points.
[0150] Step 650: Take the longest side in the minimum bounding rectangle as the length feature of the target stroke image.
[0151] Specifically, obtain the minimum bounding rectangle of the target stroke image in the horizontal direction. The determination method of the minimum bounding rectangle can be determined according to the points at the top, bottom, left, and right of the target stroke image in the horizontal direction. Take the longer side in this bounding rectangle as the length feature of the target stroke image.
[0152] By this method, first rotate the target stroke image to the horizontal direction, and then take the longest side in the minimum bounding rectangle of the target stroke image as the length feature of the target stroke image, so that the length feature of the target stroke image can be accurately extracted. At the same time, using the minimum bounding rectangle is also beneficial for program calculation and processing.
[0153] Optionally, feature extraction is performed on the angle feature of the target stroke image in the first structural type, including the method steps as Figure 8 shown:
[0154] Step 810: Extract a preset number of contour points from the target stroke image.
[0155] Step 820: Perform linear fitting on the preset number of contour points to obtain the first angle.
[0156] Specifically, the specific methods of Step 810 and Step 820 have been described in detail in Step 610 and Step 620, and will not be elaborated here.
[0157] Step 830: Segment the target stroke image to obtain the inscribed circle of each segment.
[0158] Specifically, the number of segments can be set according to the length and width of the target stroke image, and then for each segment, obtain the inscribed circle of each segment. The specific number of segments can be set according to actual needs.
[0159] Step 840: Perform a linear fitting on the centers of the inscribed circles of all segments to obtain the second angle between the fitted line and the horizontal direction.
[0160] Step 850: Determine the angle feature of the target stroke image based on the first angle and the second angle.
[0161] Specifically, perform a linear fitting on the centers of the inscribed circles of all segments to obtain the fitted line, and take the angle between this line and the horizontal direction as the second angle. This method is equivalent to making a more accurate correction to the true angle of the target stroke image in the horizontal direction. Since the first angle is equivalent to performing a linear fitting on the entire target stroke image as a whole, there is still a certain gap between it and the true angle. After segmenting the target stroke image, the angle caused by the curvature of the stroke can be calculated more accurately. Then, take the sum of the first angle and the second angle as the angle feature of the target stroke image.
[0162] In this way, after performing a linear fitting on the contour points and then segmenting the target stroke image, use the inscribed circle of each segment to perform another linear fitting. After the second fitting, the angle of the obtained target stroke image can be made more accurate and more in line with the actual angle feature of the target stroke image.
[0163] Optionally, when the stroke images in the stroke information include at least two, extracting the distance feature of the target stroke image in the first structural type includes:
[0164] Take the distance between the centroid of the first target stroke image and the centroid of the second target stroke image as the distance feature between the first target stroke image and the second target stroke image, where the first target stroke image is any one of at least two target stroke images, and the second target stroke image is any one of at least two target stroke images.
[0165] Specifically, in an optional example, when the stroke images in the stroke information include at least two, for example Figure 9 the characters "宝" and "别" in, which belong to the same-stroke parallel structure type, and the strokes to be evaluated are shown as dotted lines in the figure. Taking the character "宝" as an example, it is necessary to calculate Figure 10 the centroid of the first stroke marked by the dotted line, the centroid of the second stroke, and the centroid of the third stroke in, and then calculate the distance between the centroids of every two strokes as the distance feature of this group of stroke information.
[0166] Optionally, after constructing a character evaluation model according to the structural types corresponding to all the evaluated characters in the evaluation character set, the evaluation targets corresponding to each structural type, and the weights of each evaluation target, the method further includes the method steps as Figure 10 shown:
[0167] Step 1010: Obtain a first text image of the text to be evaluated.
[0168] Specifically, the text image to be evaluated can be an image of handwritten characters. Figure 12 The Chinese characters are shown in the column on the right.
[0169] Step 1020 : Perform text recognition on the first text image to determine a second text image and at least one structural type corresponding to the text to be evaluated.
[0170] Specifically, the second text image is the evaluation text image of the first text image. The first text image is subjected to text recognition to obtain the recognition result. Based on the recognition result, the evaluation text of the text is obtained from the evaluation text set, which can be the text image of the standard character of the text, that is, the second text image. Based on the second text image, the structural type of the text to be evaluated can be determined.
[0171] Step 1030 : Determine the difference in evaluation target values between the first text image and the second text image of the first evaluation target in the i-th structural type.
[0172] Specifically, the i-th structural type is any one of at least one structural type, and the first eigenvalue of the first text image and the second eigenvalue of the second text image in the first evaluation target are respectively obtained, the second eigenvalue is the standard eigenvalue, and the difference between the first eigenvalue and the second eigenvalue is the target value difference of the evaluation target.
[0173] Step 1040: Determine the structural type evaluation result of the i-th structural type according to the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target.
[0174] Specifically, the weight β of the target value difference of the evaluation target can be calculated using the following formula:
[0175] β=α hw / α gt -1
[0176] Among them, α hw is the eigenvalue of handwritten characters, α gt It is the characteristic value of the standard word, i.e. the evaluation word.
[0177] Score of the i-th structural type single It is equal to the weighted sum of the difference ratios between the target values of handwritten characters and standard characters, which can be obtained using the following formula:
[0178] Score single =ω1β1+ω2β2+…+ω n β n
[0179] Among them, ω1 is the score of the first evaluation target, β1 is the weight of the first evaluation target, ω2 is the score of the second evaluation target, β2 is the weight of the second evaluation target, ω n is the score of the nth evaluation target, β n is the weight of the nth evaluation target.
[0180] Step 1050 : Determine the text evaluation result of the text to be evaluated based on all the structural type evaluation results.
[0181] Specifically, the text evaluation result score Score total It is the average of all structure type scores, as shown in the following formula:
[0182]
[0183] in, Score the first structure type, Score the second structure type, is the score of the nth structural type, and n is the number of structural types.
[0184] Of course, the evaluation results can also include corresponding text evaluation result comments and improvement suggestions, etc., which can be set according to actual conditions and will not be overly restricted here.
[0185] The present invention also provides a specific usage scenario, such as in a student calligraphy practice scenario, such as Figure 11 As shown, first, students (users) use ordinary pens (such as fountain pens, pencil pen, etc.) or smart pens (various dot matrix writing pens) to write Chinese characters on the copybook, and then use a mobile phone to take a photo of the copybook, or transmit the handwriting information with a dot matrix book, and upload it to the calligraphy evaluation algorithm server. The algorithm module in the server will perform text detection and text classification. After determining the classification of the handwritten characters, the structure evaluation module will further automatically divide the structural types of the characters. Based on the evaluation information under the structural type, the writing of various structures of the written Chinese characters is evaluated. Finally, the writing problems of the handwritten characters under various structural types can be pointed out for the teacher's guidance and suggestions and the students' understanding and correction of structural writing. In this scenario, the structural characteristics of standard characters can be combined to perform multiple structural types of evaluation and analysis on each student's handwritten characters, and output more comprehensive and complete structural evaluation results and guidance suggestions, which greatly improves the help for teachers' teaching work.
[0186] The above is an embodiment of the text evaluation model construction method provided by this application. The following describes other embodiments of the text evaluation model construction provided by this application. Please refer to the following for details.
[0187] Figure 12A device for constructing a character evaluation model provided in an embodiment of the present invention includes: an acquisition module 1201, a stroke segmentation module 1202, an extraction module 1203, a matching module 1204, and a construction module 1205;
[0188] An acquisition module 1201 is configured to acquire an evaluation text set and a preset number of sample texts of each of a plurality of structural types;
[0189] A stroke splitting module 1202 is configured to split a sample character in a first structural type into strokes to obtain a plurality of stroke information of the first structural type, wherein the first structural type is any one of all structural types;
[0190] Extraction module 1203, configured to extract features from the plurality of stroke information in the first structural type to obtain a feature library of the first structural type;
[0191] Matching module 1204, configured to match a first evaluation text in the evaluation text set with features in a feature library for each structural type, to determine a structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and a weight for each evaluation target, wherein the first evaluation text is any one of the evaluation text sets;
[0192] The construction module 1205 is used to construct a text evaluation model according to the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target.
[0193] Optionally, the device further includes: a processing module 1206 and a screening module 1207;
[0194] The processing module 1206 is configured to input a sample character into the trained stroke segmentation model to obtain at least one stroke image corresponding to the sample character;
[0195] A screening module 1207 is configured to screen out at least one target stroke image from all stroke images according to the preset evaluation strokes in the first structural type;
[0196] The acquisition module 1201 is further configured to respectively acquire the stroke information corresponding to all target stroke images.
[0197] Optionally, the device includes:
[0198] Extraction module 1203, specifically configured to extract length features of the target stroke image in the first structural type;
[0199] and / or,
[0200] Extraction module 1203, specifically configured to extract angle features of the target stroke image in the first structural type;
[0201] and / or,
[0202] The extraction module 1203 is specifically configured to extract the distance features of the target stroke image in the first structural type.
[0203] Optionally, the apparatus includes: a fitting module 1208, a rotation module 1209, and a determination module 1210;
[0204] The extraction module 1203 is further configured to extract a preset number of contour points from the target stroke image;
[0205] A fitting module 1208 is configured to perform straight line fitting on a preset number of contour points to obtain a first angle;
[0206] A rotation module 1209 is configured to rotate the target stroke image according to the first angle to rotate the target stroke image to a horizontal direction;
[0207] The determination module 1210 is configured to determine the maximum bounding rectangle corresponding to the target stroke image according to the contour points; and use the longest side in the maximum bounding rectangle as the length feature of the target stroke image.
[0208] Optionally, the device further includes: a segmentation module 1211;
[0209] Extraction module 1203, specifically configured to extract a preset number of contour points from the target stroke image;
[0210] The fitting module 1208 is specifically configured to perform straight line fitting on a preset number of contour points to obtain a first angle;
[0211] Segmentation module 1211, for segmenting the target stroke image and obtaining the inscribed circle of each segment;
[0212] The fitting module 1208 is further configured to perform straight line fitting on the centers of all segmented inscribed circles, and obtain a second angle between the fitted straight line and the horizontal direction;
[0213] The determination module 1210 is further configured to determine an angle feature of the target stroke image according to the first angle and the second angle.
[0214] Optionally, the device includes:
[0215] The determination module 1210 is further used to use the distance between the center of mass of the first target stroke image and the center of mass of the second target stroke image as the distance feature of the first target stroke image and the second target stroke image, wherein the first target stroke image is any one of the at least two target stroke images, and the second target stroke image is any one of the at least two target stroke images.
[0216] Optionally, the device includes: a text recognition module 1212;
[0217] The acquisition module 1201 is further configured to acquire a first text image of the text to be evaluated;
[0218] The text recognition module 1212 is configured to perform text recognition on the first text image, determine a second text image and at least one structural type corresponding to the text to be evaluated, wherein the second text image is an evaluation text image of the first text image;
[0219] Determination module 1210 is also used to determine the difference in evaluation target values between the first text image and the second text image of the first evaluation target in the i-th structural type, where the i-th structural type is any one of at least one structural type; determine the structural type evaluation result of the i-th structural type based on the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target; and determine the text evaluation result of the text to be evaluated based on all structural type evaluation results.
[0220] The functions performed by the various components in the text evaluation model construction device provided by the embodiment of the present invention have been described in detail in any of the above method embodiments, and therefore will not be repeated here.
[0221] An embodiment of the present invention provides a device for constructing a text evaluation model, which obtains an evaluation text set and a preset number of sample texts under each structural type in multiple structural types; splits the sample text in a first structural type into strokes to obtain multiple stroke information under the first structural type, wherein the first structural type is any one of all structural types; performs feature extraction on the multiple stroke information in the first structural type to obtain a feature library of the first structural type; matches the first evaluation text in the evaluation text set with the features of the feature library of each structural type respectively to determine the structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and the weight of each evaluation target, wherein the first evaluation text is any one in the evaluation text set; constructs a text evaluation model based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target. In this way, we first obtain the set text structure type and a preset number of sample characters under each structure type, perform stroke splitting and feature extraction on the sample characters, determine the feature library of each structure type, and then match the evaluation text with the feature library in the structure type respectively. When the match is successful, the structure type is determined to be the structure type of the evaluation text. According to the structure type corresponding to each evaluation text in the evaluation text set, the evaluation target corresponding to each structure type and the weight of each evaluation target, a text evaluation model is constructed. Through this text evaluation model, automatic evaluation of text can be realized, reducing the error problem and error probability of annotation. At the same time, all text belonging to the structure type can be evaluated according to the divided structure type, thereby improving the text migration ability of the structure evaluation.
[0222] like Figure 13 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0223] Memory 113, for storing computer programs;
[0224] In one embodiment of the present application, the processor 111 is configured to execute a program stored in the memory 113 to implement the text evaluation model construction method provided by any of the aforementioned method embodiments, including:
[0225] Obtaining an evaluation text set and a preset number of sample texts under each of a plurality of structural types;
[0226] Splitting the sample characters in the first structural type into strokes to obtain a plurality of stroke information of the first structural type, wherein the first structural type is any one of all structural types;
[0227] Performing feature extraction on multiple stroke information in the first structural type to obtain a feature library of the first structural type;
[0228] Matching the first evaluation text in the evaluation text set with the features of the feature library of each structural type respectively, determining the structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and the weight of each evaluation target, wherein the first evaluation text is any one in the evaluation text set;
[0229] A text evaluation model is constructed based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target.
[0230] Optionally, the sample characters in the first structural type are split into strokes to obtain multiple stroke information of the first structural type, including:
[0231] Input the sample text into the trained stroke segmentation model to obtain at least one stroke image corresponding to the sample text;
[0232] Screening out at least one target stroke image from all stroke images according to the preset evaluation strokes in the first structural type;
[0233] Get the stroke information corresponding to all target stroke images respectively.
[0234] Optionally, feature extraction is performed on the plurality of stroke information in the first structure type, specifically including one or more of the following methods:
[0235] performing feature extraction on the length feature of the target stroke image in the first structural type;
[0236] and / or,
[0237] performing feature extraction on angle features of the target stroke image in the first structural type;
[0238] and / or,
[0239] Feature extraction is performed on the distance features of the target stroke image in the first structure type.
[0240] Optionally, extracting the length feature of the target stroke image in the first structural type includes:
[0241] For the target stroke image, extract a preset number of contour points;
[0242] Performing straight line fitting on a preset number of contour points to obtain a first angle;
[0243] Rotating the target stroke image according to the first angle to rotate the target stroke image to a horizontal direction;
[0244] Determine the maximum circumscribed rectangle corresponding to the target stroke image according to the contour points;
[0245] The longest side in the largest circumscribed rectangle is used as the length feature of the target stroke image.
[0246] Optionally, extracting the angle features of the target stroke image in the first structural type includes:
[0247] Extracting a preset number of contour points from the target stroke image;
[0248] Performing straight line fitting on a preset number of contour points to obtain a first angle;
[0249] Segment the target stroke image and obtain the inscribed circle of each segment;
[0250] Perform straight line fitting on the centers of all segmented inscribed circles, and obtain a second angle between the fitted straight line and the horizontal direction;
[0251] An angle feature of the target stroke image is determined according to the first angle and the second angle.
[0252] Optionally, when the stroke information includes at least two stroke images, performing feature extraction on the distance feature of the target stroke image in the first structure type includes:
[0253] The distance between the centroid of the first target stroke image and the centroid of the second target stroke image is used as the distance feature of the first target stroke image and the second target stroke image, wherein the first target stroke image is any one of the at least two target stroke images, and the second target stroke image is any one of the at least two target stroke images.
[0254] Optionally, after constructing the text evaluation model based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation objectives corresponding to each structural type, and the weight of each evaluation objective, the method further includes:
[0255] Obtaining a first text image of a text to be evaluated;
[0256] Performing text recognition on the first text image to determine a second text image and at least one structural type corresponding to the text to be evaluated, where the second text image is an evaluation text image of the first text image;
[0257] Determining a difference in evaluation target values between a first text image and a second text image of a first evaluation target in an i-th structural type, where the i-th structural type is any one of at least one structural type;
[0258] Determine the structural type evaluation result of the i-th structural type according to the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target;
[0259] The text evaluation results of the text to be evaluated are determined based on the evaluation results of all structural types.
[0260] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the text evaluation model construction method provided in any of the aforementioned method embodiments are implemented.
[0261] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device that includes the element.
[0262] The foregoing is merely a detailed description of the present invention, intended to enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein, but is to be construed in the widest manner consistent with the principles and novel features claimed herein.
Claims
1. A method for constructing a text evaluation model, characterized in that: The method comprises: Obtaining an evaluation text set and a preset number of sample texts of each of a plurality of structural types; Splitting the sample characters in the first structural type into strokes to obtain a plurality of stroke information of the first structural type, wherein the first structural type is any one of all the structural types; Performing feature extraction on the plurality of stroke information in the first structural type to obtain a feature library of the first structural type; Matching the first evaluation text in the evaluation text set with the features of the feature library of each structure type respectively, determining the structure type corresponding to the first evaluation text, at least one evaluation target corresponding to the structure type, and the weight of each evaluation target, wherein the first evaluation text is any one of the evaluation text sets; Constructing a text evaluation model according to the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target; The step of splitting the sample characters in the first structural type into strokes to obtain a plurality of stroke information of the first structural type includes: Inputting the sample text into a trained stroke segmentation model to obtain at least one stroke image corresponding to the sample text; Screening out at least one target stroke image from all the stroke images according to the preset evaluation strokes in the first structural type; Respectively obtaining stroke information corresponding to all target stroke images; The extracting features of the plurality of stroke information in the first structural type includes: Extracting a preset number of contour points from the target stroke image; Performing straight line fitting on the preset number of contour points to obtain a first angle; Segmenting the target stroke image to obtain an inscribed circle of each segment; Perform straight line fitting on the centers of all segmented inscribed circles, and obtain a second angle between the fitted straight line and the horizontal direction; An angle feature of the target stroke image is determined according to the first angle and the second angle.
2. The method according to claim 1, characterized in that The feature extraction of the plurality of stroke information in the first structure type specifically includes one or more of the following methods: performing feature extraction on the length features of the target stroke image in the first structural type; and / or, performing feature extraction on angle features of the target stroke image in the first structural type; and / or, Feature extraction is performed on distance features between the target stroke images in the first structure type.
3. The method according to claim 2, characterized in that The extracting the length feature of the target stroke image in the first structural type includes: Extracting a preset number of contour points from the target stroke image; Performing straight line fitting on the preset number of contour points to obtain a first angle; Rotating the target stroke image according to the first angle to rotate the target stroke image to a horizontal direction; Determine the maximum circumscribed rectangle corresponding to the target stroke image according to the contour points; The longest side in the maximum circumscribed rectangle is used as the length feature of the target stroke image.
4. The method according to any one of claims 2 to 3, characterized in that: When the stroke information includes at least two stroke images, extracting the distance features between the target stroke images in the first structure type includes: The distance between the center of mass of the first target stroke image and the center of mass of the second target stroke image is used as the distance feature of the first target stroke image and the second target stroke image, wherein the first target stroke image is any one of the at least two target stroke images, and the second target stroke image is any one of the at least two target stroke images.
5. The method according to claim 1, wherein After constructing the text evaluation model based on the structural types corresponding to all evaluation texts in the evaluation text set, the evaluation targets corresponding to each structural type, and the weight of each evaluation target, the method further includes: Obtaining a first text image of a text to be evaluated; Performing text recognition on the first text image to determine a second text image and at least one structural type corresponding to the text to be evaluated, wherein the second text image is an evaluation text image of the first text image; Determining a difference in evaluation target values between a first text image and a second text image of a first evaluation target in an i-th structural type, wherein the i-th structural type is any one of at least one of the structural types; Determine the structural type evaluation result of the i-th structural type according to the evaluation target value difference of each evaluation target and the weight corresponding to each evaluation target; The text evaluation result of the text to be evaluated is determined based on all the structural type evaluation results.
6. A text evaluation model construction device, characterized in that: The device comprises: An acquisition module, configured to acquire an evaluation text set and a preset number of sample texts under each of a plurality of structural types; The stroke splitting module is used to split the sample text in the first structural type into strokes and obtain multiple stroke information under the first structural type, wherein the first structural type is any one of all the structural types; the stroke splitting of the sample text in the first structural type and obtaining multiple stroke information under the first structural type includes: inputting the sample text into a trained stroke splitting model to obtain at least one stroke image corresponding to the sample text; screening at least one target stroke image from all the stroke images according to the preset evaluation strokes in the first structural type; respectively obtaining the stroke information corresponding to all the target stroke images; feature extraction an extraction module, configured to perform feature extraction on the plurality of stroke information in the first structural type to obtain a feature library of the first structural type; the feature extraction on the plurality of stroke information in the first structural type comprises: extracting a preset number of contour points from the target stroke image; performing straight line fitting on the preset number of contour points to obtain a first angle; segmenting the target stroke image to obtain an inscribed circle of each segment; performing straight line fitting on the centers of the inscribed circles of all the segments to obtain a second angle between the fitted straight line and the horizontal direction; and determining an angular feature of the target stroke image based on the first angle and the second angle; a matching module, configured to match a first evaluation text in the evaluation text set with features of a feature library of each of the structural types, respectively, to determine a structural type corresponding to the first evaluation text, at least one evaluation target corresponding to the structural type, and a weight of each of the evaluation targets, wherein the first evaluation text is any one of the evaluation text sets; The construction module is used to construct a text evaluation model according to the structural types corresponding to all the evaluation texts in the evaluation text set, the evaluation targets corresponding to each of the structural types, and the weight of each of the evaluation targets.
7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the steps of the text evaluation model construction method described in any one of claims 1 to 5 when executing the program stored in the memory.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the text evaluation model construction method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Character evaluation method and device
CN104573747A
Hard-tipped pen calligraphy work evaluation method
CN111738141A