WO2020181808A1 - 一种文本标点预测方法、装置、计算机设备及存储介质 - Google Patents
一种文本标点预测方法、装置、计算机设备及存储介质 Download PDFInfo
- Publication number
- WO2020181808A1 WO2020181808A1 PCT/CN2019/117303 CN2019117303W WO2020181808A1 WO 2020181808 A1 WO2020181808 A1 WO 2020181808A1 CN 2019117303 W CN2019117303 W CN 2019117303W WO 2020181808 A1 WO2020181808 A1 WO 2020181808A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- punctuation
- word
- target
- text
- sample
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
Definitions
- This application relates to the field of deep learning technology, and in particular to a text punctuation prediction method, device, computer equipment and storage medium.
- the embodiments of the present application provide a text punctuation prediction method, device, computer equipment, and storage medium to solve the problem of no punctuation in the verbal text obtained by speech recognition.
- a method for predicting text punctuation including:
- the target vectors are sequentially input to the network model, and the result sequence output by the network model in turn is obtained.
- Each value in the result sequence represents The punctuation corresponding to each target word, and the network model is composed of a pre-trained LSTM network and a conditional random field;
- Each punctuation corresponding to each value is determined according to the preset value punctuation correspondence relationship, and the value punctuation correspondence records the one-to-one correspondence between the value and the punctuation;
- the back position Refers to the position in the target text that is located behind the target word and close to the target word.
- a text punctuation prediction device including:
- Text acquisition module for acquiring target text without punctuation
- the word segmentation processing module is used to perform word segmentation processing on the target text to obtain each target word in the target text;
- the word vectorization module is used to perform vectorization processing on each target word to obtain each target vector corresponding to each target word;
- the vector input module is configured to sequentially input the target vectors into the network model according to the order of the target words in the target text to obtain the sequence of results output by the network model in turn, in the sequence of results
- the punctuation determination module is configured to determine each punctuation corresponding to each value according to the preset value punctuation correspondence relationship, and the value punctuation correspondence records the one-to-one correspondence between the value and the punctuation;
- the punctuation insertion module is used to insert each punctuation in the target text at the back position of the target word corresponding to each punctuation for each of the punctuations to obtain the punctuation prediction
- the rear position refers to a position in the target text that is located behind the target word and immediately adjacent to the target word.
- a computer device including a memory, a processor, and computer readable instructions stored in the memory and capable of running on the processor, and the processor implements the above text punctuation prediction method when the computer readable instructions are executed A step of.
- One or more readable storage media storing computer readable instructions, and the computer readable storage medium storing computer readable instructions so that the one or more processors execute the steps of the text punctuation prediction method described above.
- FIG. 1 is a schematic diagram of an application environment of a text punctuation prediction method in an embodiment of the present application
- FIG. 2 is a flowchart of a method for predicting text punctuation in an embodiment of the present application
- FIG. 4 is a schematic diagram of the process of training a network model in an application scenario of the text punctuation prediction method in an embodiment of the present application;
- step 106 of the text punctuation prediction method in an application scenario in an embodiment of the present application is a schematic flowchart of step 106 of the text punctuation prediction method in an application scenario in an embodiment of the present application
- FIG. 6 is a schematic structural diagram of a text punctuation prediction device in an application scenario in an embodiment of the present application
- FIG. 7 is a schematic structural diagram of a text punctuation prediction device in another application scenario in an embodiment of the present application.
- FIG. 8 is a schematic structural diagram of a punctuation insertion module in an embodiment of the present application.
- Fig. 9 is a schematic diagram of a computer device in an embodiment of the present application.
- the text punctuation prediction method provided by this application can be applied in the application environment as shown in Fig. 1, in which the client communicates with the server through the network.
- the client can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
- the server can be implemented as an independent server or a server cluster composed of multiple servers.
- a method for predicting text punctuation is provided.
- the method is applied to the server in FIG. 1 as an example for description, and includes the following steps:
- the server may obtain the target text without punctuation according to actual use needs or application scenarios.
- the server can communicate with the client, the client provides users in a certain place to ask questions, the user inputs the voice question through the microphone of the client, the client uploads the voice question to the server, and the server converts the voice question into words After getting the text, generally the text is the target text without punctuation.
- the server can also perform the task of punctuation recognition for a large number of verbal texts.
- a database collects a large amount of verbal texts in advance, and then transmits multiple verbal texts to the server through the network.
- the server needs to punctuate these verbal texts separately Prediction, so that these verbal texts are respectively the target texts predicted by each to-be-punctuation point without punctuation. It is understandable that the server can also obtain the target text predicted by these punctuation points in a variety of ways, which will not be repeated here.
- the text mentioned in this embodiment generally refers to the text of speech, that is, the text content obtained by converting a person's words into words.
- third-party software such as stuttering word segmentation can be used to implement word segmentation processing to obtain each target word.
- the method further includes: deleting a specified text in the target text, the specified text being at least Include stop words.
- the stop words mentioned here can refer to single Chinese characters that are particularly frequently used, such as " ⁇ ", " ⁇ ” and other Chinese characters with no actual language meaning.
- the server can delete the specified text in the target text. For example, suppose the specified text includes stop words, and the target text includes the text "I came to work today.” The server can first delete the " "” and other meaningless stop words are deleted, resulting in the deleted text "I come to work today.”
- the server After obtaining each target word, in order to facilitate the recognition and learning of the subsequent network model, the server needs to perform vectorization processing on each target word, that is, the word is converted into a vector representation, so as to obtain the target word Each target vector corresponding to the word. Specifically, the server may record each target word in the form of a one-dimensional matrix (one-dimensional vector).
- the step 103 may specifically include:
- step 201 For each target word in the target words, search for whether each target word is recorded in the preset dictionary, if yes, go to step 202, if not, go to step 203, so
- the dictionary records the correspondence between words and one-dimensional vectors;
- the server when the server converts each target word into a vector, it can convert these target words one by one, or it can convert multiple target words at the same time in a multi-threaded manner.
- a target word is vectorized.
- the server can retrieve whether the target word is recorded in a preset dictionary.
- the server may be preset with a dictionary, which records the one-to-one correspondence between words and one-dimensional vectors. For example, you can set "Hello" to correspond to "No. 1 vector", “I” to "No. 2 vector”, “Tomorrow” to "No. 3 vector", “Reply” to "No.
- the dictionary is perfected by exhausting all the words as much as possible, so that when each target word in the target text needs to be transformed, the server can use the preset dictionary to compare the target Each target word in the text is transformed into each one-dimensional vector.
- the server detects that the target word is recorded in the dictionary, it means that the one-dimensional vector corresponding to the target word is also recorded in the dictionary; otherwise, the one-dimensional vector corresponding to the target word is not recorded.
- step 202 it can be understood that if it is detected that each target word is recorded in the preset dictionary, it means that the one-dimensional vector corresponding to each target word is recorded in the dictionary. Therefore, The server may obtain a one-dimensional vector corresponding to each target word from the dictionary.
- step 203 it can be understood that if it is detected that each target word is not recorded in the preset dictionary, it means that the one-dimensional vector corresponding to each target word is not recorded in the dictionary. This is because it is often difficult to exhaust all the words when the server presets the dictionary. Even if it costs a lot of cost to exhaust all the words and record them in the dictionary, due to the daily increase in the amount of social information, new words will be generated almost every day, such as Internet terms, so some words may not be included in the preset dictionary. In the face of this situation, in this embodiment, the vector conversion of the target word can be realized while in use, and the newly added word can be added to the dictionary to complete the dictionary.
- the server first converts each target word into a first vector by loading the word vector of the first third-party platform. It can be seen that since the third-party platform is often updated in a timely manner, the word vector loaded on it generally covers all currently possible words, so the target word can be converted into the first vector.
- this embodiment in order to increase the accuracy of the vector conversion and reduce the error rate, this embodiment also converts each target word into a second vector by loading the word vector of the second third-party platform. It can be seen that the second third-party platform and the first third-party platform are two different platforms, and the word vectors loaded on each are different.
- the server can obtain a one-dimensional vector as the one-dimensional vector corresponding to each target word by using the first vector and the second vector.
- the first vector and the second vector corresponding to the same word can be spliced one after the other, that is, the tail of the first vector is immediately connected to the head of the second vector, thereby obtaining a new one-dimensional vector.
- This embodiment integrates the conversion rules of the two platforms together, which can reduce the error of vector conversion as a whole. It also ensures that each one-dimensional vector has sufficient length, which improves the accuracy of subsequent use.
- the one-dimensional vector obtained by splicing is a new one-dimensional vector relative to the preset dictionary. Therefore, in order to facilitate the improvement of the dictionary, it is convenient to improve the words when the dictionary is subsequently used.
- the server may record the spliced one-dimensional vector and the corresponding target word in the dictionary.
- the network model is composed of a pre-trained LSTM network and a conditional random field;
- the server may sequentially input each target vector into the pre-trained network model according to the order of each target word in the target text to obtain the A sequence of results sequentially output by the network model, wherein each value in the sequence of results respectively represents the punctuation corresponding to each target word. For example, assuming that the target text corresponds to a total of 5 target vectors, which are vectors 1-5, then when step 104 is performed, the first vector is input to the network model, and then the second vector is input to the network model , Followed by vector 3, vector 4, and vector 5.
- the network model will output the value corresponding to the number 1 vector, and then it will output the value corresponding to the number 2
- the value corresponding to the number vector, and the value corresponding to the number 3 vector, the value corresponding to the number 4 vector, and the value corresponding to the number 5 vector are output. Therefore, the five numerical values sequentially output by the network model constitute the result sequence.
- the server presets the corresponding relationship between each value and punctuation, which can be set according to actual conditions.
- the corresponding relationship between values and punctuation can be set as shown in Table 1:
- the network model consists of two parts, the first half is the LSTM network, and the second half is the conditional random field.
- the LSTM network is good at solving the problem of long order dependence, and is suitable for processing and predicting important events with relatively long intervals and delays in the time series, and can understand unpunctuated text well.
- Conditional random field (CRF, conditional random field algorithm), which can make up for this defect of the LSTM network, makes the combination of the two complement each other and improves the accuracy of punctuation prediction for unpunctuated text.
- the training process of the network model will be described in detail below.
- the network model can be pre-trained through the following steps:
- the numerical value punctuation correspondence relationship records the one-to-one correspondence relationship between numerical value and punctuation
- each sample vector For each sample text in each of the sample texts, according to the order of each sample word in each sample text, input each sample vector into the LSTM network in the network model in turn, and obtain the LSTM network output in turn Each intermediate vector of;
- the staff can collect a large number of verbal texts in different application scenarios, for example, can collect verbal texts when users ask questions, collect verbal texts when users complain, and collect verbal texts when users chat. Text, etc.
- the server can collect a large number of original verbal texts through professional knowledge bases, network databases and other channels. It should be noted that these texts need to be punctuated. If the collected original texts do not have punctuation, you can add punctuation to them manually.
- the input is the text without punctuation
- the server can separate the punctuation and the text in each collected text to obtain each sample text and corresponding to each sample text
- the collection of punctuation For example, if one of the collected phrasal texts is "What products do you have?", after separating the phrasal texts, you can get the sample text "What products do you have?” and the punctuation set "?” (there are four spaces before the question mark).
- the server can also convert these punctuation sets into a sequence composed of numerical values, that is, a standard sequence .
- each punctuation mark in each punctuation set is converted into a first value according to the above-mentioned numerical punctuation correspondence relationship, and then these first values are arranged to obtain a standard sequence.
- the standard sequence is "00003".
- the server can separately perform word segmentation processing on the sample text to obtain each sample word in each sample text.
- the sample text is "What product do you have?"
- word segmentation 4 sample words of "you", “you”, “what", and "product” can be obtained.
- third-party software such as stuttering word segmentation can be used to implement word segmentation processing to obtain each sample word.
- the method further includes: deleting designated text in the sample text, the designated text being at least Include stop words.
- the stop words mentioned here can refer to single Chinese characters that are particularly frequently used, such as " ⁇ ", " ⁇ ” and other Chinese characters with no actual language meaning.
- the server can delete the specified text in the sample text. For example, suppose the specified text includes stop words, and the sample text includes the text "I came to work today". The server can first delete the " "” and other meaningless stop words are deleted, resulting in the deleted text "I come to work today.”
- the server needs to perform vectorization processing on each sample word, that is, convert the word into The vector representation is used to obtain each target vector corresponding to each sample word.
- the server may record each sample word in the form of a one-dimensional matrix (one-dimensional vector).
- each sample text in each of the sample texts is separately trained.
- the server may sequentially input each sample vector into the LSTM network in the network model for training according to the order of each sample word in each sample text, and obtain each intermediate vector sequentially output by the LSTM network. For example, suppose there are 4 sample vectors of a sample text, which are vectors 1-4 respectively.
- the first vector is input to the LSTM network, and then the second vector is input to the LSTM network , Followed by the No. 3 vector and the No. 4 vector; at the same time, it can be seen that not long after the No.
- the LSTM network will output the intermediate vector corresponding to the No. 1 vector, and then output corresponding to the No. 2 vector And output the intermediate vector corresponding to the number 3 vector and the intermediate vector corresponding to the number 4 vector. It is understandable that based on the short-term memory characteristics of the text content of the LSTM network, the intermediate vector output by the LSTM network contains more text information than the input sample vector, which is the basis for the application of punctuation prediction for unpunctuated text .
- LSTM has three gates, namely forget gate, input gate and output gate.
- the forget gate first represents the information discarded from the previous cell state, and the value ranges from 0 to 1. The smaller the value, the more information to be discarded.
- the next input gate represents how much new information is added to the cell state.
- the final output gate will get the corresponding output according to the current cell state and new information, and update the cell state.
- the specific network structure of LSTM you can refer to existing materials, which will not be repeated here.
- the server may input each intermediate vector into the conditional random field in the network model to obtain the sample sequence output by the conditional random field, where, Each numerical value in the sample sequence represents the punctuation corresponding to each sample word.
- CRF or Conditional Random Fields (Conditional Random Fields)
- CRF is a conditional probability distribution model of another set of output random variables given a set of input random variables. It is a discriminant probability undirected graph Since the model is a discriminant, it is to model the conditional probability distribution. Therefore, in this embodiment, CRF can select a sequence with the highest probability from various possible output sequences as the sample sequence according to each intermediate vector given by the LSTM network. It can be seen that a CRF is usually composed of multiple feature functions, and each feature function is provided with different weight coefficients. When training the CRF, the training of the CRF is completed by determining these weight systems.
- the process of training the network model in this embodiment is the process of training the LSTM network and the conditional random field, and the parameters of the LSTM network and the weight coefficient of the conditional random field need to be adjusted.
- the server can detect that there is an error between the two. For this reason, the server can adjust the parameters of the LSTM network and the weight coefficient of the conditional random field as much as possible Make the output result of the network model close to [00003].
- step 308 When performing step 308 to adjust the parameters of the LSTM network and the weight coefficients of the conditional random field, the adjustment can also be made through the existing back propagation algorithm, which will not be further described.
- the server can determine whether the error between the sample sequence and the standard sequence corresponding to each sample text meets the preset training termination condition, and if it meets, it indicates the various parameters and weights in the network model. The coefficients have been adjusted in place, it can be determined that the network model has been trained; otherwise, if it is not satisfied, it means that the network model needs to continue training.
- the training termination condition can be preset according to actual usage conditions. Specifically, the training termination condition can be set as follows: if the error between the sample sequence and the standard sequence corresponding to each sample text is less than Specify the error value, it is considered to meet the preset training termination condition.
- the verbal text in the verification set can also be set to: use the verbal text in the verification set to perform the above steps 306-308. If the error between the sample sequence output by the network model and the standard sequence is within a certain range, it is considered to meet the preset training Termination condition.
- the collection of verbal texts in the verification set is similar to the above step 301. Specifically, after the above step 301 is performed to collect a large number of verbal texts, a certain proportion of the collected verbal texts is divided into the training set, and the remaining verbal texts The text is divided into validation sets.
- 80% of the collected texts can be randomly divided as the training set samples for the subsequent training of the network model, and the other 20% can be divided into the subsequent verification of whether the training of the network model is completed, that is, whether the preset training termination condition is met A sample of the validation set.
- the server can determine the punctuation corresponding to each value according to the preset value punctuation correspondence relationship. For example, suppose that the target vector corresponding to "Hello, I will reply you tomorrow" is input into the network model, and the result sequence is [20001]. According to the corresponding relationship in Table 1, the 5 punctuations corresponding to the result sequence can be obtained. It is ",”, space, space, space, ".”.
- each punctuation in the various punctuations insert each punctuation in the target text at the back position of the target word corresponding to each punctuation to obtain the punctuation prediction text, said The back position refers to a position in the target text that is behind the target word and immediately adjacent to the target word.
- the server inserts these punctuations into the corresponding positions of the target text to obtain the verbal text after the punctuation prediction, and complete the addition of punctuation to the target text.
- the server after getting the 5 punctuations ",.”, add them to the target text "Hello, I will reply to you tomorrow", and get the verbal text "Hello, I will reply to you tomorrow.”
- step 106 may specifically include:
- step 404 If the current punctuation is not the last punctuation of the result sequence, determine the next punctuation of the current punctuation in the result sequence as the new current punctuation, and set the next punctuation of the current word in the target text The word is determined as the new current word, and then return to step 403;
- the result sequence is [20001]
- the first punctuation is ",”
- "" is determined as the current punctuation.
- the target text is "Hello, I will reply to you tomorrow"
- the first target word is "Hello”, so that "Hello” is determined as the current word.
- step 403 insert “,” after “Hello", so that the target text is updated to "Hello, I will reply to you tomorrow". At this point, the next word is "I” after "Hello”.
- step 404 the server judges that ",” is not the last punctuation of the result sequence, so it can determine “" (space) as the new current punctuation, and "I” as the new current word, and return to execute Step 403. It can be seen that when step 403 is executed, "" is inserted after "I", so that the target text is updated to "Hello, I will reply to you tomorrow". Then, the server continues to determine that "" is not the last node of the result sequence, so it can determine "" (the second space) as the new current punctuation, and "tomorrow” as the new current word, so analogy. Until the current punctuation is ".”, the server judges that ".” is the last punctuation of the result sequence, so step 405 is executed.
- step 405 when the current punctuation is ".”, it means that all the punctuation in the result sequence has been added to the target text.
- the target text is updated to "Hello, I will reply to you tomorrow.”, it is visible, The target text has completed punctuation prediction and addition, so that the server can determine that the target text is a punctuation prediction text.
- the target text without punctuation is obtained; then, the word segmentation process is performed on the target text to obtain each target word in the target text; then, each target word is vectored separately In order to obtain the respective target vectors corresponding to the respective target words; further, according to the order of the respective target words in the target text, the respective target vectors are sequentially input into the network model to obtain the The sequence of results output by the network model in turn.
- Each value in the sequence of results represents the punctuation corresponding to each target word.
- the network model consists of a pre-trained LSTM network and a conditional random field; secondly, according to The preset numerical punctuation correspondence relationship respectively determines each punctuation corresponding to each numerical value.
- the numerical punctuation correspondence records the one-to-one correspondence between the numerical value and the punctuation; finally, for each of the various punctuations, the Each punctuation point is inserted into the back position of the target word corresponding to each punctuation point in the target text to obtain the punctuation prediction verbal text, and the back position refers to the target text in the target text after the target word , And close to the position of the target word. It can be seen that this application can accurately predict the punctuation of the target text through the pre-trained LSTM network and the preset conditional random field, complete the punctuation addition to the unpunctuated text, improve the efficiency of the text punctuation prediction, and facilitate subsequent natural language Deal with the direct use of text.
- a text punctuation prediction device is provided, and the text punctuation prediction device corresponds to the text punctuation prediction method in the above-mentioned embodiment one-to-one.
- the text punctuation prediction device includes a text acquisition module 501, a word segmentation processing module 502, a word vectorization module 503, a vector input module 504, a punctuation determination module 505, and a punctuation insertion module 506.
- the detailed description of each functional module is as follows:
- the text obtaining module 501 is used to obtain target text without punctuation
- the word segmentation processing module 502 is configured to perform word segmentation processing on the target text to obtain each target word in the target text;
- the word vectorization module 503 is configured to perform vectorization processing on each target word to obtain each target vector corresponding to each target word;
- the vector input module 504 is configured to sequentially input the target vectors into the network model according to the order of the target words in the target text to obtain the sequence of results output by the network model in turn, the sequence of results
- Each value in represents the punctuation corresponding to each target word
- the network model is composed of a pre-trained LSTM network and a conditional random field
- the punctuation determination module 505 is configured to determine each punctuation corresponding to each value according to the preset value punctuation correspondence relationship, and the value punctuation correspondence records the one-to-one correspondence between the value and the punctuation;
- the punctuation insertion module 506 is used for inserting each punctuation in the target text at the back position of the target word corresponding to each punctuation for each of the punctuations to obtain the words after the punctuation prediction
- the rear position refers to a position in the target text that is located behind the target word and immediately adjacent to the target word.
- the network model can be pre-trained through the following modules:
- the phrasal text collection module 507 is used to collect multiple punctuated phrasal texts
- the punctuation text separation module 508 is used to separate the punctuation and the text in each collected verbal text to obtain each sample text and each punctuation set corresponding to each sample text;
- the first numerical value determination module 509 is configured to determine the first numerical value corresponding to each punctuation mark in each punctuation set according to the preset numerical value punctuation correspondence relationship for each punctuation set, and compose each of the first numerical values
- the standard sequence corresponding to each set of punctuation marks, and the value punctuation correspondence relationship records a one-to-one correspondence between a value and a punctuation mark;
- the sample word segmentation processing module 510 is configured to perform word segmentation processing on the sample text respectively to obtain each sample word in each sample text;
- the sample vectorization module 511 is configured to perform vectorization processing on each sample word in each sample text to obtain each sample vector corresponding to each sample word;
- the sample vector input module 512 is configured to input each sample vector into the LSTM network in the network model in turn for each sample text in each sample text, according to the order of each sample word in each sample text, to obtain Each intermediate vector sequentially output by the LSTM network;
- the random field module 513 is configured to input each of the intermediate vectors into the conditional random field in the network model to obtain the sample sequence output by the conditional random field, and each value in the sample sequence represents the The punctuation corresponding to each sample word;
- the parameter coefficient adjustment module 514 is configured to use the output sample sequence as an adjustment target, adjust the parameters of the LSTM network and the weight coefficient of the conditional random field, so as to minimize the obtained sample sequence and each The error between the standard sequences corresponding to the sample text;
- the training completion determining module 515 is configured to determine that the network model has been trained if the error between the sample sequence and the standard sequence corresponding to each sample text meets a preset training termination condition.
- the punctuation insertion module 506 may include:
- the current punctuation determining unit 5061 is configured to determine the first punctuation in the result sequence as the current punctuation
- the current word determining unit 5062 is configured to determine the first target word in the target text as the current word
- the inserting unit 5063 is configured to insert the current punctuation into the position before the current word and the next word in the target text, where the next word refers to the next word in the target text One word
- the new punctuation determining unit 5064 is configured to, if the current punctuation is not the last punctuation of the result sequence, determine the next punctuation of the current punctuation in the result sequence as the new current punctuation, and set the target text in The next word of the current word is determined to be the new current word, and the step of inserting the current punctuation into the target text before the current word and the next word is executed again;
- the prediction completion determining unit 5065 is configured to, if the current punctuation is the last punctuation of the result sequence, determine that the target text is a punctuation prediction text.
- word vectorization module may include:
- the word search unit is used to search for each target word in each target word to find whether each target word is recorded in a preset dictionary, and the dictionary records the word and one-dimensional vector Correspondence between;
- a vector obtaining unit configured to obtain a one-dimensional vector corresponding to each target word if each target word is recorded in the preset dictionary
- the first word conversion unit is configured to, if each target word is not recorded in the preset dictionary, load the word vector of the first third-party platform to convert each target word into the first vector;
- the second word conversion unit is configured to convert each target word into a second vector by loading a word vector of a second third-party platform;
- a vector splicing unit for splicing the first vector and the second vector to obtain a one-dimensional vector as the one-dimensional vector corresponding to each target word
- the word recording unit is used for recording the spliced one-dimensional vector and the target word corresponding to it in the dictionary.
- the device for predicting text punctuation may further include:
- the designated text deletion module is used to delete the designated text in the target text, and the designated text includes at least stop words.
- Each module in the above-mentioned text punctuation prediction device can be implemented in whole or in part by software, hardware, and a combination thereof.
- the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
- a computer device is provided.
- the computer device may be a server, and its internal structure diagram may be as shown in FIG. 9.
- the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities.
- the memory of the computer device includes a readable storage medium and an internal memory.
- the readable storage medium stores an operating system, computer readable instructions, and a database.
- the internal memory provides an environment for the operation of the operating system and computer readable instructions in the readable storage medium.
- the computer equipment database is used to store the data involved in the text punctuation prediction method.
- the network interface of the computer device is used to communicate with an external terminal through a network connection.
- the computer-readable instructions are executed by the processor to realize a text punctuation prediction method.
- the readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
- a computer device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor.
- the processor executes the computer-readable instructions, the text in the above-mentioned embodiment is implemented.
- the steps of the punctuation prediction method for example, step 101 to step 106 shown in FIG. 2.
- the functions of the modules/units of the text punctuation prediction apparatus in the foregoing embodiment are realized, for example, the functions of the modules 501 to 506 shown in FIG. 6. To avoid repetition, I won’t repeat them here.
- a computer-readable storage medium In one embodiment, a computer-readable storage medium is provided.
- the one or more computer-readable storage media store computer-readable instructions.
- the steps of the text punctuation prediction method in the foregoing method embodiments are implemented, or the one or more readable storage media storing computer-readable instructions are executed by one or more
- one or more processors execute computer-readable instructions to implement the functions of each module/unit in the text punctuation prediction apparatus in the foregoing apparatus embodiment. To avoid repetition, I won’t repeat them here.
- the readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
- the computer-readable instructions can be stored in a computer-readable storage. In the medium, when the computer-readable instructions are executed, they may include the processes of the foregoing method embodiments.
- any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory.
- the memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
- Volatile memory may include random access memory (RAM) or external cache memory.
- RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
- SRAM static RAM
- DRAM dynamic RAM
- SDRAM synchronous DRAM
- DDRSDRAM double data rate SDRAM
- ESDRAM enhanced SDRAM
- SLDRAM synchronous chain Channel
- memory bus Radbus direct RAM
- RDRAM direct memory bus dynamic RAM
- RDRAM memory bus dynamic RAM
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Machine Translation (AREA)
Abstract
本申请公开了一种文本标点预测方法、装置、计算机设备及存储介质,应用于深度学习技术领域,用于解决语音识别得到的话术文本无标点的问题。本申请提供的方法包括:获取无标点的目标文本;对目标文本进行分词处理,得到目标文本中的各个目标字词;对各个目标字词分别进行向量化处理,得到各个目标向量;按照各个目标字词在目标文本中的次序,将各个目标向量依次输入至网络模型,得到输出的结果序列,结果序列中的各个数值分别表征了各个目标字词对应的标点;根据预设的数值标点对应关系分别确定出各个数值对应的各个标点;针对各个标点中的每个标点,将每个标点插入至目标文本中与每个标点对应目标字词的后面位置,得到标点预测后的话术文本。
Description
本申请以2019年03月12日提交的申请号为201910182506.1,名称为“一种文本标点预测方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。
本申请涉及深度学习技术领域,尤其涉及一种文本标点预测方法、装置、计算机设备及存储介质。
随着社会和高科技技术的飞速发展,智能家居控制、自动问答、语音助手等自然语言处理得到越来越多的关注。但是,由于口语对话没有标点符号,不能区分语句边界和规范语言结构,因此标点预测是极其重要的自然语言处理任务。在智能电话客服场景中,对于用户的讲话,通过语音识别得到的是无标点无断句的原始话术文本,没有办法直接使用,故而在进一步利用用户的话术之前,需要先对原始话术文本进行标点预测,以便对无标点的文本添加标点。
因此,寻找一种能够准确地对话术文本进行标点预测的方法成为本领域技术人员亟需解决的问题。
发明内容
本申请实施例提供一种文本标点预测方法、装置、计算机设备及存储介质,以解决语音识别得到的话术文本无标点的问题。
一种文本标点预测方法,包括:
获取无标点的目标文本;
对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;
对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;
按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;
根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;
针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
一种文本标点预测装置,包括:
文本获取模块,用于获取无标点的目标文本;
分词处理模块,用于对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;
字词向量化模块,用于对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;
向量输入模块,用于按照所述各个目标字词在所述目标文本中的次序,将所述各个目 标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;
标点确定模块,用于根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;
标点插入模块,用于针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述文本标点预测方法的步骤。
一个或多个存储有计算机可读指令的可读存储介质,所述计算机可读存储介质存储有计算机可读指令,使得所述一个或多个处理器执行上述文本标点预测方法的步骤。
本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例中文本标点预测方法的一应用环境示意图;
图2是本申请一实施例中文本标点预测方法的一流程图;
图3是本申请一实施例中文本标点预测方法步骤103在一个应用场景下的流程示意图;
图4是本申请一实施例中文本标点预测方法在一个应用场景下训练网络模型的流程示意图;
图5是本申请一实施例中文本标点预测方法步骤106在一个应用场景下的流程示意图;
图6是本申请一实施例中文本标点预测装置在一个应用场景下的结构示意图;
图7是本申请一实施例中文本标点预测装置在另一个应用场景下的结构示意图;
图8是本申请一实施例中标点插入模块的结构示意图;
图9是本申请一实施例中计算机设备的一示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请提供的文本标点预测方法,可应用在如图1的应用环境中,其中,客户端通过网络与服务器进行通信。其中,该客户端可以但不限于各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。
在一实施例中,如图2所示,提供一种文本标点预测方法,以该方法应用在图1中的服务器为例进行说明,包括如下步骤:
101、获取无标点的目标文本;
本实施例中,服务器可以根据实际使用的需要或者应用场景的需要获取无标点的目标文本。例如,服务器可以与客户端通信连接,该客户端提供给某场所内的用户咨询问题,用户通过客户端的麦克风输入语音问题,客户端将该语音问题上传给服务器,服务器将该语音问题音转字后得到文本,一般该文本为无标点的目标文本。或者,服务器也可以执行对大批量的话术文本进行标点识别的任务,某数据库预先收集大量的话术文本,然后通过网络将多个话术文本传输给服务器,服务器需要对这些话术文本分别进行标点预测,从而这些话术文本分别为各个待标点预测的、无标点的目标文本。可以理解的是,服务器还可以通过多种方式获取到这些待标点预测的目标文本,对此不再过多赘述。
需要说明的是,本实施例所说的文本一般是指话术文本,即由人所说的话通过音转字得到的文本内容。
102、对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;
可以理解的是,在进行标点预测时,需要准确把握标点可能出现的位置,而标点的位置又与目标文本中各个字词密切相关,这就需要服务器对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词。举例说明,目标文本为“你好我明天回复你”,经过分词后,可以得到“你好”、“我”、“明天”、“回复”、“你”共5个字词,这5个字词即为所述各个目标字词。
特别地,在对目标文本进行分词处理时,可以采用结巴分词等第三方软件实现分词处理,得到各个目标字词。
为了减少目标文本中的干扰信息,保证后续分词和投入网络模型进行识别的准确性,进一步地,在步骤102之前,本方法还包括:删除所述目标文本中的指定文本,所述指定文本至少包括停用词。可以理解的是,这里所说的停用词可以是指使用频率特别高的单汉字,比如“的”、“了”等无实际语言意义的汉字。执行步骤102之前,服务器可以将目标文本中的指定文本删除,举例说明,假设该指定文本包括停用词,该目标文本中包括文本“我今天来上班了”,服务器可以先将其中的“了”等无实际意义的停用词删除,从而得到删除后的文本“我今天来上班”。
103、对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;
在得到各个目标字词后,为了便于后续网络模型的识别和学习,服务器需要对所述各个目标字词分别进行向量化处理,即将字词转化为向量的方式表示,从而得到所述各个目标字词对应的各个目标向量。具体地,服务器可以将每个目标字词以一维矩阵(一维向量)的形式记载。
为便于理解的,在一个具体应用场景下,如图3所示,进一步地,所述步骤103具体可以包括:
201、针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,若是,则执行步骤202,若否,则执行步骤203,所述字典记录了字词与一维向量之间的对应关系;
202、获取与所述每个目标字词对应的一维向量;
203、通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;
204、通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;
205、拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;
206、将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
对于上述步骤201,服务器在将各个目标字词转化为向量时,可以逐个对这些目标字词进行转化,也可以采用多线程的方式同时对多个目标字词进行转化,每个线程同一 时间对一个目标字词进行向量转化。具体地,针对每个目标字词进行向量转化过程中,首先,服务器可以检索预设的字典中是否记录有该目标字词。这里需要说明的是,为了便于实现对字词到向量的转化,服务器可以预先设有字典,该字典记录了字词与一维向量之间的一一对应关系。例如,可以设置“你好”与“1号向量”对应,“我”与“2号向量”对应,“明天”与“3号向量”对应,“回复”与“4号向量”对应,“你”与“5号向量”对应……,通过尽可能穷尽所有字词来完善该字典,从而当需要转化该目标文本中的各个目标字词时,服务器可以采用预设的字典将所述目标文本中各个目标字词转化为各个一维向量。
因此,若服务器检测到字典中记录有该目标字词,说明该字典中也记录有该目标字词对应的一维向量,反之,则不记录有与该目标字词对应的一维向量。
对于上述步骤202,可以理解的是,若检测发现预设的字典中记录有所述每个目标字词,则说明该字典中记录有所述每个目标字词对应的一维向量,因此,服务器可以从字典中获取到与所述每个目标字词对应的一维向量。
对于上述步骤203,可以理解的是,若检测发现预设的字典中没有记录有所述每个目标字词,则说明该字典中没有记录所述每个目标字词对应的一维向量。这是因为,服务器预设字典时往往难以穷尽所有字词,即便花费大量成本穷尽所有字词记录到字典中,由于当前社会信息量每日剧增,几乎每天均会产生新的字词,比如网络用语,因此预设的字典也存在没有收录某些字词的情况。面对这种情况,本实施例中可以在使用时一边实现对目标字词的向量转化,一边补充新增字词到字典中以完善字典。具体地,服务器先通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量。可知,由于第三方平台往往更新及时,因此在其上加载的词向量一般会涵盖了所有当前可能出现的字词,因此可以实现将该目标字词转化为第一向量。
对于上述步骤204,为了增加向量转化的准确性,降低误差率,本实施例还通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量。可知,第二第三方平台与第一第三方平台为两个不同的平台,在各自上加载的词向量也不相同。
对于上述步骤205,服务器在得到第一向量和第二向量后,可以所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量。具体地,可以将同一个字词对应的第一向量和第二向量一前一后拼接起来,即第一向量的尾部紧接上第二向量的头部,从而得到一个新的一维向量。可知,由于第一向量和第二向量来自不同平台的两个词向量,因此两者存在不同,本实施例将两个平台的转化规则整合到一起,从整体上可以减少向量转化的误差,通知也保证了每个一维向量均具有足够的长度,提高后续使用的准确性。
对于上述步骤206,可以理解的是,拼接得到的该一维向量相对该预设的字典来说是新的一维向量,因此,为便于完善该字典,便于后续使用该字典时能提高字词的检索成功率,服务器可以将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
104、按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;
在得到各个目标字词对应的各个目标向量之后,服务器可以按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至预先训练好的网络模型,得到所述网络模型依次输出的结果序列,其中,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点。例如,假设该目标文本对应的目标向量共5个,分别为1-5号向量,则在执行步骤104时,先将1号向量输入至该网络模型,然后将2号向量输入至 该网络模型,随后是3号向量、4号向量和5号向量;同时,可知在1号向量输入至该网络模型没多久,该网络模型会输出与该1号向量对应的数值,随后会输出与该2号向量对应的数值,以及输出与该3号向量对应的数值、4号向量对应的数值、5号向量对应的数值。因此,该网络模型依次输出的5个数值组成了该结果序列。
需要说明的是,服务器预先设置好每个数值与标点之间的对应关系,具体可以根据实际情况需要设定。例如,在一个应用场景下,可以将数值与标点的对应关系设置如下表一所示:
表一
| 标点 | 空格 | 句号 | 逗号 | 问号 |
| 数值 | 0 | 1 | 2 | 3 |
可知,上述标点的种类可以根据实际情况的需要增多或减少,并且,哪一数值与哪一标点对应可以根据需要设定,只需保证该网络模型训练时和使用时均采用同一套对应关系即可。
本实施例中,该网络模型由两部分组成,前半部分为LSTM网络,后半部分则为条件随机场。可以理解的是,无标点文本的标点预测应用场景下,LSTM网络善于解决长序依赖问题,适合于处理和预测时间序列中间隔和延迟相对较长的重要事件,能很好地理解无标点文本中各个字词之间的依赖关系并给出预测,但是LSTM网络缺乏对输出类别信息建模的能力,因此,本方法摈弃LSTM网络后加上全连接层的方式,而在LSTM网络后接上条件随机场(CRF,conditional random field algorithm),其能很好地弥补LSTM网络的这一缺陷,使得两者结合相得益彰,提高对无标点文本的标点预测准确性。
为便于理解,下面将对网络模型的训练过程进行详细描述。如图4所示,进一步地,所述网络模型可以通过以下步骤预先训练好:
301、收集多个带标点的话术文本;
302、将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;
303、针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;
304、对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;
305、对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;
306、针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输出的各个中间向量;
307、分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;
308、以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;
309、若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
对于上述步骤301,本实施例中,工作人员可以在不同应用场景下收集大量的话术文本,比如,可以收集用户咨询问题时的话术文本、收集用户投诉时的话术文本、收集 用户闲聊时的话术文本、等等。在收集话术文本时,服务器可以通过专业知识库、网络数据库等渠道收集大量的、原始的话术文本。需要说明的是,这些话术文本需要带有标点,收集的原始话术文本若不带有标点,可以人工为其添加上标点。
对于上述步骤302,在训练时,输入的是不带有标点的话术文本,因此服务器可以将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合。例如,某个收集到的话术文本为“你们有什么产品?”,将这个话术文本分离后可以得到样本文本“你们有什么产品”以及标点集合“?”(问号前面有四个空格)。
对于上述步骤303,可以理解的是,为了便于后续步骤的处理,在步骤302从话术文本中分离出标点集合后,服务器还可以将这些标点集合转化成以由数值组成的序列,即标准序列。具体地,根据上面所说的数值标点对应关系将每个标点集合中的各个标点转换为第一数值,然后将这些第一数值排列得到标准序列。举例说明,例如上述标点集合“?”,参照上述表一所示的对应关系可以得到标准序列为“00003”。
对于上述步骤304,与上述步骤102同理,在进行网络模型训练之前,同样需要对这些样本文本进行分词处理。因此,服务器可以对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词。举例说明,样本文本为“你们有什么产品”,经过分词后,可以得到“你们”、“有”、“什么”、“产品”共4个样本字词。
特别地,在对样本文本进行分词处理时,可以采用结巴分词等第三方软件实现分词处理,得到各个样本字词。
为了减少样本文本中的干扰信息,保证后续分词和投入网络模型进行训练的准确性,进一步地,在步骤304之前,本方法还包括:删除所述样本文本中的指定文本,所述指定文本至少包括停用词。可以理解的是,这里所说的停用词可以是指使用频率特别高的单汉字,比如“的”、“了”等无实际语言意义的汉字。执行步骤304之前,服务器可以将样本文本中的指定文本删除,举例说明,假设该指定文本包括停用词,该样本文本中包括文本“我今天来上班了”,服务器可以先将其中的“了”等无实际意义的停用词删除,从而得到删除后的文本“我今天来上班”。
对于上述步骤305,与上述步骤103同理,在得到各个样本字词后,为了便于后续网络模型的识别和学习,服务器需要对所述各个样本字词分别进行向量化处理,即将字词转化为向量的方式表示,从而得到所述各个样本字词对应的各个目标向量。具体地,服务器可以将每个样本字词以一维矩阵(一维向量)的形式记载。
对于上述步骤306,可以理解的是,在训练网络模型时,针对各个所述样本文本中每个样本文本进行分别训练。服务器可以按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中的LSTM网络进行训练,得到所述LSTM网络依次输出的各个中间向量。例如,假设某个样本文本的样本向量共4个,分别为1-4号向量,则在执行步骤306时,先将1号向量输入至该LSTM网络,然后将2号向量输入至该LSTM网络,随后是3号向量、4号向量;同时,可知在1号向量输入至该LSTM网络没多久,该LSTM网络会输出与该1号向量对应的中间向量,随后会输出与该2号向量对应的中间向量,以及输出与该3号向量对应的中间向量、4号向量对应的中间向量。可以理解的是,基于LSTM网络能对文本的内容进行短期记忆的特点,LSTM网络输出的中间向量相比输入的样本向量包含更多的文本信息,是本申请对无标点文本进行标点预测的基础。
关于LSTM网络,其可以克服传统的RNN(Recurrent Neural Network)无法处理远距离依赖的缺点。LSTM有三个门,分别为忘记门、输入门和输出门。其中,首先忘记门代表从上一个细胞状态丢弃的信息,取值为从0到1,取值越小表明要丢弃的信息越多。紧接着的输入门代表了让多少新的信息加入到细胞状态去。最后的输出门会根据当前细 胞状态和新的信息得到对应的输出,并更新细胞状态。关于LSTM的网络结构具体可以参照现有资料,此处不再赘述。
对于上述步骤307,在得到LSTM网络输出的各个中间向量后,服务器可以分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,其中,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点。
需要说明的是,CRF即条件随机场(Conditional Random Fields),是在给定一组输入随机变量条件下另外一组输出随机变量的条件概率分布模型,它是一种判别式的概率无向图模型,既然是判别式,那就是对条件概率分布建模。因此,在本实施例中,CRF可以实现依据LSTM网络给出的各个中间向量从各种可能的输出序列中选取出可能性最高的一个序列作为该样本序列。可知,一个CRF通常由多个特征函数组成,每个特征函数对应设有不同的权重系数,在训练CRF时,通过确定这些权重系统来完成对CRF的训练。
对于上述步骤308,可以理解的是,本实施例训练网络模型的过程,即为训练该LSTM网络和条件随机场的过程,需要调整所述LSTM网络的参数和所述条件随机场的权重系数。举例说明,假设针对某个样本文本“你们有什么产品”,将该样本文本中4个样本字词对应的样本向量依次输入LSTM网络+条件随机场后,最后条件随机场输出的样本序列为[00104],而该样本文本对应的标准序列为[00003],服务器可以检测得知两者存在误差,为此,服务器可以通过调整所述LSTM网络的参数和所述条件随机场的权重系数,尽量使得网络模型输出的结果接近[00003]。
在执行步骤308调整所述LSTM网络的参数和所述条件随机场的权重系数时,也可以通过现有的反向传播算法进行调整,对此不再展开描述。
对于上述步骤309,服务器可以判断所述样本序列与所述每个样本文本对应的标准序列之间的误差是否满足预设的训练终止条件,若满足,则说明该网络模型中的各个参数和权重系数已经调整到位,可以确定该网络模型已训练完成;反之,若不满足,则说明该网络模型还需要继续训练。其中,该训练终止条件可以根据实际使用情况预先设定,具体地,可以将该训练终止条件设定为:若所述样本序列与所述每个样本文本对应的标准序列之间的误差均小于指定误差值,则认为其满足该预设的训练终止条件。或者,也可以将其设为:使用验证集中的话术文本执行上述步骤306-308,若网络模型输出的样本序列与标准序列之间的误差在一定范围内,则认为其满足该预设的训练终止条件。其中,该验证集中的话术文本的收集与上述步骤301类似,具体地,可以执行上述步骤301收集得到大量话术文本后,将收集得到的话术文本中的一定比例划分为训练集,剩余的话术文本划分为验证集。比如,可以将收集得到的话术文本中随机划分80%作为后续训练网络模型的训练集的样本,将其它的20%划分为后续验证网络模型是否训练完成,也即是否满足预设训练终止条件的验证集的样本。
105、根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;
在得到该网络模型输出的结果序列后,服务器可以根据预设的数值标点对应关系分别确定出各个数值对应的各个标点。例如,假设将“你好我明天回复你”对应的各个目标向量输入该网络模型后,得到结果序列为[20001],则根据上述表一的对应关系可以得到该结果序列对应的5个标点分别为“,”、空格、空格、空格、“。”。
106、针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
可以理解的是,在确定出各个标点后,服务器将这些标点插入到目标文本的相应位置,即可得到标点预测后的话术文本,完成对目标文本的标点添加。承接上述举例,在 得到“,。”这5个标点后,将其添加至目标文本“你好我明天回复你”中,得到话术文本“你好,我明天回复你。”
为便于理解,如图5所示,进一步地,上述步骤106具体可以包括:
401、将所述结果序列中的第一个标点确定为当前标点;
402、将所述目标文本中的第一个目标字词确定为当前字词;
403、将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;
404、若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行步骤403;
405、若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后的话术文本。
对于上述步骤401,承接上述举例,该结果序列为[20001],其第一个标点为“,”,将“,”确定为当前标点。
对于上述步骤402,该目标文本为“你好我明天回复你”,其第一个目标字词为“你好”,从而将“你好”确定为当前字词。
对于上述步骤403,将“,”插入到“你好”后面,从而该目标文本更新为“你好,我明天回复你”。此时,下一字词是“你好”后面的“我”。
对于上述步骤404,服务器判断得知“,”并非结果序列的最后一个标点,因此可以将“”(空格)确定为新的当前标点,将“我”确定为新的当前字词,并返回执行步骤403。可知,在执行步骤403时,将“”插入到“我”后面,从而该目标文本更新为“你好,我明天回复你”。然后,服务器继续判断得知“”也不是结果序列的最后一个节点,因此可以将“”(第2个空格)确定为新的当前标点,将“明天”确定为新的当前字词,以此类推。直到当前标点为“。”时,服务器判断得知“。”为该结果序列的最后一个标点,因此执行步骤405。
对于上述步骤405,当当前标点为“。”时,说明该结果序列中的全部标点均已添加至该目标文本中,此时目标文本更新为“你好,我明天回复你。”,可见,该目标文本已经完成了标点预测和添加,从而服务器可以确定所述目标文本为标点预测后的话术文本。
本申请实施例中,首先,获取无标点的目标文本;然后,对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;接着,对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;再之,按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;次之,根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;最后,针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。可见,本申请可以通过预先训练好的LSTM网络和预设的条件随机场准确地对目标文本进行标点预测,完成对无标点文本的标点添加,提升了文本标点预测的效率,以便于后续自然语言处理对文本的直接使用。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在一实施例中,提供一种文本标点预测装置,该文本标点预测装置与上述实施例中文本标点预测方法一一对应。如图6所示,该文本标点预测装置包括文本获取模块501、分词处理模块502、字词向量化模块503、向量输入模块504、标点确定模块505和标点插入模块506。各功能模块详细说明如下:
文本获取模块501,用于获取无标点的目标文本;
分词处理模块502,用于对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;
字词向量化模块503,用于对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;
向量输入模块504,用于按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;
标点确定模块505,用于根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;
标点插入模块506,用于针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
如图7所示,进一步地,所述网络模型可以通过以下模块预先训练好:
话术文本收集模块507,用于收集多个带标点的话术文本;
标点文本分离模块508,用于将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;
第一数值确定模块509,用于针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;
样本分词处理模块510,用于对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;
样本向量化模块511,用于对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;
样本向量输入模块512,用于针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输出的各个中间向量;
随机场模块513,用于分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;
参数系数调整模块514,用于以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;
训练完成确定模块515,用于若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
如图8所示,进一步地,所述标点插入模块506可以包括:
当前标点确定单元5061,用于将所述结果序列中的第一个标点确定为当前标点;
当前字词确定单元5062,用于将所述目标文本中的第一个目标字词确定为当前字词;
插入单元5063,用于将所述当前标点插入至所述目标文本中当前字词与下一字词之 前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;
新标点确定单元5064,用于若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行所述将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置的步骤;
预测完成确定单元5065,用于若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后的话术文本。
进一步地,所述字词向量化模块可以包括:
字词检索单元,用于针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,所述字典记录了字词与一维向量之间的对应关系;
向量获取单元,用于若预设的字典中记录有所述每个目标字词,则获取与所述每个目标字词对应的一维向量;
第一字词转化单元,用于若预设的字典中没有记录有所述每个目标字词,则通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;
第二字词转化单元,用于通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;
向量拼接单元,用于拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;
字词记录单元,用于将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
进一步地,所述文本标点预测装置还可以包括:
指定文本删除模块,用于删除所述目标文本中的指定文本,所述指定文本至少包括停用词。
关于文本标点预测装置的具体限定可以参见上文中对于文本标点预测方法的限定,在此不再赘述。上述文本标点预测装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图9所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括可读存储介质、内存储器。该可读存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为可读存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储文本标点预测方法中涉及到的数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种文本标点预测方法。本实施例所提供的可读存储介质包括非易失性可读存储介质和易失性可读存储介质。
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现上述实施例中文本标点预测方法的步骤,例如图2所示的步骤101至步骤106。或者,处理器执行计算机可读指令时实现上述实施例中文本标点预测装置的各模块/单元的功能,例如图6所示模块501至模块506的功能。为避免重复,这里不再赘述。
在一个实施例中,提供了一种计算机可读存储介质,该一个或多个存储有计算机可读指令的可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理 器执行计算机可读指令时实现上述方法实施例中文本标点预测方法的步骤,或者,该一个或多个存储有计算机可读指令的可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行计算机可读指令时实现上述装置实施例中文本标点预测装置中各模块/单元的功能。为避免重复,这里不再赘述。本实施例所提供的可读存储介质包括非易失性可读存储介质和易失性可读存储介质。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。
Claims (20)
- 一种文本标点预测方法,其特征在于,包括:获取无标点的目标文本;对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
- 根据权利要求1所述的文本标点预测方法,其特征在于,所述网络模型通过以下步骤预先训练好:收集多个带标点的话术文本;将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输出的各个中间向量;分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
- 根据权利要求1所述的文本标点预测方法,其特征在于,所述针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本包括:将所述结果序列中的第一个标点确定为当前标点;将所述目标文本中的第一个目标字词确定为当前字词;将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的 下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行所述将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置的步骤;若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后的话术文本。
- 根据权利要求1所述的文本标点预测方法,其特征在于,所述对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量包括:针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,所述字典记录了字词与一维向量之间的对应关系;若预设的字典中记录有所述每个目标字词,则获取与所述每个目标字词对应的一维向量;若预设的字典中没有记录有所述每个目标字词,则通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
- 根据权利要求1至4中任一项所述的文本标点预测方法,其特征在于,在对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词之前,还包括:删除所述目标文本中的指定文本,所述指定文本至少包括停用词。
- 一种文本标点预测装置,其特征在于,包括:文本获取模块,用于获取无标点的目标文本;分词处理模块,用于对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;字词向量化模块,用于对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;向量输入模块,用于按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;标点确定模块,用于根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;标点插入模块,用于针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
- 根据权利要求6所述的文本标点预测装置,其特征在于,所述网络模型通过以下模块预先训练好:话术文本收集模块,用于收集多个带标点的话术文本;标点文本分离模块,用于将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;第一数值确定模块,用于针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;样本分词处理模块,用于对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;样本向量化模块,用于对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;样本向量输入模块,用于针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输出的各个中间向量;随机场模块,用于分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;参数系数调整模块,用于以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;训练完成确定模块,用于若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
- 根据权利要求6所述的文本标点预测装置,其特征在于,所述标点插入模块包括:当前标点确定单元,用于将所述结果序列中的第一个标点确定为当前标点;当前字词确定单元,用于将所述目标文本中的第一个目标字词确定为当前字词;插入单元,用于将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;新标点确定单元,用于若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行步骤403;预测完成确定单元,用于若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后的话术文本。
- 根据权利要求6所述的文本标点预测装置,其特征在于,所述字词向量化模块包括:字词检索单元,用于针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,所述字典记录了字词与一维向量之间的对应关系;向量获取单元,用于若预设的字典中记录有所述每个目标字词,则获取与所述每个目标字词对应的一维向量;第一字词转化单元,用于若预设的字典中没有记录有所述每个目标字词,则通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;第二字词转化单元,用于通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;向量拼接单元,用于拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;字词记录单元,用于将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
- 根据权利要求6至9中任一项所述的文本标点预测装置,其特征在于,所述文本标点预测装置还包括:指定文本删除模块,用于删除所述目标文本中的指定文本,所述指定文本至少包括停用词。
- 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:获取无标点的目标文本;对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
- 根据权利要求11所述的计算机设备,其特征在于,所述网络模型通过以下步骤预先训练好:收集多个带标点的话术文本;将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输出的各个中间向量;分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
- 根据权利要求11所述的计算机设备,其特征在于,所述针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本包括:将所述结果序列中的第一个标点确定为当前标点;将所述目标文本中的第一个目标字词确定为当前字词;将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行所述将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置的步骤;若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后 的话术文本。
- 根据权利要求11所述的计算机设备,其特征在于,所述对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量包括:针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,所述字典记录了字词与一维向量之间的对应关系;若预设的字典中记录有所述每个目标字词,则获取与所述每个目标字词对应的一维向量;若预设的字典中没有记录有所述每个目标字词,则通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
- 根据权利要求11至14中任一项所述的计算机设备,其特征在于,在对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词之前,所述处理器执行所述计算机可读指令时还实现如下步骤:删除所述目标文本中的指定文本,所述指定文本至少包括停用词。
- 一个或多个存储有计算机可读指令的可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:获取无标点的目标文本;对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词;对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量;按照所述各个目标字词在所述目标文本中的次序,将所述各个目标向量依次输入至网络模型,得到所述网络模型依次输出的结果序列,所述结果序列中的各个数值分别表征了所述各个目标字词对应的标点,所述网络模型由预先训练好的LSTM网络和条件随机场组成;根据预设的数值标点对应关系分别确定出各个数值对应的各个标点,所述数值标点对应关系记录了数值与标点的一一对应关系;针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本,所述后面位置是指所述目标文本中位于所述目标字词后面、且紧靠所述目标字词的位置。
- 根据权利要求16所述的可读存储介质,其特征在于,所述网络模型通过以下步骤预先训练好:收集多个带标点的话术文本;将收集到的各个话术文本中的标点与文本分离,得到各个样本文本和与所述各个样本文本对应的各个标点集合;针对每个标点集合,根据预设的数值标点对应关系分别确定出所述每个标点集合中各个标点对应的第一数值,并以各个所述第一数值组成与所述每个标点集合对应的标准序列,所述数值标点对应关系记录了数值与标点的一一对应关系;对所述样本文本分别进行分词处理,得到各个所述样本文本中的各个样本字词;对各个所述样本文本中的各个样本字词分别进行向量化处理,得到与所述各个样本字词对应的各个样本向量;针对各个所述样本文本中每个样本文本,按照各个样本字词在每个样本文本中的次序,将各个样本向量依次输入至所述网络模型中LSTM网络,得到所述LSTM网络依次输 出的各个中间向量;分别将各个所述中间向量输入至所述网络模型中条件随机场中,得到所述条件随机场输出的样本序列,所述样本序列中的各个数值分别表征了所述各个样本字词对应的标点;以输出的所述样本序列作为调整目标,调整所述LSTM网络的参数和所述条件随机场的权重系数,以最小化得到的所述样本序列与所述每个样本文本对应的标准序列之间的误差;若所述样本序列与所述每个样本文本对应的标准序列之间的误差满足预设的训练终止条件,则确定所述网络模型已训练好。
- 根据权利要求16所述的可读存储介质,其特征在于,所述针对所述各个标点中的每个标点,将所述每个标点插入至所述目标文本中与所述每个标点对应目标字词的后面位置,得到标点预测后的话术文本包括:将所述结果序列中的第一个标点确定为当前标点;将所述目标文本中的第一个目标字词确定为当前字词;将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置,所述下一字词是指所述目标文本中所述当前字词的下一个字词;若所述当前标点不是所述结果序列的最后一个标点,则将所述结果序列中当前标点的下一个标点确定为新的当前标点,且将所述目标文本中当前字词的下一个字词确定为新的当前字词,再返回执行所述将所述当前标点插入至所述目标文本中当前字词与下一字词之前的位置的步骤;若所述当前标点是所述结果序列的最后一个标点,则确定所述目标文本为标点预测后的话术文本。
- 根据权利要求16所述的可读存储介质,其特征在于,所述对所述各个目标字词分别进行向量化处理,得到所述各个目标字词对应的各个目标向量包括:针对所述各个目标字词中的每个目标字词,检索预设的字典中是否记录有所述每个目标字词,所述字典记录了字词与一维向量之间的对应关系;若预设的字典中记录有所述每个目标字词,则获取与所述每个目标字词对应的一维向量;若预设的字典中没有记录有所述每个目标字词,则通过加载第一第三方平台的词向量,将所述每个目标字词转化为第一向量;通过加载第二第三方平台的词向量,将所述每个目标字词转化为第二向量;拼接所述第一向量和第二向量,得到一个一维向量作为所述每个目标字词对应的一维向量;将拼接得到的所述一维向量和与之对应的目标字词记录至所述字典。
- 根据权利要求16至19中任一项所述的可读存储介质,其特征在于,在对所述目标文本进行分词处理,得到所述目标文本中的各个目标字词之前,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤::删除所述目标文本中的指定文本,所述指定文本至少包括停用词。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910182506.1A CN110032732A (zh) | 2019-03-12 | 2019-03-12 | 一种文本标点预测方法、装置、计算机设备及存储介质 |
| CN201910182506.1 | 2019-03-12 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020181808A1 true WO2020181808A1 (zh) | 2020-09-17 |
Family
ID=67235820
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/117303 Ceased WO2020181808A1 (zh) | 2019-03-12 | 2019-11-12 | 一种文本标点预测方法、装置、计算机设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110032732A (zh) |
| WO (1) | WO2020181808A1 (zh) |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112347789A (zh) * | 2020-11-06 | 2021-02-09 | 科大讯飞股份有限公司 | 一种标点预测方法、装置、设备及存储介质 |
| CN112464642A (zh) * | 2020-11-25 | 2021-03-09 | 平安科技(深圳)有限公司 | 文本添加标点的方法、装置、介质及电子设备 |
| CN112633479A (zh) * | 2020-12-30 | 2021-04-09 | 北京捷通华声科技股份有限公司 | 一种目标数据的预测方法和装置 |
| CN112685996A (zh) * | 2020-12-23 | 2021-04-20 | 北京有竹居网络技术有限公司 | 文本标点预测方法、装置、可读介质和电子设备 |
| CN114595676A (zh) * | 2022-02-15 | 2022-06-07 | 北京三快在线科技有限公司 | 文本分句方法及装置、电子设备及可读存储介质 |
| CN117113941A (zh) * | 2023-10-23 | 2023-11-24 | 新声科技(深圳)有限公司 | 标点符号恢复方法、装置、电子设备及存储介质 |
| CN119646240A (zh) * | 2024-12-06 | 2025-03-18 | 北京百度网讯科技有限公司 | 时间序列数据预测方法、装置、电子设备及存储介质 |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110032732A (zh) * | 2019-03-12 | 2019-07-19 | 平安科技(深圳)有限公司 | 一种文本标点预测方法、装置、计算机设备及存储介质 |
| CN111339750B (zh) * | 2020-02-24 | 2023-09-08 | 网经科技(苏州)有限公司 | 去除停用语并预测句子边界的口语文本处理方法 |
| CN111832564A (zh) * | 2020-07-20 | 2020-10-27 | 浙江诺诺网络科技有限公司 | 一种图像文字识别方法、系统及电子设备和存储介质 |
| CN112735384B (zh) * | 2020-12-28 | 2024-07-05 | 科大讯飞股份有限公司 | 应用于说话人分离的转折点检测方法、装置以及设备 |
| CN113780449B (zh) * | 2021-09-16 | 2023-08-25 | 平安科技(深圳)有限公司 | 文本相似度的计算方法、装置、存储介质及计算机设备 |
| CN114049885B (zh) * | 2022-01-12 | 2022-04-22 | 阿里巴巴达摩院(杭州)科技有限公司 | 标点符号识别模型构建方法和装置 |
| CN116070628A (zh) * | 2023-01-10 | 2023-05-05 | 长城汽车股份有限公司 | 一种文本断句的方法、装置、电子设备及存储介质 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107247700A (zh) * | 2017-04-27 | 2017-10-13 | 北京捷通华声科技股份有限公司 | 一种添加文本标注的方法及装置 |
| US20170358295A1 (en) * | 2016-06-10 | 2017-12-14 | Conduent Business Services, Llc | Natural language generation, a hybrid sequence-to-sequence approach |
| CN108920446A (zh) * | 2018-04-25 | 2018-11-30 | 华中科技大学鄂州工业技术研究院 | 一种工程文本的处理方法 |
| US20190065460A1 (en) * | 2017-08-31 | 2019-02-28 | Ebay Inc. | Deep hybrid neural network for named entity recognition |
| CN110032732A (zh) * | 2019-03-12 | 2019-07-19 | 平安科技(深圳)有限公司 | 一种文本标点预测方法、装置、计算机设备及存储介质 |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103164399A (zh) * | 2013-02-26 | 2013-06-19 | 北京捷通华声语音技术有限公司 | 一种语音识别中的标点添加方法和装置 |
| CN104143331B (zh) * | 2013-05-24 | 2015-12-09 | 腾讯科技(深圳)有限公司 | 一种添加标点的方法和系统 |
| US9978370B2 (en) * | 2015-07-31 | 2018-05-22 | Lenovo (Singapore) Pte. Ltd. | Insertion of characters in speech recognition |
| CN106653030A (zh) * | 2016-12-02 | 2017-05-10 | 北京云知声信息技术有限公司 | 标点添加方法及装置 |
| CN107221330B (zh) * | 2017-05-26 | 2020-11-27 | 北京搜狗科技发展有限公司 | 标点添加方法和装置、用于标点添加的装置 |
| CN107767870B (zh) * | 2017-09-29 | 2021-03-23 | 百度在线网络技术(北京)有限公司 | 标点符号的添加方法、装置和计算机设备 |
| CN108932226A (zh) * | 2018-05-29 | 2018-12-04 | 华东师范大学 | 一种对无标点文本添加标点符号的方法 |
-
2019
- 2019-03-12 CN CN201910182506.1A patent/CN110032732A/zh active Pending
- 2019-11-12 WO PCT/CN2019/117303 patent/WO2020181808A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170358295A1 (en) * | 2016-06-10 | 2017-12-14 | Conduent Business Services, Llc | Natural language generation, a hybrid sequence-to-sequence approach |
| CN107247700A (zh) * | 2017-04-27 | 2017-10-13 | 北京捷通华声科技股份有限公司 | 一种添加文本标注的方法及装置 |
| US20190065460A1 (en) * | 2017-08-31 | 2019-02-28 | Ebay Inc. | Deep hybrid neural network for named entity recognition |
| CN108920446A (zh) * | 2018-04-25 | 2018-11-30 | 华中科技大学鄂州工业技术研究院 | 一种工程文本的处理方法 |
| CN110032732A (zh) * | 2019-03-12 | 2019-07-19 | 平安科技(深圳)有限公司 | 一种文本标点预测方法、装置、计算机设备及存储介质 |
Cited By (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112347789A (zh) * | 2020-11-06 | 2021-02-09 | 科大讯飞股份有限公司 | 一种标点预测方法、装置、设备及存储介质 |
| CN112347789B (zh) * | 2020-11-06 | 2024-04-12 | 科大讯飞股份有限公司 | 一种标点预测方法、装置、设备及存储介质 |
| CN112464642A (zh) * | 2020-11-25 | 2021-03-09 | 平安科技(深圳)有限公司 | 文本添加标点的方法、装置、介质及电子设备 |
| CN112685996A (zh) * | 2020-12-23 | 2021-04-20 | 北京有竹居网络技术有限公司 | 文本标点预测方法、装置、可读介质和电子设备 |
| CN112685996B (zh) * | 2020-12-23 | 2024-03-22 | 北京有竹居网络技术有限公司 | 文本标点预测方法、装置、可读介质和电子设备 |
| CN112633479A (zh) * | 2020-12-30 | 2021-04-09 | 北京捷通华声科技股份有限公司 | 一种目标数据的预测方法和装置 |
| CN114595676A (zh) * | 2022-02-15 | 2022-06-07 | 北京三快在线科技有限公司 | 文本分句方法及装置、电子设备及可读存储介质 |
| CN117113941A (zh) * | 2023-10-23 | 2023-11-24 | 新声科技(深圳)有限公司 | 标点符号恢复方法、装置、电子设备及存储介质 |
| CN117113941B (zh) * | 2023-10-23 | 2024-02-06 | 新声科技(深圳)有限公司 | 标点符号恢复方法、装置、电子设备及存储介质 |
| CN119646240A (zh) * | 2024-12-06 | 2025-03-18 | 北京百度网讯科技有限公司 | 时间序列数据预测方法、装置、电子设备及存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110032732A (zh) | 2019-07-19 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020181808A1 (zh) | 一种文本标点预测方法、装置、计算机设备及存储介质 | |
| CN110765244B (zh) | 获取应答话术的方法、装置、计算机设备及存储介质 | |
| CN113094578B (zh) | 基于深度学习的内容推荐方法、装置、设备及存储介质 | |
| WO2021031383A1 (zh) | 智能辅助审判方法、装置、计算机设备及存储介质 | |
| CN110415679B (zh) | 语音纠错方法、装置、设备和存储介质 | |
| WO2021051866A1 (zh) | 判案结果确定方法、装置、设备及计算机可读存储介质 | |
| CN109614627B (zh) | 一种文本标点预测方法、装置、计算机设备及存储介质 | |
| WO2020232877A1 (zh) | 一种问题答案选取方法、装置、计算机设备及存储介质 | |
| WO2022227162A1 (zh) | 问答数据处理方法、装置、计算机设备及存储介质 | |
| WO2020220539A1 (zh) | 数据增量方法、装置、计算机设备及存储介质 | |
| WO2021114810A1 (zh) | 基于图结构的公文推荐方法、装置、计算机设备及介质 | |
| WO2020237869A1 (zh) | 一种问题意图识别方法、装置、计算机设备及存储介质 | |
| WO2021114841A1 (zh) | 一种用户报告的生成方法及终端设备 | |
| CN110472035A (zh) | 一种智能应答方法、装置、计算机设备及存储介质 | |
| CN108595695A (zh) | 数据处理方法、装置、计算机设备和存储介质 | |
| WO2021151328A1 (zh) | 症状数据处理方法、装置、计算机设备及存储介质 | |
| CN110795913A (zh) | 一种文本编码方法、装置、存储介质及终端 | |
| CN111339248A (zh) | 数据属性填充方法、装置、设备及计算机可读存储介质 | |
| WO2021238337A1 (zh) | 用于实体标注的方法和装置 | |
| CN111400340A (zh) | 一种自然语言处理方法、装置、计算机设备和存储介质 | |
| CN110674276A (zh) | 机器人自学习方法、机器人终端、装置及可读存储介质 | |
| CN114203200B (zh) | 一种语音质检方法、装置、计算机设备和存储介质 | |
| CN117556057A (zh) | 知识问答方法、向量数据库构建方法及装置 | |
| CN116644183A (zh) | 文本分类方法、装置及存储介质 | |
| CN116052676A (zh) | 热词管理方法、语音识别方法、装置、设备及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19919014 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19919014 Country of ref document: EP Kind code of ref document: A1 |