A code error correction method and device, electronic equipment and storage medium

By performing word segmentation and context vector processing on the input code, and automatically selecting the target vector sequence, the problem of time-consuming, labor-intensive, and inaccurate code correction in existing technologies is solved, achieving efficient and comprehensive code correction.

CN114579184BActive Publication Date: 2026-07-03CHINA CONSTRUCTION BANK

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2022-03-04
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing code error correction methods require manual configuration of rules, which is time-consuming, labor-intensive, and the rules are not comprehensive enough, resulting in inaccurate code error detection.

Method used

By segmenting the input code into words, determining the segmentation vectors and hidden information, and then selecting the target vector sequence based on the weighted sum of context vectors, the system can transform the target code into automated and comprehensive error correction.

Benefits of technology

It achieves efficient and accurate code correction without the need for manual rule configuration, and can comprehensively detect various code errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579184B_ABST
    Figure CN114579184B_ABST
Patent Text Reader

Abstract

This application relates to the field of data processing technology, and provides a code correction method, apparatus, electronic device, and storage medium. The method includes: after segmenting input code into words, determining the segmentation vector of each segmented code; determining the hidden information of each segmented code based on the segmentation vectors of all segmented codes; performing a weighted summation of the hidden information of all segmented codes based on the weight information corresponding to the context vector at any level, to obtain the context vector of that level of the input code; selecting a target vector sequence from a preset set of selectable vectors based on the context vectors at each level; converting each vector in the target vector sequence into a target segmented code, and then combining the target segmented codes according to the order of the vectors in the target vector sequence to obtain the target code. This method accurately determines the target vector sequence corresponding to the corrected code based on the aforementioned context vectors; converting the vectors in the target vector sequence into code form yields the corrected target code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a code correction method, apparatus, electronic device, and storage medium. Background Technology

[0002] During the coding process, problematic code may be written, such as incorrect memory allocation, redundant code, or flawed database statement design. It is necessary to promptly identify and correct these errors.

[0003] In related technologies, after configuring rules, static analysis is used to match the rules in order to identify code that does not conform to the rules.

[0004] However, the above correction method requires manual configuration of rules, which is not only time-consuming and laborious, but the configured rules may not be comprehensive enough, resulting in the inability to accurately detect code errors. Summary of the Invention

[0005] This application provides a code correction method, apparatus, electronic device, and storage medium for accurate and efficient code correction.

[0006] In a first aspect, embodiments of this application provide a code correction method, the method comprising:

[0007] After segmenting the input code into words, determine the segmentation vector for each segmentation code;

[0008] Based on the word segmentation vectors of all word segmentation codes, determine the hidden information of each word segmentation code;

[0009] The hidden information of all word segmentation codes is weighted and summed based on the weight information corresponding to the context vector of any level to obtain the context vector of the input code at that level.

[0010] Based on the context vectors at each level of the input code, a target vector sequence is selected from a preset list of available vectors;

[0011] After converting each vector in the target vector sequence into a target word segmentation code, the target word segmentation codes are combined according to the order of the vectors in the target vector sequence to obtain the target code.

[0012] The above scheme determines the context vector representing the features of the input code, corrects the word segmentation vectors based on this context vector, and accurately determines the target vector sequence corresponding to the standardized code. Then, the vectors in this target vector sequence are converted into code form to obtain the standardized target code. This method not only eliminates the need for manual rule configuration but also provides comprehensive error correction for various types of code.

[0013] In some optional implementations, the hidden information of each segmentation code is determined based on the segmentation vectors of all segmentation codes, including:

[0014] Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and

[0015] For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

[0016] In some optional implementations, a target vector sequence is selected from preset optional vectors based on the context vectors at various levels of the input code, including:

[0017] Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors;

[0018] The target vector sequence is determined based on the target vectors at each level.

[0019] The above scheme, based on the second preset hidden information, context vectors at each level, and preset start symbols, can accurately select target vectors at each level from the available vectors; and then accurately determine the target vector sequence based on the target vectors at each level.

[0020] In some optional implementations, if there are multiple second preset hidden information and / or multiple preset start symbols, then based on the second preset hidden information, the context vectors at each level, and the preset start symbols, the target vectors at each level are selected from the optional vectors, including:

[0021] Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information;

[0022] Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N;

[0023] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0024] Determine the target vector sequence based on the target vectors at each level, including:

[0025] Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

[0026] The above scheme, due to its flexible code writing, may result in more than one standardized target code after error correction of the input code. By determining the target vectors at each level under each combination when there are multiple combinations of second preset hidden information and preset start symbols, and then sorting all the target vectors under each combination according to their level, a sequence of target vectors under each combination is obtained, thereby determining multiple sets of target codes to provide users with more choices.

[0027] In some optional implementations, if there is a second preset hidden information and a preset start symbol, then based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors, including:

[0028] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined;

[0029] Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level;

[0030] Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level;

[0031] For any first-level target vector, based on the Nth-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, and the Nth-level hidden information is determined based on the (N-1)th-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector.

[0032] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0033] Determine the target vector sequence based on the target vectors at each level, including:

[0034] For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

[0035] The above scheme, due to its flexible code writing, may result in more than one standardized target code after error correction of the input code. By determining multiple first-level target vectors under a combination of a second preset hidden information and a preset start symbol, other target vectors corresponding to each first-level target vector are obtained. For any first-level target vector, the first-level target vector and its corresponding other level target vectors are sorted according to their level to obtain multiple sets of target vector sequences, thereby determining multiple sets of target codes to provide users with more choices.

[0036] Secondly, embodiments of this application also provide a code correction device, the device comprising:

[0037] The word segmentation module is used to determine the word segmentation vector of each word segmentation code after the input code is segmented into words;

[0038] The vector processing module is used to determine the hidden information of each word segmentation code based on the word segmentation vectors of all word segmentation codes;

[0039] The vector processing module is further configured to perform a weighted summation of the hidden information of all word segmentation codes based on the weight information corresponding to the context vector of any level, so as to obtain the context vector of the input code at that level.

[0040] The vector processing module is further configured to select a target vector sequence from preset optional vectors based on the context vectors at each level of the input code;

[0041] The code determination module is used to convert each vector in the target vector sequence into target word segmentation code, and then combine the target word segmentation code according to the order of the vectors in the target vector sequence to obtain the target code.

[0042] In some optional implementations, the vector processing module is specifically used for:

[0043] Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and

[0044] For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

[0045] In some optional implementations, the vector processing module is specifically used for:

[0046] Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors;

[0047] The target vector sequence is determined based on the target vectors at each level.

[0048] In some optional implementations, if there are multiple second preset hidden information and / or multiple preset start symbols, the vector processing module is specifically used for:

[0049] Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information;

[0050] Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N;

[0051] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0052] Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

[0053] In some optional implementations, if there is a second preset hidden information and a preset start symbol, the vector processing module is specifically used for:

[0054] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined;

[0055] Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level;

[0056] Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level;

[0057] For any first-level target vector, based on the Nth-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, and the Nth-level hidden information is determined based on the (N-1)th-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector.

[0058] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0059] For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

[0060] Thirdly, embodiments of this application provide an electronic device, including at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor performs any of the code correction methods described in the first aspect above.

[0061] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a computer, which, when run on the computer, causes the computer to perform any of the code correction methods described in the first aspect above.

[0062] Fifthly, embodiments of this application provide a computer program product comprising computer-executable instructions, the computer-executable instructions being used to cause a computer to execute the code correction method as described in any of the first aspects.

[0063] Furthermore, the technical effects of any of the implementation methods in aspects two through five can be found in the technical effects of different implementation methods in aspect one, and will not be repeated here. Attached Figure Description

[0064] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0065] Figure 1 A flowchart illustrating the first code correction method provided in this application embodiment;

[0066] Figure 2 A flowchart illustrating the second code correction method provided in this application embodiment;

[0067] Figure 3 This is a schematic diagram of the code correction model provided in the embodiments of this application;

[0068] Figure 4 A schematic diagram illustrating the processing procedure of the code correction model provided in this application embodiment;

[0069] Figure 5 This is a schematic diagram of the structure of the code correction device provided in the embodiments of this application;

[0070] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0071] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0072] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0073] In this embodiment of the invention, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.

[0074] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the term "connection" should be interpreted broadly. For example, it can refer to a direct connection, an indirect connection through an intermediate medium, or a connection within two devices. Those skilled in the art can understand the specific meaning of the above term in this application based on the specific circumstances.

[0075] During the coding process, problematic code may be written, such as incorrect memory allocation, redundant code, or flawed database statement design. It is necessary to promptly identify and correct these errors.

[0076] In related technologies, after configuring rules (such as manually configuring rules according to the code development manual), static analysis is used to match the rules in order to identify code that does not conform to the rules.

[0077] However, the above correction method requires manual configuration of rules, which is not only time-consuming and laborious, but the configured rules may not be comprehensive enough, resulting in the inability to accurately detect code errors.

[0078] In view of this, embodiments of this application propose a code correction method, apparatus, electronic device, and storage medium. The method includes: after segmenting the input code into words, determining the segmentation vector of each segmented code; determining the hidden information of each segmented code based on the segmentation vectors of all segmented codes; performing a weighted summation of the hidden information of all segmented codes based on the weight information corresponding to the context vector of any level, to obtain the context vector of the input code at that level; selecting a target vector sequence from a preset set of selectable vectors based on the context vectors of each level of the input code; converting each vector in the target vector sequence into a target segmented code, and then combining the target segmented codes according to the order of the vectors in the target vector sequence to obtain the target code.

[0079] The above scheme determines the context vector representing the features of the input code, corrects the word segmentation vectors based on this context vector, and accurately determines the target vector sequence corresponding to the standardized code. Then, the vectors in this target vector sequence are converted into code form to obtain the standardized target code. This method not only eliminates the need for manual rule configuration but also provides comprehensive error correction for various types of code.

[0080] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with reference to the accompanying drawings and specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0081] This application provides a first code correction method, such as... Figure 1 As shown, it includes the following steps:

[0082] Step S101: After segmenting the input code into words, determine the segmentation vector of each segmentation code.

[0083] In practice, the input code is usually quite long, meaning it contains many words. Therefore, it is necessary to first segment the input code to obtain multiple segmented codes.

[0084] For example, if the input code is “"test".equals(object);”, then “"test".equals(object);” will be segmented into the following 6 segmentation codes:

[0085] The first word segmentation code is "test"; the second word segmentation code is ".equals"; the third word segmentation code is "("; the fourth word segmentation code is "object"; the fifth word segmentation code is ")"; and the sixth word segmentation code is ";".

[0086] The above input code and word segmentation results are merely illustrative examples, and this application is not limited thereto.

[0087] In order to better identify the correlation between words, this embodiment also needs to determine the word segmentation vector of the above word segmentation code.

[0088] This embodiment does not limit the specific method for determining the segmentation vector of the segmentation code. For example, the segmentation code can be input into the Continuous Bag-of-Words Model (CBOW) in word embedding (word2vec), and CBOW can output the segmentation vector of the segmentation code.

[0089] Step S102: Based on the word segmentation vectors of all word segmentation codes, determine the hidden information of each word segmentation code.

[0090] In practice, it is necessary to determine the hidden information of each segmentation code based on the correlation between the segmentation vectors of all segmentation codes, and then obtain the context vector that represents the features of the input code.

[0091] In some alternative implementations, step S102 can be implemented in, but is not limited to, the following ways:

[0092] Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and

[0093] For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

[0094] For example, h xi =f w (h x(i-1) ,xi); where xi is the i-th word segmentation code, i=1,2,……s, and s is the total number of word segmentation codes in the input code; h xi For the hidden information of the i-th word segmentation code, h x0 The first preset hidden information; f w It is a non-linear activation function.

[0095] The process of determining the hidden information of the word segmentation code described above is merely an illustrative example, and this application is not limited thereto.

[0096] Step S103: Based on the weight information corresponding to the context vector of any level, the hidden information of all word segmentation codes is weighted and summed to obtain the context vector of the input code at that level.

[0097] In practice, each level of context vector corresponds to weight information, which includes the weight coefficient of each word segmentation code. The hidden information of all word segmentation codes is weighted and summed based on the weight information corresponding to the context vector of each level to obtain the context vector of that level.

[0098] For example, C j =a j1 h x1 +a j2 h x2 +……a js h xs Among them, C j Let a be the context vector of level j, where j = 1, 2, ..., t, and t is the total level of the context vectors; j1 a j2 ... a js This represents the weight information corresponding to the context vector at level j.

[0099] The above-described method for determining the context vector is merely illustrative and is not intended to limit this application.

[0100] It is understandable that the total number of levels in the context vector can be the same as or different from the total number of word segmentation codes in the input code.

[0101] Step S104: Based on the context vectors at each level of the input code, select the target vector sequence from the preset optional vectors.

[0102] The context vectors at each level of the input code represent the characteristics of the input code. Based on the context vectors, the word segmentation vectors of the word segmentation code are corrected, and the target vector sequence corresponding to the standard code can be accurately determined.

[0103] Step S105: After converting each vector in the target vector sequence into target word segmentation code, the target word segmentation code is combined according to the order of the vectors in the target vector sequence to obtain the target code.

[0104] Since the target vector sequence is the vector obtained after correcting the input vector, and this embodiment requires code correction, after determining the target vector sequence, it is also necessary to convert the vectors in the target vector sequence into code form to obtain the target word segmentation code. The target word segmentation code is then combined according to the order of the vectors in the target vector sequence to obtain the corrected and standardized target code.

[0105] The above scheme determines the context vector representing the features of the input code, corrects the word segmentation vectors based on this context vector, and accurately determines the target vector sequence corresponding to the standardized code. Then, the vectors in this target vector sequence are converted into code form to obtain the standardized target code. This method not only eliminates the need for manual rule configuration but also provides comprehensive error correction for various types of code.

[0106] This application provides a second code correction method, such as... Figure 2 As shown, it includes the following steps:

[0107] Step S201: After segmenting the input code into words, determine the segmentation vector of each segmentation code.

[0108] Step S202: Based on the word segmentation vectors of all word segmentation codes, determine the hidden information of each word segmentation code.

[0109] Step S203: Based on the weight information corresponding to the context vector of any level, the hidden information of all word segmentation codes is weighted and summed to obtain the context vector of the input code at that level.

[0110] The specific implementation of steps S201 to S203 can be found in the above embodiments, and will not be repeated here.

[0111] Step S204: Based on the second preset hidden information, the context vectors at each level and the preset start symbol, select the target vectors at each level from the optional vectors.

[0112] As described above, after determining the context vector for each level in this embodiment, it is necessary to select a target vector sequence from a preset list of available vectors based on these context vectors. The target vector sequence includes the target vector corresponding to the context vector for each level. Based on this, it is necessary to determine the target vectors for each level first.

[0113] Step S205: Determine the target vector sequence based on the target vectors at each level.

[0114] Once the target vectors corresponding to all context vectors are determined, the target vector sequence can be determined based on these target vectors.

[0115] Step S206: After converting each vector in the target vector sequence into target word segmentation code, the target word segmentation code is combined according to the order of the vectors in the target vector sequence to obtain the target code.

[0116] The specific implementation of step S206 can be found in the above embodiments, and will not be repeated here.

[0117] The above scheme, based on the second preset hidden information, context vectors at each level, and preset start symbols, can accurately select target vectors at each level from the available vectors; and then accurately determine the target vector sequence based on the target vectors at each level.

[0118] Because the code writing is quite flexible, there may be more than one standardized target code after the input code has been corrected. Based on this, multiple sets of target code can be determined to provide users with more choices.

[0119] In some optional implementations, there are multiple second preset hidden information and / or multiple preset start symbols. Correspondingly, the above step S204 can be implemented in the following ways:

[0120] Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information;

[0121] Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N;

[0122] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0123] The above step S205 can be achieved in the following way:

[0124] Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

[0125] For example, the above-mentioned second preset hidden information and preset start character can be arbitrarily combined (at least one of the second preset hidden information and preset start character in different combinations is different). For example, if there are three second preset hidden information (denoted as A1, A2 and A3) and two preset start characters (denoted as B1 and B2), the first combination is A1+B1, the second combination is A2+B1, the third combination is A3+B1, the fourth combination is A1+B2, the fifth combination is A2+B2, and the sixth combination is A3+B2.

[0126] H j =F w (H j-1 , y j-1 C j ); where H j-1 H0 represents the (j-1)th level of hidden information, and H0 represents the preset hidden information in any combination; y j-1Let y0 be the target vector of level j-1, and y0 be the preset start symbol in this combination; C j F is the context vector for level j; w It is a non-linear activation function;

[0127] P YLj =g(H j , y j-1 C j ); where P YLj H represents the output probability of the optional vector YL at level j; j Hidden information at level j; y j-1 Let y0 be the target vector of level j-1, and y0 be the preset start symbol in this combination; C j This is the context vector for level j; that is...

[0128] For any combination, based on the second preset hidden information in the combination, the first-level context vector, and the preset start symbol in the combination, the first-level hidden information is determined; based on the first-level hidden information, the first-level context vector, and the preset start symbol in the combination, the output probability of each optional vector in the first level is determined; from all optional vectors, the optional vector with the highest output probability in the first level is selected as the first-level target vector (y1).

[0129] Based on the first-level hidden information, the second-level context vector, and the first-level target vector, the second-level hidden information is determined; based on the second-level hidden information, the second-level context vector, and the first-level target vector, the output probability of each optional vector in the second level is determined; from all optional vectors, the optional vector with the highest output probability in the second level is selected as the second-level target vector (y2).

[0130] The same method is used to determine the third-level target vector (y3), the fourth-level target vector (y4), ..., the t-th-level target vector (yt). t );

[0131] Sort all target vectors according to their level to obtain the target vector sequence: y1, y2, ..., y t .

[0132] The above method for determining the target vector sequence is merely an illustrative example, and this application is not limited thereto.

[0133] The above scheme, due to its flexible code writing, may result in more than one standardized target code after error correction of the input code. By determining the target vectors at each level under each combination when there are multiple combinations of second preset hidden information and preset start symbols, and then sorting all the target vectors under each combination according to their level, a sequence of target vectors under each combination is obtained, thereby determining multiple sets of target codes to provide users with more choices.

[0134] In some optional implementations, there is a second preset hidden information and a preset start character. Correspondingly, step S204 above can be implemented in the following way:

[0135] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined;

[0136] Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level;

[0137] Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level;

[0138] For any first-level target vector, based on the Nth-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, and the Nth-level hidden information is determined based on the (N-1)th-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector.

[0139] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0140] The above step S205 can be achieved in the following way:

[0141] For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

[0142] For example, H j =F w (H j-1 , y j-1 C j ); where H j-1 H0 represents the (j-1)th level of hidden information, and H0 represents the preset hidden information in any combination; y j-1 Let y0 be the target vector of level j-1, and y0 be the preset start symbol in this combination; C j F is the context vector for level j; w It is a non-linear activation function;

[0143] P YLj =g(H j , y j-1 C j ); where P YLjH represents the output probability of the optional vector YL at level j; j Hidden information at level j; y j-1 Let y0 be the target vector of level j-1, and y0 be the preset start symbol in this combination; C j This is the context vector for level j; that is...

[0144] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined; based on the first-level hidden information, the first-level context vector, and the preset start symbol in this combination, the output probability of each optional vector in the first level is determined; according to the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the first-level target vectors (e.g., when the preset number is 3, the 3 optional vectors with the highest output probability in the first level are selected from all optional vectors as the first-level target vectors, denoted as y). 1a y 1b and y 1c );

[0145] Based on the first-level hidden information, the second-level context vector, and any first-level target vector, determine the second-level hidden information; based on any second-level hidden information, the second-level context vector, and the corresponding first-level target vector, determine the output probability of each optional vector at the second level; select the optional vector with the highest output probability at the second level from all optional vectors as the second-level target vector (y). 1a The corresponding second-level target vector is denoted as y. 2a y 1b The corresponding second-level target vector is denoted as y. 2b y 1c The corresponding second-level target vector is denoted as y. 2c );

[0146] The third-level target vector (y) is determined using the same method. 3a y 3b and y 3c ), fourth-level target vector (y 4a y 4b and y 4c ), ... the t-th level target vector (y ta y tb and y tc );

[0147] y 1a and y 1a The corresponding target vectors at other levels are sorted according to their respective levels to obtain the first set of target vector sequences: y 1a y 2a ... y ta ; will y 1b and y1b The corresponding target vectors at other levels are sorted according to their respective levels to obtain the second set of target vector sequences: y 1b y 2b ... y tb ; will y 1c and y 1c The corresponding target vectors at other levels are sorted according to their respective levels to obtain the second set of target vector sequences: y 1c y 2c ... y tc .

[0148] The above method for determining the target vector sequence is merely an illustrative example, and this application is not limited thereto.

[0149] The above scheme, due to its flexible code writing, may result in more than one standardized target code after error correction of the input code. By determining multiple first-level target vectors under a combination of a second preset hidden information and a preset start symbol, other target vectors corresponding to each first-level target vector are obtained. For any first-level target vector, the first-level target vector and its corresponding other level target vectors are sorted according to their level to obtain multiple sets of target vector sequences, thereby determining multiple sets of target codes to provide users with more choices.

[0150] See Figure 3 As shown, this embodiment provides a code correction model, including an encoder and a decoder. In practice, the process of determining the context vector (i.e., steps S102-S103, steps S202-S203) can be implemented by the trained encoder; the process of determining the target vector sequence (i.e., steps S104, steps S204-S205) can be implemented by the trained decoder.

[0151] Since the Long Short-Term Memory (LSTM) network model can better understand the semantics of the sequence, both the encoder and decoder mentioned above can adopt the LSTM model.

[0152] See Figure 4 As shown, the word segmentation vectors (x1, x2, x3, x4, x5, and x6) of all the word segmentation codes in the input code are input into the encoder. The encoder determines the hidden information (h) of each word segmentation code. x1 h x2 h x3 h x4 h x5 and h x6After that, the context vectors (C1, C2, C3, C4, C5, C6, and C7) of each level of the input code are output. The decoder determines the hidden information (H1, H2, H3, H4, H5, H6, and H7) of each level based on the context vectors of each level, the preset hidden information, and the preset start symbol. Based on the hidden information, the preset hidden information, the context vectors of each level, and the preset start symbol, the decoder determines the output probability of the optional vector at each level. Based on the output probability of the optional vector at each level, the decoder selects the target vector (y1, y2, y3, y4, y5, y6, and y7) of each level.

[0153] Based on the same inventive concept, this application provides a code correction device, see reference. Figure 5 As shown, the code correction device 500 includes:

[0154] The word segmentation processing module 501 is used to determine the word segmentation vector of each word segmentation code after the input code is segmented into words;

[0155] The vector processing module 502 is used to determine the hidden information of each word segmentation code based on the word segmentation vectors of all word segmentation codes;

[0156] The vector processing module 502 is further configured to perform a weighted summation of the hidden information of all word segmentation codes based on the weight information corresponding to the context vector of any level, so as to obtain the context vector of the input code at that level.

[0157] The vector processing module 502 is further configured to select a target vector sequence from preset optional vectors based on the context vectors at each level of the input code;

[0158] The code determination module 503 is used to convert each vector in the target vector sequence into target word segmentation code, and then combine the target word segmentation code according to the order of the vectors in the target vector sequence to obtain the target code.

[0159] In some optional implementations, the vector processing module 502 is specifically used for:

[0160] Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and

[0161] For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

[0162] In some optional implementations, the vector processing module 502 is specifically used for:

[0163] Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors;

[0164] The target vector sequence is determined based on the target vectors at each level.

[0165] In some optional implementations, if there are multiple second preset hidden information and / or multiple preset start symbols, the vector processing module 502 is specifically used for:

[0166] Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information;

[0167] Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N;

[0168] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0169] Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

[0170] In some optional implementations, if there is a second preset hidden information and a preset start symbol, then the vector processing module 502 is specifically used for:

[0171] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined;

[0172] Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level;

[0173] Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level;

[0174] For any first-level target vector, based on the Nth-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, and the Nth-level hidden information is determined based on the (N-1)th-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector.

[0175] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0176] For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

[0177] Since this device is the same as the device in the method of this application embodiment, and the principle of the device in solving the problem is similar to that of the method, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described again.

[0178] Based on the same technical concept, this application also provides an electronic device 600, such as... Figure 6 As shown, it includes at least one processor 601 and a memory 602 connected to at least one processor. In this embodiment, the specific connection medium between the processor 601 and the memory 602 is not limited. Figure 6 Taking the connection between processor 601 and memory 602 via bus 603 as an example. The bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0179] The processor 601 is the control center of the electronic device, capable of connecting various parts of the device via various interfaces and lines. It performs data processing by running or executing instructions stored in the memory 602 and retrieving data stored in the memory 602. Optionally, the processor 601 may include one or more processing units. The processor 601 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles issuing instructions. It is understood that the modem processor may not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 may be implemented on the same chip; in other embodiments, they may be implemented on separate chips.

[0180] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the code correction method embodiments can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0181] Memory 602, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 602 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 602 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 602 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0182] In this embodiment, the memory 602 stores a computer program, which, when executed by the processor 601, causes the processor 601 to perform the following:

[0183] After segmenting the input code into words, determine the segmentation vector for each segmentation code;

[0184] Based on the word segmentation vectors of all word segmentation codes, determine the hidden information of each word segmentation code;

[0185] The hidden information of all word segmentation codes is weighted and summed based on the weight information corresponding to the context vector of any level to obtain the context vector of the input code at that level.

[0186] Based on the context vectors at each level of the input code, a target vector sequence is selected from a preset list of available vectors;

[0187] After converting each vector in the target vector sequence into a target word segmentation code, the target word segmentation codes are combined according to the order of the vectors in the target vector sequence to obtain the target code.

[0188] In some alternative implementations, processor 601 specifically performs:

[0189] Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and

[0190] For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

[0191] In some alternative implementations, processor 601 specifically performs:

[0192] Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors;

[0193] The target vector sequence is determined based on the target vectors at each level.

[0194] In some optional implementations, if there are multiple second preset hidden information and / or multiple preset start characters, the processor 601 specifically executes:

[0195] Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information;

[0196] Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N;

[0197] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0198] Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

[0199] In some optional implementations, if there is a second preset hidden information and a preset start character, then processor 601 specifically executes:

[0200] Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined;

[0201] Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level;

[0202] Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level;

[0203] For any first-level target vector, based on the Nth-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, and the Nth-level hidden information is determined based on the (N-1)th-level hidden information, the Nth-level context vector, and the (N-1)th-level target vector.

[0204] Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N;

[0205] For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

[0206] Since the electronic device is the same as the electronic device in the method of this application embodiment, and the principle of the electronic device in solving the problem is similar to that of the method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be described again.

[0207] Based on the same technical concept, embodiments of this application also provide a computer-readable storage medium storing a computer program executable by a computer, which, when run on the computer, causes the computer to perform the steps of the above-described code correction method.

[0208] In some alternative implementations, various aspects of the code correction method provided in this application can also be implemented as a program product containing computer-executable instructions. When the program product is run on a computer device, the computer-executable instructions are used to cause the computer device to perform the steps of the code correction method according to the various exemplary embodiments of this application described above.

[0209] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0210] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0211] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0212] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0213] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0214] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of error correction of a code, characterized in that, The method includes: After segmenting the input code into words, determine the segmentation vector for each segmentation code; Based on the word segmentation vectors of all word segmentation codes, determine the hidden information of each word segmentation code; The hidden information of all word segmentation codes is weighted and summed based on the weight information corresponding to the context vector of any level to obtain the context vector of the input code at that level. Based on the context vectors at each level of the input code, a target vector sequence is selected from a preset list of available vectors; After converting each vector in the target vector sequence into a target word segmentation code, the target word segmentation codes are combined according to the order of the vectors in the target vector sequence to obtain the target code; Based on the context vectors at each level of the input code, a target vector sequence is selected from a preset list of available vectors, including: Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors; Determine the target vector sequence based on the target vectors at each level; If there is a second preset hidden information and a preset start symbol, then based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors, including: Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined; Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level; Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level; For the Nth level target vector, based on the Nth level hidden information, the Nth level context vector, and the (N-1)th level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, the Nth level hidden information is determined based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector; Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N; Determine the target vector sequence based on the target vectors at each level, including: For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

2. The method as described in claim 1, characterized in that, Based on the word segmentation vectors of all word segmentation codes, the hidden information of each word segmentation code is determined, including: Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

3. The method as described in claim 1, characterized in that, If there are multiple second preset hidden information and / or multiple preset start symbols, then based on the second preset hidden information, the context vectors at each level, and the preset start symbols, target vectors at each level are selected from the optional vectors, including: Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information; Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N; Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N; Determine the target vector sequence based on the target vectors at each level, including: Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

4. A code correction device, characterized in that, The device includes: The word segmentation module is used to determine the word segmentation vector of each word segmentation code after the input code is segmented into words; The vector processing module is used to determine the hidden information of each word segmentation code based on the word segmentation vectors of all word segmentation codes; The vector processing module is further configured to perform a weighted summation of the hidden information of all word segmentation codes based on the weight information corresponding to the context vector of any level, so as to obtain the context vector of the input code at that level. The vector processing module is further configured to select a target vector sequence from preset optional vectors based on the context vectors at each level of the input code; The code determination module is used to convert each vector in the target vector sequence into target word segmentation code, and then combine the target word segmentation code according to the order of the vectors in the target vector sequence to obtain the target code; The vector processing module is specifically used for: Based on the second preset hidden information, the context vectors at each level and the preset start symbol, the target vectors at each level are selected from the optional vectors; Determine the target vector sequence based on the target vectors at each level; If there is a second preset hidden information and a preset start symbol, then the vector processing module is specifically used for: Based on the second preset hidden information, the first-level context vector, and the preset start symbol, the first-level hidden information is determined; Based on the first-level hidden information, the first-level context vector, and the preset start symbol, determine the output probability of each optional vector at the first level; Based on the output probability of each optional vector in the first level, a preset number of optional vectors are selected from all optional vectors as the target vectors for the first level; For the Nth level target vector, based on the Nth level hidden information, the Nth level context vector, and the (N-1)th level target vector, determine the output probability of each optional vector at the Nth level; where N≥2, the Nth level hidden information is determined based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector; Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N; For any first-level target vector, sort the first-level target vector and the other level target vectors corresponding to the first-level target vector according to their level to obtain the target vector sequence corresponding to the first-level target vector.

5. The apparatus as described in claim 4, characterized in that, The vector processing module is specifically used for: Based on the first preset hidden information and the word segmentation vector of the first word segmentation code, the hidden information of the first word segmentation code is determined; wherein, the first word segmentation code is the first word segmentation code determined based on the order of word segmentation codes in the input code; and For any other word segmentation code besides the first word segmentation code, the hidden information of the other word segmentation code is determined based on the word segmentation vector of the other word segmentation code and the hidden information of the previous word segmentation code; wherein, the previous word segmentation code is the word segmentation code preceding the other word segmentation code determined based on the order of the word segmentation codes in the input code.

6. The apparatus as claimed in claim 4, characterized in that, If there are multiple second preset hidden information and / or multiple preset start symbols, then the vector processing module is specifically used for: Based on the (N-1)th level hidden information, the Nth level context vector, and the (N-1)th level target vector, the Nth level hidden information is determined; where, if N=1, the (N-1)th level target vector is any preset start symbol, and the (N-1)th level hidden information is any second preset hidden information; Based on the hidden information at level N, the context vector at level N, and the target vector at level N-1, determine the output probability of each optional vector at level N; Select the optional vector with the highest output probability at level N from all optional vectors as the target vector at level N; Sort all target vectors according to their level to obtain the second preset hidden information and the target vector sequence corresponding to the preset start symbol.

7. An electronic device, characterized in that, It includes at least one processor and at least one memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method as described in any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that, It stores a computer program executable by a computer, which, when run on the computer, causes the computer to perform the method as described in any one of claims 1 to 3.

9. A computer program product, characterized in that, It includes computer-executable instructions for causing a computer to perform the method as described in any one of claims 1 to 3.