Text punctuation adding method, device, medium and electronic device
By combining word segmentation and relation vector analysis with pre-trained models and algorithms, the problem of inaccurate punctuation addition in existing technologies has been solved, improving text readability and the effectiveness of natural language processing tasks.
Patent Information
- Application Number
- CN202011344671.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2040-11-25
AI Technical Summary
Existing punctuation addition methods fail to effectively consider the characteristics of the text to be punctuated, resulting in inaccurate punctuation addition and affecting the performance of natural language processing tasks.
The text to be added is segmented to determine the relationship vectors between words. A pre-trained attention model and a bidirectional LSTM layer are used for feature extraction. The Viterbi algorithm is combined to calculate the punctuation addition method, taking into account the relationship between words and the text structure.
This improved the accuracy of punctuation addition, enhanced text readability, and thus improved the performance of downstream natural language processing tasks.
Smart Images

Figure CN112464642B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, in particular to a method and device for adding punctuation to text, a medium and an electronic device. BACKGROUND
[0002] With the continuous development of artificial intelligence, various deep learning operations have emerged. At present, whether it is text generated by speech recognition or various social network corpus, it is text without any punctuation. Due to the lack of necessary sentence boundaries and punctuation information, the readability of the text is low, which has a certain influence on some natural language processing tasks downstream, such as intent recognition, named entity recognition, etc. The existing punctuation adding method needs to construct features manually as input, without considering the features of the text to be added, and the added punctuation is not accurate enough. SUMMARY
[0003] The present application aims to provide a method and device for adding punctuation to text, which can improve the accuracy of punctuation addition to a certain extent.
[0004] According to an aspect of an embodiment of the present application, a method for adding punctuation to text is provided, including: obtaining a text to be added, and performing word segmentation on the text to be added to obtain a plurality of words; obtaining the relationship between each word in the plurality of words, obtaining the dependency word of each word, and obtaining the relationship between each word and its dependency word; determining the relationship vector of each word based on each word, the dependency word of each word, and the relationship between each word and its dependency word; obtaining the relationship between the relationship vectors of the plurality of words; and adding punctuation between the plurality of words based on the relationship between the relationship vectors.
[0005] According to an aspect of an embodiment of the present application, a device for adding punctuation to text is provided, including: an obtaining module configured to obtain a text to be added, and perform word segmentation on the text to be added to obtain a plurality of words; obtain the relationship between each word in the plurality of words, obtain the dependency word of each word, and obtain the relationship between each word and its dependency word; a determining module configured to determine the relationship vector of each word based on each word, the dependency word of each word, and the relationship between each word and its dependency word; and an adding module configured to obtain the relationship between the relationship vectors of the plurality of words, and add punctuation between the plurality of words based on the relationship between the relationship vectors.
[0006] In some embodiments of the present application, based on the foregoing scheme, the acquisition module is configured to: perform word segmentation on the to-be-added text in text order to obtain a first word segmentation result; perform word segmentation on the to-be-added text in text reverse order to obtain a second word segmentation result; acquire differences between the first word segmentation result and the second word segmentation result, perform word segmentation on the to-be-added text corresponding to the differences from the middle to both sides to obtain difference results; and replace the differences between the first word segmentation result and the second word segmentation result with the difference results, and take the replaced first word segmentation result as the plurality of words.
[0007] In some embodiments of the present application, based on the foregoing scheme, the acquisition module is configured to: acquire the parts of speech and positions of the respective words; and determine the relationships between the respective words according to the parts of speech and positions of the respective words.
[0008] In some embodiments of the present application, based on the foregoing scheme, the determination module is configured to: acquire a first vector based on the respective words; acquire a second vector based on the dependent words of the respective words; acquire a third vector based on the relationships between the respective words and their dependent words; and combine the first vector, the second vector and the third vector to obtain a relationship vector corresponding to the respective words.
[0009] In some embodiments of the present application, based on the foregoing scheme, the determination module is configured to: encode the respective words to obtain a first sequence; encode the dependent words of the respective words to obtain a second sequence; encode the relationships between the respective words and their dependent words to obtain a third sequence; truncate or zero-pad the first sequence, the second sequence and the third sequence, map the truncated or zero-padded first sequence to the first vector, map the truncated or zero-padded second sequence to the second vector, and map the truncated or zero-padded third sequence to the third vector.
[0010] In some embodiments of the present application, based on the foregoing scheme, the addition module is configured to: input the relationship vectors of the plurality of words into a pre-trained attention model to obtain relationships between the relationship vectors of the plurality of words.
[0011] In some embodiments of the present application, based on the foregoing scheme, the addition module is configured to: add punctuation between the plurality of words to obtain a plurality of addition manners; perform feature extraction on the relationships between the relationship vectors through a bidirectional LSTM layer; calculate probabilities of various addition manners based on the features using a Viterbi algorithm, and add punctuation between the plurality of words based on an addition manner with the highest probability among the plurality of manners.
[0012] According to an aspect of an embodiment of the present application, a computer readable program medium storing computer program instructions is provided, which, when executed by a computer, causes the computer to perform the method according to any one of the preceding aspects.
[0013] According to an aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; a memory, the memory storing computer readable instructions, which, when executed by the processor, implement the method according to any one of the preceding aspects.
[0014] The technical solution provided by the embodiments of the present application can include the following beneficial effects:
[0015] In the technical solution provided by some embodiments of the present application, by obtaining the text to be added, the text to be added is segmented to obtain a plurality of words, the relationship between each word in the plurality of words is obtained, the dependent word of each word and the relationship between each word and its dependent word are obtained, the relationship vector of each word is determined based on each word, the dependent word of each word and the relationship between each word and its dependent word, the relationship between the relationship vectors of the plurality of words is obtained, and punctuation is added between the plurality of words based on the relationship between the relationship vectors. The relationship between the words in the text to be added is considered, and the relationship between the words and the text in the text to be added is considered, which can improve the accuracy of punctuation addition to a certain extent.
[0016] It should be understood that the foregoing general description and the following detailed description are only exemplary and do not limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 An exemplary system architecture schematic diagram to which the technical solution of the embodiments of the present application can be applied is shown;
[0019] Figure 2 A flowchart of a text punctuation adding method of an embodiment of the present application is schematically shown;
[0020] Figure 3 A structural schematic diagram of a system for text punctuation adding of an embodiment of the present application is schematically shown;
[0021] Figure 4 A block diagram of a text punctuation adding device according to an embodiment of the present application is schematically shown;
[0022] Figure 5 is a hardware diagram of an electronic device according to an exemplary embodiment;
[0023] Figure 6 It is a computer-readable storage medium for implementing a method, as illustrated in an exemplary embodiment. Detailed Implementation
[0024] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0025] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0026] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0027] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0028] Figure 1 A schematic diagram of an exemplary system architecture 100 to which the technical solutions of the embodiments of this application can be applied is shown.
[0029] like Figure 1 As shown, system architecture 100 may include terminal device 101 (which may be one or more of a smartphone, tablet, and portable computer, or of course, a desktop computer, etc.), network 102, and server 103. Network 102 is used as a medium to provide a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired communication links, wireless communication links, etc.
[0030] It should be understood that Figure 1The number of terminal devices 101, networks 102 and servers 103 in FIG. 1 is merely illustrative. According to the implementation needs, there can be any number of terminal devices 101, networks 102 and servers 103. For example, the server 103 can be a server cluster composed of multiple servers, etc.
[0031] In an embodiment of the present application, the server 103 obtains the text to be added, performs word segmentation on the text to be added to obtain a plurality of words, obtains the relationship between each word in the plurality of words, obtains the dependent word of each word and the relationship between each word and its dependent word, determines the relationship vector of each word based on each word, the dependent word of each word and the relationship between each word and its dependent word, obtains the relationship between the relationship vectors of the plurality of words, and adds punctuation between the plurality of words based on the relationship between the relationship vectors. The relationship between words in the text to be added is considered, and the relationship between words and the text in the text to be added is considered, which can improve the accuracy of punctuation addition to a certain extent.
[0032] It should be noted that the text punctuation adding method provided in the embodiments of the present application is generally executed by the server 103, and accordingly, the text punctuation adding apparatus is generally provided in the server 103. However, in other embodiments of the present application, the terminal device 101 can also have similar functions as the server 103, so as to execute the text punctuation adding method provided in the embodiments of the present application.
[0033] The implementation details of the technical solutions of the embodiments of the present application are described in detail as follows:
[0034] Figure 2 The flowchart of the text punctuation adding method of one embodiment of the root application is schematically shown, and the execution subject of the text punctuation adding method can be a server, such as the server 103 shown in FIG. 1. Figure 1
[0035] Referring to FIG. 2, the text punctuation adding method at least includes steps S210 to S250, which are described in detail as follows: Figure 2 In step S210, the text to be added is obtained, and word segmentation is performed on the text to be added to obtain a plurality of words.
[0036]
[0037] In an embodiment of the present application, the text to be added can be segmented according to the text order to obtain a first segmentation result; the text to be added can be segmented according to the reverse text order to obtain a second segmentation result; a difference between the first segmentation result and the second segmentation result can be obtained, and the text to be added corresponding to the difference can be segmented from the middle to both sides to obtain a difference result; the difference between the first segmentation result and the second segmentation result can be replaced by the difference result, and the first segmentation result after the replacement can be used as the plurality of words.
[0038] In an embodiment of the present application, meaningless characters in the text to be added can be filtered and segmented.
[0039] In an embodiment of the present application, each character in the text to be added can be identified, and a word in a preset word table can be segmented by combining each character and a character similar to the character and comparing the combination with the preset word table.
[0040] In an embodiment of the present application, the meaning of each character can be obtained, and if the meanings of adjacent characters can be combined, the character and the adjacent character can be used as a word.
[0041] In an embodiment of the present application, the text to be added can be input into a pre-trained segmentation model to obtain a plurality of words output by the segmentation model.
[0042] In step S220, the relationship between each word in the plurality of words can be obtained to obtain a dependent word of each word and the relationship between each word and the dependent word.
[0043] In an embodiment of the present application, the part of speech and the position of each word can be obtained; and the relationship between each word can be determined according to the part of speech and the position of each word.
[0044] In an embodiment of the present application, the meaning of each word can be obtained, and the relationship between the plurality of words can be determined according to the meaning.
[0045] In an embodiment of the present application, for each word in the plurality of words, a word relationship table can be searched according to the word and any word in the plurality of words to obtain a dependent word associated with the word and the relationship between the word and the dependent word.
[0046] In an embodiment of the present application, the plurality of words can be input into a pre-trained relationship obtaining model to obtain the relationship between the plurality of words output by the relationship obtaining model.
[0047] In an embodiment of the present application, the relationship obtaining model can be a syntactic dependency tree model.
[0048] In an embodiment of the present application, the dependency relationship can include a master-slave relationship, a subject-object relationship, a passive relationship, a subordinate relationship, a fixed collocation, a appositive, an adjective, etc.
[0049] In an embodiment of the present application, a label can be set for each type of dependency relationship to facilitate the generation of a vector based on the label hereinafter.
[0050] In step S230, a relationship vector of each word is determined based on each word, the dependency word of each word, and the relationship between each word and its dependency word.
[0051] In an embodiment of the present application, a first vector based on each word can be obtained; a second vector based on the dependency word of each word can be obtained; a third vector based on the relationship between each word and its dependency word can be obtained; and the first vector, the second vector, and the third vector can be combined to obtain the relationship vector corresponding to each word.
[0052] In an embodiment of the present application, each word can be encoded to obtain a first sequence; the dependency word of each word can be encoded to obtain a second sequence; the relationship between each word and its dependency word can be encoded to obtain a third sequence; the first sequence, the second sequence, and the third sequence can be truncated or zero-padded; the first sequence after truncation or zero-padding can be mapped to a first vector; the second sequence after truncation or zero-padding can be mapped to a second vector; and the third sequence after truncation or zero-padding can be mapped to a third vector.
[0053] In an embodiment of the present application, the first sequence, the second sequence, and the third sequence can be truncated from front to back.
[0054] In step S240, the relationship between the relationship vectors of the plurality of words is obtained.
[0055] In an embodiment of the present application, the relationship vectors of the plurality of words can be input into a pre-trained attention model to obtain the relationship between the relationship vectors of the plurality of words, and the pre-trained attention model can fully consider the relationship between each relationship vector.
[0056] In step S250, punctuation is added between the plurality of words based on the relationship between the relationship vectors.
[0057] In an embodiment of the present application, the punctuation can be added between the plurality of words by a conditional random field.
[0058] In an embodiment of the present application, punctuation can be added between multiple words in multiple ways, the relationship between the relationship vectors is extracted by a bidirectional LSTM layer, and the probability of each adding method is calculated based on the features, and the punctuation is added between the multiple words based on the adding method with the highest probability among the multiple methods.
[0059] In this embodiment, the bidirectional LSTM layer can perform deep feature extraction on the text to obtain a feature output vector N*K of the text, where K is the number of neurons in the LSTM layer.
[0060] For example, assuming that there are three types of punctuation in a certain scenario, no punctuation, comma, and period. For the predicted text
Xiaozhang's doctor is Xiaoli
no punctuation, no punctuation, no punctuation, no punctuation, period
Xiaozhang's doctor is Xiaoli.
[0061] In Figure 2 In an embodiment of the present application, the text to be added is obtained, the text to be added is segmented to obtain multiple words, the relationship between each word in the multiple words is obtained, the dependent word of each word and the relationship between each word and its dependent word are obtained, the relationship vector of each word is determined based on each word, the dependent word of each word and the relationship between each word and its dependent word, the relationship between the relationship vectors of the multiple words is obtained, and punctuation is added between the multiple words based on the relationship between the relationship vectors. The relationship between the words in the text to be added is considered, and the relationship between the words and the text in the text to be added is considered, which can improve the accuracy of punctuation addition to a certain extent.
[0062] The method for adding punctuation to text of the present application adds punctuation marks to Chinese text lacking sentence boundary information, supplements necessary sentence structure information, improves the readability of the text, and further improves the effect of downstream natural language processing tasks.
[0063] In an embodiment of the present application, the present application provides a system for adding punctuation to text, which applies the method for adding punctuation to text of the present application to process text to be added with punctuation, Figure 3 The structure diagram of the system for adding punctuation to text of an embodiment of the present application is schematically shown in FIG. 1. Figure 3As shown, the system for adding punctuation to text can include an input module (Input), a dependency tree module (Dependency tree), a concatenation module (concat), an attention module (Attention), a feature extraction module (BiLSTM), a conditional random field module (CRF), and an output module (Output).
[0064] The process of applying the method for adding punctuation to text of the present application to process medical information text can include: an input module, the length of the medical information text can be l1, the medical information text is segmented by the syntax dependency tree module, and a sequence of words with a length of l2 is obtained after segmentation. The length of the sequence of words is shorter than the length of the text in words. Then the syntax relationship of the whole sentence is extracted, the dependent words of each word and the relationship between each word and its dependent word are extracted, and by integrating the obtained syntax relationship, the relevant dependent words of each word and the corresponding semantic relationship are obtained.
[0065] For example:
Xiaozhang's doctor is Xiaoli
B E S BE S B E
Xiaozhang's doctor is Xiaoli
doctor doctor is is is
is
root
[0066] In an embodiment of the present application, the process of applying the method for adding punctuation to text of the present application to process medical information text can further include: obtaining a semantic vector according to the semantic relationship (refer to the steps of obtaining the first vector, the second vector, and the third vector above), length standardizing the semantic vector, setting the standard length to N, truncating the length exceeding N, retaining only the first N characters, and zero-padding the length less than N, to obtain three sequences with a length of N. The first vector (Word Emb) obtained according to each word, the second vector (Parent Emb) obtained according to the dependent word of each word, and the third vector (Relation Emb) obtained according to the relationship between each word and its dependent word.
[0067] In one embodiment of the present application, the first vector, the second vector and the third vector can be merged together by a merging module, each word embedding vector is M-dimensional, so an N*3M vector can be obtained.
[0068] In one embodiment of the present application, the process of applying the text punctuation adding method of the present application to process the medical information text can further include: taking the vector extracted by the neural network as input by the conditional random field, calculating the probability between each prediction path by using the Viterbi algorithm, and selecting the maximum probability value as the result of the punctuation prediction pair. Assuming that there are three types of punctuation types in a certain scenario, no punctuation, comma, and period. For the predicted text
Xiaozhang's doctor is Xiaoli
no punctuation, no punctuation, no punctuation, no punctuation, period
Xiaozhang's doctor is Xiaoli.
[0069] The text punctuation adding method of the present application processes medical information text based on the syntax dependency tree and the attention mechanism. The method utilizes the feature extraction capability of the LSTM pair in the neural network, the modeling capability of the output sequence of the conditional random field, and the syntax dependency tree and the attention mechanism. The method can fully consider the relationship between words, as much as possible to mine the semantic relationship information, take the whole sentence as a whole, consider the rationality of the whole prediction, and has obvious effect in actual use compared with the existing model. The present application can automatically add punctuation marks to the text, supplement necessary sentence structure information, and greatly improve the effect of subsequent natural language processing tasks.
[0070] The device embodiment of the present application is introduced below, which can be used to execute the robot control method in the above-mentioned embodiments of the present application. For details not disclosed in the device embodiment of the present application, please refer to the above-mentioned embodiments of the robot control method of the present application.
[0071] Figure 4 A block diagram of a text punctuation adding device according to one embodiment of the present application is schematically shown.
[0072] Referring to Figure 4 As shown in the figure, the text punctuation adding device 400 according to one embodiment of the present application includes an acquisition module 401, a determination module 402 and an adding module 403.
[0073] In some embodiments of the present application, based on the foregoing scheme, the obtaining module 401 is configured to obtain the text to be added, perform word segmentation on the text to be added to obtain a plurality of words, obtain the relationship between each word in the plurality of words, obtain the dependent word of each word and the relationship between each word and its dependent word, and the determining module 402 is configured to determine the relationship vector of each word based on each word, the dependent word of each word and the relationship between each word and its dependent word.
[0074] In some embodiments of the present application, based on the foregoing scheme, the obtaining module 401 is configured to perform word segmentation on the text to be added according to the text order to obtain a first word segmentation result, perform word segmentation on the text to be added according to the reverse text order to obtain a second word segmentation result, obtain the difference between the first word segmentation result and the second word segmentation result, and perform word segmentation on the difference corresponding text to be added from the middle to both sides to obtain a difference result.
[0075] In some embodiments of the present application, based on the foregoing scheme, the obtaining module 401 is configured to obtain the part-of-speech and position of each word, and determine the relationship between each word according to the part-of-speech and position of each word.
[0076] In some embodiments of the present application, based on the foregoing scheme, the determining module 402 is configured to obtain a first vector based on each word, obtain a second vector based on the dependent word of each word, obtain a third vector based on the relationship between each word and its dependent word, and combine the first vector, the second vector and the third vector to obtain the relationship vector corresponding to each word.
[0077] In some embodiments of the present application, based on the foregoing scheme, the determining module 402 is configured to encode each word to obtain a first sequence, encode the dependent word of each word to obtain a second sequence, encode the relationship between each word and its dependent word to obtain a third sequence, truncate or zero-pad the first sequence, the second sequence and the third sequence, map the truncated or zero-padded first sequence to a first vector, map the truncated or zero-padded second sequence to a second vector, and map the truncated or zero-padded third sequence to a third vector.
[0078] In some embodiments of the present application, based on the foregoing scheme, the adding module 403 is configured to input the relationship vectors of the plurality of words into a pre-trained attention model to obtain the relationship between the relationship vectors of the plurality of words.
[0079] In some embodiments of the present application, based on the foregoing scheme, the adding module 403 is configured to: add punctuation between the plurality of words to obtain a plurality of adding manners; perform feature extraction on the relationship between the relationship vectors through a bidirectional LSTM layer; based on the features, calculate the probabilities of various adding manners using a Viterbi algorithm, and add punctuation between the plurality of words based on the adding manner with the highest probability in the plurality of manners.
[0080] Those skilled in the art can understand that various aspects of the present application can be implemented as a system, a method or a program product. Therefore, various aspects of the present application can be embodied as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software aspects, which can be collectively referred to as "circuitry", "module" or "system" here.
[0081] The electronic device 50 according to this embodiment of the present application will be described below with reference to Figure 5 Figure 5 The display electronic device 50 is only an example and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0082] As shown in Figure 5 , the electronic device 50 is in the form of a general computing device. The components of the electronic device 50 can include, but are not limited to, the at least one processing unit 51 described above, the at least one storage unit 52 described above, a bus 53 connecting different system components (including the storage unit 52 and the processing unit 51), and a display unit 54.
[0083] The storage unit stores program code that can be executed by the processing unit 51, so that the processing unit 51 performs the steps according to various exemplary embodiments of the present application described in the "Embodiment Method" section of the present specification.
[0084] The storage unit 52 can include a readable medium in the form of a volatile storage unit, such as a random access memory (RAM) 521 and / or a cache memory unit 522, and can further include a read-only memory (ROM) 523.
[0085] The storage unit 52 can also include program / utilities 524 having a set of (at least one) program modules 525, such as an operating system, one or more application programs, other program modules, and program data, each of which or some combination of which can include the implementation of a network environment.
[0086] Bus 53 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0087] Electronic device 50 can also communicate with one or more external devices (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 50, and / or with any device that enables electronic device 50 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 55. Furthermore, electronic device 50 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 56. As shown, network adapter 56 communicates with other modules of electronic device 50 via bus 53. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with electronic device 50, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0088] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the method according to the embodiments of this application.
[0089] According to one embodiment of this application, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above in this specification is stored. In some possible implementations, various aspects of this application may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of this application described in the "Exemplary Methods" section of this specification.
[0090] refer to Figure 6As shown, a program product 60 for implementing the above-described method according to an embodiment of the present application is described, which can take the form of a portable compact disc read-only memory (CD-ROM) and include a program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present application is not limited thereto, and in the present document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0091] The program product can take any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium, for example, can be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0092] The computer readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave, in which the readable program code is carried. Such propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable signal medium can also be any readable medium that is not a readable storage medium and that can transmit, propagate, or transport the program for use by or in connection with an instruction execution system, apparatus, or device.
[0093] The program code contained on the readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, and the like, or any suitable combination of the above.
[0094] The program code may, for example, be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, for example, through the Internet using an Internet Service Provider.
[0095] Further, the above-described diagrams are merely schematic illustrations of the processes included in the method according to the exemplary embodiments of the present application, and are not intended for limiting purposes. It is readily understood that the processes shown in the above-described diagrams do not indicate or limit the time sequence of the processes. In addition, it is readily understood that the processes can be executed, for example, synchronously or asynchronously in a plurality of modules.
[0096] It is to be understood that the application is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application is limited only by the appended claims.
Claims
1. A method of text punctuation, characterized by, The method comprises the following steps: obtaining a text to be added, performing word segmentation on the text to be added in a text sequence to obtain a first word segmentation result; performing word segmentation on the text to be added in a reverse text sequence to obtain a second word segmentation result; obtaining the difference between the first word segmentation result and the second word segmentation result, performing word segmentation on the difference corresponding to the text to be added from the middle to both sides to obtain a difference result; replacing the difference between the first word segmentation result and the second word segmentation result with the difference result, and taking the replaced first word segmentation result as a plurality of words obtained by performing word segmentation on the text to be added; obtaining the relationship between each word in the plurality of words to obtain the dependent word of each word and the relationship between each word and its dependent word; determining the relationship vector of each word based on the plurality of words, the dependent word of each word and the relationship between each word and its dependent word; obtaining the relationship between the relationship vectors of the plurality of words; adding punctuation between the plurality of words based on the relationship between the relationship vectors.
2. The method of punctuating text of claim 1, wherein, The method comprises the following steps: obtaining the part-of-speech and position of each word; determining the relationship between each word according to the part-of-speech and position of each word.
3. The method of punctuating text of claim 1, wherein, The method comprises the following steps: obtaining a first vector based on each word; obtaining a second vector based on the dependent word of each word; obtaining a third vector based on the relationship between each word and its dependent word; combining the first vector, the second vector and the third vector to obtain the relationship vector corresponding to each word.
4. The method of punctuating text of claim 3, wherein, The method comprises the following steps: encoding each word to obtain a first sequence; encoding the dependent word of each word to obtain a second sequence; encoding the relationship between each word and its dependent word to obtain a third sequence; truncating or zero-padding the first sequence, the second sequence and the third sequence, mapping the truncated or zero-padded first sequence to the first vector, mapping the truncated or zero-padded second sequence to the second vector, and mapping the truncated or zero-padded third sequence to the third vector.
5. The method of punctuating text of claim 1, wherein, The method comprises the following steps: inputting the relationship vectors of the plurality of words into a pre-trained attention model to obtain the relationship between the relationship vectors of the plurality of words.
6. The method of punctuating text of claim 1, wherein, The method comprises the following steps: adding punctuation between the plurality of words to obtain a plurality of adding modes; performing feature extraction on the relationship between the relationship vectors through a bidirectional LSTM layer; Based on the features, probabilities of various adding manners are calculated by using a Viterbi algorithm, and a punctuation is added between the plurality of words based on an adding manner with the maximum probability among the plurality of adding manners.
7. An apparatus for text punctuation, characterized by The method comprises the steps of: acquiring a text to be added, and performing word segmentation on the text to be added to obtain a plurality of words; acquiring a relationship between each word in the plurality of words, and obtaining a dependent word of each word and a relationship between each word and the dependent word thereof; determining a relationship vector of each word based on the each word, the dependent word of the each word, and the relationship between the each word and the dependent word thereof; adding a punctuation between the plurality of words based on a relationship between the relationship vectors of the plurality of words; the acquiring module is further configured to: perform word segmentation on the text to be added according to a text sequence to obtain a first word segmentation result; perform word segmentation on the text to be added according to a reverse text sequence to obtain a second word segmentation result; acquire a difference between the first word segmentation result and the second word segmentation result; perform word segmentation on the text to be added from the middle to both sides according to the difference; obtain a difference result; and replace the difference between the first word segmentation result and the second word segmentation result with the difference result, and take the first word segmentation result after replacement as the plurality of words.
8. A computer readable program medium having stored thereon computer program instructions, characterized in that, The computer program instructions, when executed by a computer, cause the computer to perform the method of any one of 1-6. The method comprises the steps of:
9. An electronic device, comprising: a processor; and a memory having computer readable instructions stored thereon; wherein the computer readable instructions, when executed by the processor, implement the method of any one of 1-6.
Citation Information
Patent Citations
Method and apparatus for text semantic expression
CN109062902A
Punctuation mark adding method and model training method in text and device, and electronic equipment
CN111027291A