Chinese grammar sequence editing and correction method, system, medium and device based on fusion of pronunciation and meaning
By using the BERT model that integrates sound and meaning information with the label information of the text, the correct text sequence is generated. This solves the problems of poor generalization and slow inference speed of existing Chinese text error correction methods, and achieves efficient error correction for multiple characters, missing characters, and word order swapping.
Patent Information
- Application Number
- CN202310546414.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-05-16
AI Technical Summary
Existing Chinese text correction methods rely on word segmentation tools and confusion sets, resulting in poor generalization. Error correction models based on BERT can only handle substitution errors, have slow inference speed, and are difficult to effectively correct errors such as extra characters, missing characters, and word order swapping.
Combining the phonetic and semantic information of the text, a BERT-based phonetic and semantic fusion training and editing method is adopted. By obtaining the label information, representation matrix and pinyin information of the erroneous text sequence, the correct text sequence is generated, and error correction is performed using the loss function of the linear detection and correction layer.
It improves the accuracy and practicality of Chinese text error correction, reduces false alarms, has fast inference speed, does not rely on word segmentation tools and confusion sets, and is suitable for practical application scenarios.
Smart Images

Figure CN116611427B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of text error correction, and particularly relates to a sound-meaning fusion Chinese grammar sequence editing error correction method, system, medium and equipment. BACKGROUND
[0002] The common error types of Chinese text can be divided into four categories: substitution error, multiple word error, few word error and word order exchange error, as shown in Table 1. Among them, multiple word error and few word error are also called redundancy error and missing error.
[0003] Table 1, Chinese text error example
[0004] Type Sentence Correct sentence On XX, ABC square was crowded with people, and it was very lively. Replace error On XX, ABC square was crowded with people, and it was very lively. More word error On XX, ABC square square was crowded with people, and it was very lively. Fewer word error On XX, AB square was crowded with people, and it was very lively. Word order exchange error On XX, square ABC was crowded with people, and it was very lively.
[0005] In the prior art, the following methods are mainly used for Chinese text error correction.
[0006] (1) Rule-based Chinese text error correction.
[0007] This method mainly relies on a word library and a word segmentation tool. For example, when correcting "AB" in "ABCDE", "AB" and "ab" need to be added as a pair of replacement words to the word library, and appropriate rules need to be set according to the surrounding semantic information to accurately correct. However, this method requires the staff to have rich linguistic knowledge when constructing rules, and is time-consuming and laborious, and has poor generalization.
[0008] (2) N-gram model-based Chinese text error correction.
[0009] When correcting errors based on the N-gram model, first, the Chinese word segmentation technology is used to segment the given sentence, then the confusion set of the corresponding words in the sentence is found according to the judgment condition, then each character in the confusion set of each replaceable character in the sentence is enumerated to replace the original character, thereby obtaining a candidate sentence set, and finally the bi-gram model and tri-gram model are combined to calculate the score of each candidate sentence, and the sentence with the highest score is output. However, this method needs to rely on a word segmentation tool and a confusion set.
[0010] In addition, the error correction model based on bert / roberta can only predict substitution errors; the error correction model based on seq2seq has a very slow inference speed. SUMMARY
[0011] In view of the above-mentioned shortcomings of the prior art, the purpose of the present application is to provide a sound-meaning fusion Chinese grammar sequence editing error correction method, system, medium and equipment, which combines the sound-meaning information of the text, uses a sound-meaning fusion training editing method based on BERT to correct Chinese grammar, and effectively improves the accuracy and practicality.
[0012] In a first aspect, the present application provides a Chinese grammar sequence editing and correcting method based on sound-meaning fusion, comprising the following steps: obtaining an error text sequence; training a text correction model based on the error text sequence; wherein the text correction model obtains a correct text sequence corresponding to the error text sequence; obtaining label information of each character in the error text sequence based on the correct text sequence; generating a representation matrix and pinyin information of the error text sequence based on the label information; obtaining the correct text sequence based on the representation matrix and the pinyin information; and correcting a to-be-corrected text based on the trained text correction model.
[0013] In an implementation form of the first aspect, obtaining the correct text sequence corresponding to the error text sequence comprises the following steps:
[0014] Obtaining all possible candidate correct text sequences corresponding to the error text sequence;
[0015] Selecting a candidate correct text sequence with the maximum posterior probability as the correct text sequence.
[0016] In an implementation form of the first aspect, the correct text sequence and the error text sequence have different lengths.
[0017] In an implementation form of the first aspect, the label information comprises character correct label, character deletion label, character replacement label, character insertion label and word order reversal label.
[0018] In an implementation form of the first aspect, the detection information represents whether each character in the error text sequence is correct; the correction information represents a corrected character corresponding to each character in the error text sequence; and the pinyin information represents pinyin of each character in the error text sequence.
[0019] In an implementation form of the first aspect, obtaining the label information of each character in the error text sequence based on the correct text sequence comprises the following steps:
[0020] Generating an embedding sequence, a detection annotation sequence, a correction annotation sequence and a pinyin sequence of a BERT model based on the label information; the detection annotation sequence represents whether each character in the error text sequence is correct in sequence; the correction annotation sequence represents a corrected character corresponding to each character in the error text sequence in sequence; and the pinyin sequence represents pinyin of each character in the error text sequence in sequence;
[0021] Inputting the embedding sequence into an initialized BERT model layer to obtain a representation matrix of the error text sequence;
[0022] input the pinyin sequence to a pinyin embedding layer to obtain the pinyin information.
[0023] In an implementation form of the first aspect, the obtaining the correct text sequence based on the representation matrix and the pinyin information comprises the following steps:
[0024] concatenating the representation matrix and the pinyin information to obtain concatenated combination information;
[0025] inputting the concatenated combination information and the detection label sequence to a linear detection layer to obtain detection information;
[0026] inputting the concatenated combination information and the correction label sequence to a linear correction layer to obtain correction information, wherein the correction information is the correct text sequence.
[0027] In an implementation form of the first aspect, the loss function of the text correction model adopts L = λL c +(1-λ)L d , wherein L d and L c are loss functions of the linear detection layer and the linear correction layer respectively, and λ represents a balance coefficient.
[0028] Secondly, the present application provides a Chinese grammar sequence editing and correction system based on fusion of pronunciation and meaning, which comprises an acquisition module, a training module and a correction module.
[0029] The acquisition module is configured to acquire an error text sequence.
[0030] The training module is configured to train a text correction model based on the error text sequence, wherein the text correction model obtains a correct text sequence corresponding to the error text sequence, obtains label information of each character in the error text sequence based on the correct text sequence, generates a representation matrix and pinyin information of the error text sequence based on the label information, and obtains the correct text sequence based on the representation matrix and the pinyin information.
[0031] The correction module is configured to correct a text to be corrected based on the trained text correction model.
[0032] Thirdly, the present application provides an electronic device, which comprises a processor and a memory.
[0033] The memory is configured to store a computer program.
[0034] The processor is configured to execute the computer program stored in the memory, so that the electronic device executes the Chinese grammar sequence editing and correction method based on fusion of pronunciation and meaning.
[0035] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the program is executed by an electronic device to implement the above-mentioned Chinese grammar sequence editing and error correction method of sound-meaning fusion.
[0036] As described above, the Chinese grammar sequence editing and error correction method, system, medium and device of sound-meaning fusion have the following beneficial effects.
[0037] (1) The sound-meaning information of the text is combined, and the BERT-based neural network model is used for Chinese grammar correction, which reduces the false positives caused by excessive reliance on mark information and ignoring pinyin information.
[0038] (2) The BERT-based neural network model does not depend on the confusion set and the word segmentation tool, and only needs to input the constructed training corpus into the model.
[0039] (3) The inference speed of the sequence editing-based network model is very fast, which meets the needs of the actual application scenarios. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 A scene schematic diagram of an embodiment of the electronic device of the present application is shown.
[0041] Figure 2 A flowchart of an embodiment of the Chinese grammar sequence editing and error correction method of sound-meaning fusion of the present application is shown.
[0042] Figure 3 A framework schematic diagram of an embodiment of the Chinese grammar sequence editing and error correction method of sound-meaning fusion of the present application is shown.
[0043] Figure 4 A generation schematic diagram of an embodiment of the label information of the present application is shown.
[0044] Figure 5 A structure schematic diagram of an embodiment of the Chinese grammar sequence editing and error correction system of sound-meaning fusion of the present application is shown.
[0045] Figure 6 A structure schematic diagram of an embodiment of the electronic device of the present application is shown. DETAILED DESCRIPTION
[0046] Following make the embodiments of the present application specific, specific examples of the present application can be easily understood by those skilled in the art from the disclosure of the specification, other advantages and effects of the present application. The present application can also be implemented or applied by different specific embodiments, and the details in the specification can be modified or changed based on different views and applications without departing from the spirit of the present application. It should be noted that the following examples and features in the examples can be combined with each other without conflict.
[0047] It should be noted that the diagrams provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and only the components related to the present application are shown in the diagrams, not the number, shape and size of the components when actually implemented. The actual implementation of each component may be a random change, and the component layout pattern may be more complex.
[0048] The following examples of the present application provide a Chinese grammar sequence editing and error correction method with sound and meaning fusion, which can be applied to electronic devices such as Figure 1 The electronic device described in the present application can include a mobile phone 11, a tablet computer 12, a notebook computer 13, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. with wireless charging function. The specific type of electronic device is not limited in the embodiments of the present application.
[0049] For example, the electronic device can be a station (STATION, ST) in a WLAN with wireless charging capability, can be a cellular phone with wireless charging capability, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless charging capability, a computing device or other processing device, a computer, a laptop, a handheld communication device, a handheld computing device, and / or other equipment for communicating over a wireless system and a next-generation communication system, for example, a mobile terminal in a 5G network, a mobile terminal in a future evolved public land mobile network (PLMN), or a mobile terminal in a future evolved non-terrestrial network (NTN), etc.
[0050] For example, the electronic device can communicate with a network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou navigation satellite system (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).
[0051] The technical solutions in the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0052] As shown in Figure 2 and Figure 3 The phonetic and semantic fusion Chinese grammar sequence editing and error correction method of the present application comprises the following steps.
[0053] Step S1, obtaining an error text sequence.
[0054] Specifically, Chinese texts containing errors such as wrong words, multiple words, few words, and reversed word order are collected as the error text sequence.
[0055] Step S2, training a text error correction model based on the error text sequence; wherein the text error correction model is used to obtain a correct text sequence corresponding to the error text sequence, to obtain label information of each character in the error text sequence based on the correct text sequence, to generate a representation matrix and pinyin information of the error text sequence based on the label information, and to obtain the correct text sequence based on the representation matrix and the pinyin information.
[0056] Specifically, the text error correction model is used to correct errors such as wrong words, multiple words, few words, and reversed word order in the error text sequence. The error correction of the text error correction model comprises the following steps.
[0057] 21) obtaining a correct text sequence corresponding to the error text sequence.
[0058] wherein, given an error text sequence X = {x1, x2,…, x n}, all possible candidate correct text sequences corresponding thereto are obtained; the candidate correct text sequence with the maximum posterior probability P(Y |X) is selected as the correct text sequence, wherein Y = {y1, y2, …, y m}. It should be noted that X and Y can have different lengths or the same length.
[0059] 22) obtaining label information of each character in the error text sequence based on the correct text sequence.
[0060] The label information includes a correct character label, a deleted character label, a replaced character label, an inserted character label, and a word order reversal label. For example, the correct text sequence is "ABCDEFG". When the incorrect text sequence is "ABcdEFG", the label information is "$STARTL|||R$K AL|||R$K BL|||R$K cL|||R$R_CdL|||R$R_DEL|||R$K FL|||R$K GL|||R$K。L|||R$K". When the incorrect text sequence is "ABCEFG", the label information is "$STARTL|||R$K AL|||R$K BL|||R$K CL|||R$A_DEL|||R$K FL|||R$K GL|||R$K。L|||R$K". When the error text sequence is "ABCDEFHG.", the label information is "$STARTL|||R$K AL|||R$K BL|||R$K CL|||R$K DL|||R$K EL|||R$K FL|||R$K HL|||R$D GL|||R$K。L|||R$K". Among them, "L|||R" in the above label is the separator between the character and the label, "$K" indicates that the current character is correct, "$D" indicates that the current character needs to be deleted, "$R_word" indicates that the current character needs to be replaced with word, and "$A_word" indicates that word needs to be inserted after the current character.
[0061] like Figure 4 As shown, when the source text sequence is "Appreciate the charming scenery together" and the correct text sequence is "Appreciate the beautiful scenery together", the corresponding label information is $STARTL|||R$K一L|||R$K一起L|||R$K享受L|||R$A_赏魅L|||R$R_美力L|||R$R_丽的L|||R$K风L|||R$K景L|||R$K。
[0062] In actual use, 22,107 labels are generated based on the Chinese characters, numbers, and punctuation marks in the BERT vocabulary, of which $R_word and $A_word have 11,050 labels respectively. In addition, $D, $K, $T (indicating reversed word order), $UNK (indicating unknown), and $PAD (indicating padding) are also included. When $R_word and $A_word cannot find a mapping relationship in the vocabulary, the mapping of $UNK is used instead. When the length of the converted label is less than the maximum length, $PAD is used for padding. For example, the length of "Enjoy the charming scenery together" is 8, and the length after the label conversion is 9. However, in the actual training process, the length of each sentence needs to be padded to the maximum length. If the maximum length is 12, the padded tag information is: $STARTL|||R$K一L|||R$K起L|||R$K欣L|||R$A_赏魅L|||R$R_美力L|||R$R_丽的L|||R$K风L|||R$K景L|||R$K$PAD$PAD$PAD. In addition, there are a total of four error checking tags: COR (indicates the current word is correct), ERR (indicates the current word is incorrect), UNK (indicates unknown), and PAD (indicates padding). An error checking label can be generated according to the label information. For example, for the label information “$STARTL|||R$KAL|||R$K BL|||R$K cL|||R$R_CdL|||R$R_DEL|||R$K FL|||R$K GL|||R$K。L|||R$K”, the corresponding error checking label is “COR COR COR ERR ERR COR COR COR COR COR”.
[0063] 23) Generate a representation matrix and pinyin information of the erroneous text sequence based on the label information.
[0064] In one embodiment, generating a representation matrix and pinyin information of the erroneous text sequence based on the label information includes the following steps.
[0065] 231) Generate the embedding sequence E = {e1, e2, …, e n}、Detection annotation sequence , correct the label sequence , Pinyin sequence . Among them, the detection annotation sequence sequentially indicates whether each character in the erroneous text sequence is correct; the correction annotation sequence sequentially indicates the correction character corresponding to each character in the erroneous text sequence; and the pinyin sequence sequentially indicates the pinyin of each character in the erroneous text sequence.
[0066] Specifically, e i Represents character x icharacter embeddings, position embeddings, tokenization embeddings in a given text X = {x 1, x2, …, x n}. denotes whether a given character x i is correct in a given text X; if correct, then , otherwise . denotes which character a given character x i should be corrected to in a given text X. Since most characters in a text are correct and only a small portion of characters need to be corrected, most characters remain unchanged and only a small portion of characters need to be replaced by the correct characters. denotes the pinyin of a character x i .
[0067] 232) input the embedding sequence into an initialized BERT model layer to obtain a representation matrix H of the error text sequence.
[0068] where BERT is a pre-trained language model based on a Transformer encoder, and the Transformer encoder generates a representation matrix H = {h1, h2, …, hn} of the hidden layers for a given text X, where hi∈ R 768 is a representation of xi.
[0069] 233) input the pinyin sequence into a pinyin embedding layer to obtain the pinyin information Hp.
[0070] where common misspelled words in Chinese correction are mostly spelling errors, and without pinyin, it is easy to correct the error word to another reasonable but significantly different word from the error word. For example, the “hao” in the source text sequence “today the weather is really hao.” will be corrected to “hao”, but it is most appropriate to modify it to “good” here. In order to select a better result between the two recommended words, pinyin needs to be added to the model to select the best answer according to the pinyin information of the characters. In an embodiment, the open source pypinyin package is used to convert common Chinese characters into pinyin without tone, and finally 417 common Chinese pinyin libraries are formed by removing duplicates, where the pinyin of each character is composed of Roman characters, and then a pinyin embedding layer is formed. The pinyin sequence is input into the pinyin embedding layer to obtain the pinyin information Hp.
[0071] 24) obtain the correct text sequence based on the representation matrix and the pinyin information.
[0072] In an embodiment, obtaining the correct text sequence based on the representation matrix and the pinyin information includes the following steps.
[0073] 241) Splicing the representation matrix H and the pinyin information Hp to obtain spliced combination information.
[0074] 242) Inputting the spliced combination information and the detection label sequence into a linear detection layer to obtain detection information Hd.
[0075] 243) Inputting the spliced combination information and the correction label sequence into a linear correction layer to obtain correction information Hc, that is, the correct text sequence.
[0076] Wherein, the representation matrix H of BERT is spliced with the pinyin feature Hp, the shape is changed from (BatchSize * maximum length of sentence * 768) to (BatchSize * maximum length of sentence * 968), and the spliced result is taken as the final input of the linear detection layer and the linear correction layer, so as to obtain the correct text sequence.
[0077] It should be noted that the detection task of the linear detection layer is defined as a classification task of whether the character needs to be modified, and the correction task of the linear correction layer is defined as a classification task of what character to modify, and their loss functions are respectively:
[0078]
[0079] The linear combination of the above two loss functions is taken as the loss function of the text correction model, that is, L = λLc + (1-λ)Ld, where Ld and Lc are the loss functions of the linear detection layer and the linear correction layer respectively, λ represents a balance coefficient, and λ∈ [0, 1].
[0080] Step S3, based on the trained text correction model, the error correction of the text to be corrected is performed.
[0081] Specifically, when the Chinese grammar sequence editing correction of phonetic and semantic fusion needs to be performed, the Chinese text is input into the trained text correction model, and the corresponding correction text can be obtained.
[0082] The protection scope of the Chinese grammar sequence editing correction method of phonetic and semantic fusion according to the embodiment of the application is not limited to the order of steps listed in the embodiment, and any scheme realized by adding, replacing or replacing steps of the prior art according to the principle of the application is included in the protection scope of the application.
[0083] The embodiment of the present application also provides a Chinese grammar sequence editing and error correcting system with sound-meaning fusion, which can realize the Chinese grammar sequence editing and error correcting method with sound-meaning fusion, but the implementation device of the Chinese grammar sequence editing and error correcting system with sound-meaning fusion of the present application includes but is not limited to the structure of the Chinese grammar sequence editing and error correcting system with sound-meaning fusion of the embodiment, and any structure modification and replacement of the prior art according to the principle of the present application is included in the protection scope of the present application.
[0084] As shown in the figure, in an embodiment, the Chinese grammar sequence editing and error correcting system with sound-meaning fusion of the present application includes an acquisition module 51, a training module 52 and an error correcting module 53. Figure 5
[0085] The acquisition module 51 is used for acquiring an error text sequence.
[0086] The training module 52 is connected with the acquisition module 51 and is used for training a text error correcting model based on the error text sequence; wherein the text error correcting model acquires a correct text sequence corresponding to the error text sequence; acquires label information of each character in the error text sequence based on the correct text sequence; generates a representation matrix and pinyin information of the error text sequence based on the label information; and acquires the correct text sequence based on the representation matrix and the pinyin information.
[0087] The error correcting module 53 is connected with the training module 52 and is used for performing error correction on a text to be corrected based on the trained text error correcting model.
[0088] The structure and principle of the acquisition module 51, the training module 52 and the error correcting module 53 correspond to the steps of the Chinese grammar sequence editing and error correcting method with sound-meaning fusion one by one, and thus will not be repeated here.
[0089] In the several embodiments of the present application, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic. The division of the modules / units is only a logical function division. There can be another division manner for actual implementation, for example, a plurality of modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed modules can be indirect coupling or communication connection through some interfaces, devices or modules, and can be electrical, mechanical or other forms.
[0090] The modules / units described as separated components may or may not be physically separated, and the components shown as modules / units may or may not be physical modules, i.e., may be located in one place, or may be distributed on multiple network units. Part or all of the modules / units may be selected to achieve the purposes of the embodiments of the present application according to actual needs. For example, the functional modules / units in various embodiments of the present application may be integrated in one processing module, or may be physically separated, or two or more modules / units may be integrated in one module / unit.
[0091] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0092] The embodiments of the present application also provide a computer readable storage medium. Those of ordinary skill in the art can understand that all or part of the steps of the methods described above can be completed by programs instructing a processor, and the programs can be stored in a computer readable storage medium, which is a non-transitory medium, such as a random access memory, a read only memory, a flash memory, a hard disk, a solid state disk, a magnetic tape, a floppy disk, an optical disc and any combination thereof. The storage medium described above can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid state disk (SSD)) etc.
[0093] The embodiments of the present application also provide an electronic device. The electronic device includes a processor and a memory.
[0094] The memory is used to store a computer program.
[0095] The memory includes ROM, RAM, disk, U disk, memory card or optical disc and various media that can store program codes.
[0096] The processor is connected with the memory, and is used for executing the computer program stored in the memory, so that the electronic device executes the above-mentioned Chinese grammar sequence editing and error correction method of sound-meaning fusion.
[0097] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; and can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0098] As shown in Figure 6 The electronic device of the present application is in the form of a general-purpose computing device. The components of the electronic device can include, but are not limited to, one or more processors or processing units 61, a memory 62, and a bus 63 that connects different system components, including the memory 62 and the processing unit 61.
[0099] The bus 63 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processor or local bus using any of a variety of bus architectures. By way of example, these architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0100] The electronic device typically includes a variety of computer system readable media. These media can be any available media that is accessible by the electronic device and includes both volatile and non-volatile media, removable and non-removable media.
[0101] The memory 62 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 621 and / or cache memory 622. The electronic device can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 623 can be used for reading from and writing to non-removable, non-volatile magnetic media (e.g., a "hard drive"). Figure 6 (not shown), commonly referred to as a "hard disk drive"). Although Figure 6Although not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), as well as an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) can be provided. In these cases, each drive can be connected to bus 63 via one or more data media interfaces. Memory 62 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0102] A program / utility 624 having a set (at least one) of program modules 6241 may be stored, for example, in memory 62. Such program modules 6241 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 6241 generally implement the functions and / or methods of the embodiments described herein.
[0103] The electronic device may also communicate with one or more external devices (e.g., a keyboard, a pointing device, a display, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 64. Furthermore, the electronic device may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 65. Figure 6 As shown, the network adapter 65 communicates with other modules of the electronic device via the bus 63. It should be understood that, although not shown in the figures, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0104] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A Chinese grammatical sequence editing and error correction method integrating sound and meaning, characterized in that: The method comprises the following steps: Get the error text sequence; Training a text error correction model based on the erroneous text sequence; wherein training the text error correction model includes obtaining a correct text sequence corresponding to the erroneous text sequence, obtaining label information of each character in the erroneous text sequence based on the correct text sequence, generating a representation matrix and pinyin information of the erroneous text sequence based on the label information, and obtaining a corrected text sequence based on the representation matrix and the pinyin information; Correct the text to be corrected based on the trained text correction model; Generating the representation matrix and pinyin information of the erroneous text sequence based on the label information comprises the following steps: Generate an embedding sequence, a detection annotation sequence, a correction annotation sequence, and a pinyin sequence of a BERT model based on the label information; the detection annotation sequence sequentially indicates whether each character in the erroneous text sequence is correct; the correction annotation sequence sequentially indicates the corrected character corresponding to each character in the erroneous text sequence; and the pinyin sequence sequentially indicates the pinyin of each character in the erroneous text sequence; Inputting the embedded sequence into the initialized BERT model layer to obtain a representation matrix of the erroneous text sequence; Inputting the pinyin sequence into the pinyin embedding layer to obtain the pinyin information; Acquiring the corrected text sequence based on the representation matrix and the pinyin information comprises the following steps: Splicing the representation matrix and the phonetic information to obtain splicing combination information; Inputting the splicing combination information and the detection annotation sequence into a linear detection layer to obtain detection information; Inputting the splicing combination information and the corrected annotation sequence into a linear correction layer to obtain correction information, where the correction information is the corrected text sequence; Obtaining a correct text sequence corresponding to the erroneous text sequence includes the following steps: Obtain all possible candidate correct text sequences corresponding to the erroneous text sequence; Selecting the candidate correct text sequence with the largest posterior probability as the correct text sequence; The label information includes a correct character label, a deleted character label, a replaced character label, an inserted character label, and a word order reversal label.
2. The Chinese grammatical sequence editing and error correction method of the phonetic-meaning fusion according to claim 1 is characterized by: The correct text sequence and the incorrect text sequence have different lengths.
3. The Chinese grammatical sequence editing and error correction method of the phonetic-meaning fusion according to claim 1 is characterized by: The loss function of the text error correction model adopts L=λL c +(1-λ)L d , where L d and L c are the loss functions of the linear detection layer and the linear correction layer respectively, and λ represents the balance coefficient.
4. A Chinese grammatical sequence editing and error correction system integrating sound and meaning, characterized in that: The system includes an acquisition module, a training module and an error correction module; The acquisition module is used to obtain an error text sequence; The training module is used to train a text error correction model based on the erroneous text sequence; wherein training the text error correction model includes obtaining a correct text sequence corresponding to the erroneous text sequence, obtaining label information of each character in the erroneous text sequence based on the correct text sequence, generating a representation matrix and pinyin information of the erroneous text sequence based on the label information, and obtaining a corrected text sequence based on the representation matrix and the pinyin information; The error correction module is used to correct the text to be corrected based on the trained text error correction model; Generating the representation matrix and pinyin information of the erroneous text sequence based on the label information comprises the following steps: Generate an embedding sequence, a detection annotation sequence, a correction annotation sequence, and a pinyin sequence of a BERT model based on the label information; the detection annotation sequence sequentially indicates whether each character in the erroneous text sequence is correct; the correction annotation sequence sequentially indicates the corrected character corresponding to each character in the erroneous text sequence; and the pinyin sequence sequentially indicates the pinyin of each character in the erroneous text sequence; Input the embedded sequence into the initialized BERT model layer to obtain a representation matrix of the erroneous text sequence; Inputting the pinyin sequence into the pinyin embedding layer to obtain the pinyin information; Acquiring the corrected text sequence based on the representation matrix and the pinyin information comprises the following steps: Splicing the representation matrix and the phonetic information to obtain splicing combination information; Inputting the splicing combination information and the detection annotation sequence into a linear detection layer to obtain detection information; Inputting the splicing combination information and the corrected annotation sequence into a linear correction layer to obtain correction information, where the correction information is the corrected text sequence; Obtaining a correct text sequence corresponding to the erroneous text sequence includes the following steps: Obtain all possible candidate correct text sequences corresponding to the erroneous text sequence; Selecting the candidate correct text sequence with the largest posterior probability as the correct text sequence; The label information includes a correct character label, a deleted character label, a replaced character label, an inserted character label, and a word order reversal label.
5. An electronic device, characterized in that: The electronic device includes: a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the computer program stored in the memory, so that the electronic device executes the Chinese grammatical sequence editing and error correction method for integrating sound and meaning according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by an electronic device, the Chinese grammatical sequence editing and error correction method for the fusion of sound and meaning as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Error correction method and device, and computing equipment
CN112784582A
Error correction method, system and device after character recognition
CN115565179A