Text processing method and device, equipment and storage medium

By masking the speech text and extracting features using a category detection model, the problem of unconverted numbers and idioms after speech recognition is solved, thus improving the accuracy and intuitiveness of text conversion.

CN115809640BActive Publication Date: 2026-04-07CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-19
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies convert numerical fragments, such as idioms, that should not be converted after speech recognition, resulting in low text conversion accuracy.

Method used

By locating digit segments in speech text and masking them, feature extraction and attention encoding are performed using the embedding, encoding, and output layers of a category detection model. Combined with a mapping matrix and a configuration list, the digit categories are accurately detected and converted to generate the target text.

Benefits of technology

It improves the accuracy of text conversion, avoids incorrect conversion of numerical fragments that should not be converted, and enhances the intuitiveness and readability of the text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115809640B_ABST
    Figure CN115809640B_ABST
Patent Text Reader

Abstract

The present application relates to artificial intelligence, and provides a text processing method, device, equipment and storage medium. The method locates the segment position of the digital segment from the speech text, performs mask processing on the speech text based on the segment position, obtains a masked text, performs feature extraction on the masked text, obtains text features, performs attention coding processing on the text features, obtains a coding vector, inputs the coding vector into an output network layer, obtains a digital category, performs text conversion on the speech text based on the digital category, and improves the conversion accuracy of the target text. In addition, the present application also relates to blockchain technology, and the target text can be stored in the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a text processing method and device, equipment and a storage medium. BACKGROUND

[0002] With the development of artificial intelligence, speech recognition has also made certain development. In the text obtained by speech recognition, the phenomenon of outputting numbers in the form of Chinese characters often occurs, resulting in poor intuitiveness of the text output by speech recognition.

[0003] In order to improve the intuitiveness of the text, the current rule-based matching method is used to convert all the number texts obtained by speech recognition into Arabic numerals. However, this method also converts a part of numbers that should not be converted, such as the idiom "one poor as a church mouse", resulting in low accuracy of text conversion. SUMMARY

[0004] In view of the above, it is necessary to provide a text processing method, device, equipment and storage medium, which can solve the technical problem that the text with a number segment cannot be accurately converted.

[0005] In one aspect, the present application provides a text processing method applied to an electronic device, which comprises:

[0006] locating a segment position of a number segment from an obtained speech text;

[0007] masking the speech text based on the segment position to obtain a masked text;

[0008] obtaining a category detection model, the category detection model comprising an embedding network layer, an encoding network layer and an output network layer;

[0009] extracting features of the masked text based on the embedding network layer to obtain text features;

[0010] performing attention encoding processing on the text features based on the encoding network layer to obtain an encoding vector;

[0011] inputting the encoding vector into the output network layer to obtain a number category of the number segment in the speech text;

[0012] performing text conversion on the speech text based on the number category to obtain a target text.

[0013] According to the preferred embodiment of the present application, the step of locating a segment position of a number segment from an obtained speech text comprises:

[0014] acquire the speech text from a translation device in communication with the electronic device;

[0015] acquire all forms of representation with a text label being a preset label from the translation device;

[0016] filter the digital segment from the speech text based on the all forms of representation;

[0017] locate the segment position based on an arrangement order of the digital segment in the speech text.

[0018] According to the preferred embodiment of the present application, the inputting the encoding vector into the output network layer to obtain the digital category of the digital segment in the speech text comprises:

[0019] perform mapping processing on the encoding vector based on a mapping matrix in the output network layer to obtain a mapping vector;

[0020] perform normalization processing on the mapping vector to obtain a probability vector, the probability vector comprising a predicted probability value of the digital segment for each preset label;

[0021] if there are at least two predicted probability values greater than a preset probability threshold value in the plurality of predicted probability values, determine the predicted probability value greater than the preset probability threshold value as a target probability value;

[0022] select a target category from the plurality of preset labels based on a probability difference value of the target probability value;

[0023] if there are multiple target categories, extract a target word from the speech text based on the digital segment;

[0024] acquire a preset label corresponding to the digital segment from a configuration list of the output network layer as the digital category based on the target word.

[0025] According to the preferred embodiment of the present application, the attention encoding processing on the text feature based on the encoding network layer to obtain the encoding vector comprises:

[0026] perform dot product operation of each weight matrix in the encoding network layer with the text feature to obtain an initial vector corresponding to each weight matrix;

[0027] perform normalization processing and activation processing on a dot product result of any two vectors in the plurality of initial vectors to obtain a vector weight;

[0028] perform dot product operation of the vector weight with a target vector in the plurality of initial vectors to obtain a score vector;

[0029] Based on the fully connected parameters in the coding network layer, the score vector is processed by a fully connected layer to obtain the coding vector.

[0030] According to a preferred embodiment of the present invention, the step of converting the speech text based on the number category to obtain the target text includes:

[0031] If the number category is not a specific category, then obtain the category label corresponding to the number category;

[0032] Generate replacement statements based on the category labels and the fragment positions;

[0033] The speech text is updated based on the replacement statement to obtain the target text.

[0034] According to a preferred embodiment of the present invention, the step of masking the speech text based on the segment position to obtain masked text includes:

[0035] Obtain the configuration mask identifier from the category detection model;

[0036] Based on the configured mask identifier, the voice text is masked to obtain the masked text.

[0037] According to a preferred embodiment of the present invention, the step of extracting features from the masked text based on the embedded network layer to obtain text features includes:

[0038] The masked text is encoded to obtain the representation vector of the masked text;

[0039] The representation vector is processed based on the dimensionality reduction matrix in the embedded network layer to obtain low-dimensional features;

[0040] The mask features of the configuration mask identifier are located from the low-dimensional features;

[0041] Extract the adjacent and non-adjacent features of the mask feature from the low-dimensional features;

[0042] The adjacent features are then subjected to dimensionality-upgrading processing to obtain high-dimensional features;

[0043] The text features are obtained by concatenating the high-dimensional features and the non-adjacent features.

[0044] On the other hand, the present invention also proposes a text processing device, which operates in an electronic device, the text processing device comprising:

[0045] The localization unit is used to locate the position of a digital segment from the acquired speech text.

[0046] A mask unit is configured to mask the speech text based on the segment position to obtain a masked text;

[0047] An acquisition unit is configured to acquire a category detection model, the category detection model comprising an embedding network layer, an encoding network layer, and an output network layer;

[0048] An extraction unit is configured to extract features of the masked text based on the embedding network layer to obtain text features;

[0049] An encoding unit is configured to perform attention encoding processing on the text features based on the encoding network layer to obtain an encoding vector;

[0050] An input unit is configured to input the encoding vector into the output network layer to obtain a digital category of the digital segment in the speech text;

[0051] A conversion unit is configured to convert the speech text into a target text based on the digital category.

[0052] In another aspect, the present application further provides an electronic device, which comprises:

[0053] a memory configured to store computer-readable instructions; and

[0054] a processor configured to execute the computer-readable instructions stored in the memory to implement the text processing method.

[0055] In another aspect, the present application further provides a computer-readable storage medium, which stores computer-readable instructions, the computer-readable instructions being executed by a processor in an electronic device to implement the text processing method.

[0056] As can be seen from the above technical solutions, the present application can avoid the influence of the digital segment on category detection by masking the digital segment in the speech text, can expand the receptive field of the text that has an influence on the category of the digital segment by extracting features of the masked text through the embedding network layer, can improve the representation ability of the encoding vector by performing attention encoding on the text features through the encoding network layer, and can further improve the detection accuracy of the digital category by combining the mapping matrix and the configuration list of the output network layer to predict the encoding vector, thereby avoiding converting all digital segments in the speech text, and improving the text conversion accuracy of the target text. BRIEF DESCRIPTION OF DRAWINGS

[0057] Figure 1is an application scenario diagram of the text processing method.

[0058] Figure 2 is a flowchart of a preferred embodiment of the text processing method.

[0059] Figure 3 is a network structure diagram of a category detection model in the text processing method.

[0060] Figure 4 is a functional module diagram of a preferred embodiment of the text processing device.

[0061] Figure 5 is a structural schematic diagram of an electronic device implementing a preferred embodiment of the text processing method. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described in detail below in combination with the drawings and specific embodiments.

[0063] As shown in Figure 1 , is Figure 1 is an application scenario diagram of the text processing method.

[0064] The present application is applied in an electronic device 1, which is in communication with a translation device 2. The translation device 2 is used to translate voice into text output, wherein the text can be Chinese, the text can also be English, etc., and the present application does not specifically limit the text.

[0065] As shown in Figure 2 , is a flowchart of a preferred embodiment of the text processing method. The order of steps in the flowchart can be changed according to different needs, and some steps can be omitted.

[0066] The text processing method can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or digital computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0067] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.

[0068] The text processing method is applied to one or more electronic devices, which is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored computer readable instructions, and the hardware thereof includes but is not limited to microprocessor, application specific integrated circuit (ASIC), field-programmable gate array (FPGA), digital signal processor (DSP), embedded device, etc.

[0069] The electronic device can be any electronic product capable of human-computer interaction with the user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive Internet Protocol Television (IPTV), a smart wearable device, etc.

[0070] The electronic device can include a network device and / or a user device. The network device includes but is not limited to a single network electronic device, an electronic device group composed of multiple network electronic devices, or a cloud composed of a large number of hosts or network electronic devices based on cloud computing.

[0071] The network in which the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0072] The electronic device communicates with the translation device.

[0073] 101, locating the segment position of the digital segment from the obtained voice text.

[0074] In at least one embodiment of the present application, the voice text refers to the text output by the translation device after translating any voice, which can be Chinese, and can also be English, etc.

[0075] The digital segment refers to the digital vocabulary in the voice text, for example, the voice text is: A company holds the fifteenth meeting since its establishment in B, and each local representative speaks in turn. The digital segment includes fifteen, one one.

[0076] The segment position refers to the specific location of the digital segment in the speech text. Continuing with the above example, the segment position of the digital segment "fifteen" is: serial number 16-17, and the segment position of "one-one" is: serial number 26-27.

[0077] In at least one embodiment of the present invention, the electronic device locates the position of a digital segment from the acquired voice text by including:

[0078] The speech text is obtained from a translation device that communicates with the electronic device;

[0079] Obtain all representations of text tags as preset tags from the translation device;

[0080] Based on all the aforementioned representation forms, the digital segments are selected from the speech text;

[0081] The position of the segment is located based on the arrangement order of the digital segments in the speech text.

[0082] The preset labels include all labels related to numbers, such as, but not limited to: Chinese numerals, Arabic numerals, Chinese telegraphic readings, and uppercase Chinese characters.

[0083] For example, the Chinese numerals are represented as "one hundred and three", the Arabic numerals as "103", and the Chinese telegraph reading method as "one hundred and three", etc.

[0084] The arrangement order refers to the text sequence number of the digital segment in the audio text. For example, the arrangement order could be sequence number 16-sequence number 17.

[0085] The translation device can directly acquire the speech text, and then, through all the representation forms corresponding to the preset tags stored in the translation device, the digital segments can be accurately filtered out from the speech text, and the position of the segments can be accurately located based on the arrangement order.

[0086] 102. Mask the speech text based on the segment position to obtain masked text.

[0087] In at least one embodiment of the present invention, the masked text refers to the text obtained by masking digital segments in the speech text.

[0088] In at least one embodiment of the present invention, the electronic device performs masking processing on the speech text based on the segment position to obtain masked text including:

[0089] Obtain the configuration mask identifier from the category detection model;

[0090] Based on the configured mask identifier, the voice text is masked to obtain the masked text.

[0091] The configuration mask identifier refers to an identifier that the category detection model cannot perform semantic representation for; for example, the configuration mask identifier can be a mask.

[0092] By using the configuration mask identifier obtained from the category detection model to mask the speech text, it is possible to avoid using identifiers with semantic representation to mask the speech text, thereby improving the rationality of the generation of the mask text.

[0093] 103. Obtain a category detection model, which includes an embedding network layer, an encoding network layer, and an output network layer.

[0094] In at least one embodiment of the present invention, the category detection model is used to detect the specific category corresponding to the numerical fragments in the text. For example... Figure 3 As shown, Figure 3 This is a network structure diagram of the category detection model in the text processing method of this invention. Figure 3 In this context, the mask text is: the[mask]sat on the mat. P represents the specific category output by the output network layer of the category detection model.

[0095] The embedded network layer is used to reduce the representational dimension of the text and expand the receptive field of digital fragments in the text.

[0096] The encoding network layer is used to re-encode the text.

[0097] The output network layer is used to output the specific category corresponding to the numerical fragments in the text.

[0098] In at least one embodiment of the present invention, before obtaining the category detection model, the method further includes:

[0099] Obtain the preset detection network;

[0100] Obtain training texts and the labeled categories of text numbers in the training texts from a preset library;

[0101] The training text is input into the preset detection network for detection to obtain the predicted category;

[0102] Based on the predicted category and the annotation results, the hyperparameters in the preset detection network are adjusted until the loss value or prediction accuracy value of the preset detection network no longer changes, thus obtaining the category detection model.

[0103] The preset libraries include document libraries, book libraries, news libraries, etc.

[0104] The training text refers to text containing numerical information.

[0105] Specifically, the method for generating the predicted category is similar to the method for detecting the speech text by the category detection model, and will not be described in detail here.

[0106] By adjusting the hyperparameters using the loss value and the prediction accuracy value, the detection accuracy of the category detection model can be improved.

[0107] 104. Based on the embedded network layer, feature extraction is performed on the masked text to obtain text features.

[0108] In at least one embodiment of the present invention, the text features refer to the representation features of the speech text by the embedding network layer.

[0109] In at least one embodiment of the present invention, the electronic device performs feature extraction on the masked text based on the embedded network layer to obtain text features including:

[0110] The masked text is encoded to obtain the representation vector of the masked text;

[0111] The representation vector is processed based on the dimensionality reduction matrix in the embedded network layer to obtain low-dimensional features;

[0112] The mask features of the configuration mask identifier are located from the low-dimensional features;

[0113] Extract the adjacent and non-adjacent features of the mask feature from the low-dimensional features;

[0114] The adjacent features are then subjected to dimensionality-upgrading processing to obtain high-dimensional features;

[0115] The text features are obtained by concatenating the high-dimensional features and the non-adjacent features.

[0116] The dimensionality reduction matrix is ​​a hyperparameter of the category detection model.

[0117] The mask feature refers to the feature in the low-dimensional features that corresponds to the configured mask identifier.

[0118] The adjacent features refer to the features in the low-dimensional features that are adjacent to the mask feature. The non-adjacent features refer to the features in the low-dimensional features other than the mask feature and the non-adjacent features. For example, if the low-dimensional features are [0.1 1 0.2 1 0.3 1 0 0.4], and the mask feature is 0, then the adjacent features are 1 and 0.4, and the non-adjacent features are 0.1, 1, 0.2, 1 and 0.3.

[0119] The dimensionality reduction matrix enables the dimensionality reduction of the representation vector, thereby avoiding excessive data volume in the representation vector that leads to low category detection efficiency. Furthermore, by performing dimensionality increase processing on the adjacent features, the receptive field of the adjacent features can be improved, thereby enhancing the text features' ability to represent the speech text.

[0120] 105. Based on the encoding network layer, attention encoding processing is performed on the text features to obtain the encoding vector.

[0121] In at least one embodiment of the present invention, the encoding vector refers to the vector obtained after the encoding network layer re-encodes the text features.

[0122] In at least one embodiment of the present invention, the electronic device performs attention encoding processing on the text features based on the encoding network layer to obtain an encoding vector including:

[0123] Based on the dot product operation between the multiple weight matrices in the coding network layer and the text features, an initial vector corresponding to each weight matrix is ​​obtained;

[0124] The dot product of any two vectors among the multiple initial vectors is normalized and activated to obtain the vector weights;

[0125] The score vector is obtained by multiplying the vector weights with the target vector among the multiple initial vectors.

[0126] Based on the fully connected parameters in the coding network layer, the score vector is processed by a fully connected layer to obtain the coding vector.

[0127] The multiple weight matrices and the fully connected parameters are all hyperparameters of the category detection model.

[0128] The target vector refers to the initial vector other than any two of the plurality of initial vectors.

[0129] By performing attention recoding on the text features, the ability of the encoding vector to represent the speech text can be further improved.

[0130] Specifically, the formula for generating the encoded vector is:

[0131] y = max(0, ZW1+b1)W2+b2;

[0132] Where y represents the encoding vector, Z represents the score vector, and W1, W2, b1, and b2 are all the fully connected parameters.

[0133] 106. The encoded vector is input into the output network layer to obtain the digit category of the digit segment in the speech text.

[0134] In at least one embodiment of the present invention, the number category refers to the specific category obtained by the category detection model after performing category detection on the number segments in the speech text. For example, the number category may include, but is not limited to: Chinese numerals, Arabic numerals, Chinese telegraph readings, uppercase Chinese characters, etc.

[0135] In at least one embodiment of the present invention, the electronic device inputs the encoded vector into the output network layer to obtain the digit category of the digit segment in the speech text, including:

[0136] The encoded vector is mapped based on the mapping matrix in the output network layer to obtain a mapped vector.

[0137] The mapping vector is normalized to obtain a probability vector, which includes the predicted probability value of the digital segment for each preset label.

[0138] If at least two of the predicted probability values ​​are greater than a preset probability threshold, the predicted probability values ​​that are greater than the preset probability threshold are determined as the target probability values.

[0139] Based on the probability difference of the target probability values, a target category is selected from multiple preset labels;

[0140] If there are multiple target categories, target words are extracted from the speech text based on the digital segments;

[0141] Based on the target word segmentation, the preset label corresponding to the number fragment is obtained from the configuration list of the output network layer as the number category.

[0142] Wherein, the mapping matrix and the preset probability threshold are both hyperparameters of the category detection model.

[0143] The preset labels may include, but are not limited to: Chinese numerals, Arabic numerals, Chinese telegraphic readings, and uppercase Chinese characters.

[0144] The target category includes a preset label corresponding to the target probability value with the largest value. The target category may also include a preset label corresponding to a target probability value whose difference from the target probability value with the largest value is less than a preset difference.

[0145] The target word segmentation refers to the words in the spoken text that include the digit segments.

[0146] Through the above implementation method, when at least two of the multiple predicted probability values ​​are greater than the preset probability threshold, the multiple preset labels are selected by the probability difference, which can avoid category detection errors caused by certain errors in the category detection model. Therefore, when there are multiple target categories, further detection of the target word segmentation by the configuration list can improve the accuracy of the number category.

[0147] Specifically, the electronic device selects a target category from a plurality of preset labels based on the probability difference of the target probability values, including:

[0148] The probability difference is obtained by calculating the difference between the probability values ​​of the target with the largest value and the probability values ​​of other targets.

[0149] If the probability difference is less than a preset difference, then the target probability value with the largest value and the preset label corresponding to the other target probability values ​​are determined as the target category.

[0150] The preset difference can be set according to actual needs.

[0151] For example, the predicted probability values ​​include 0.25, 0.24, 0.20, 0.21, and 0.10. If the preset probability threshold is 0.20, then the target probability values ​​are 0.25, 0.24, and 0.21. By calculating the difference between 0.25 and 0.24, and the difference between 0.25 and 0.21, if the preset difference is 0.2, then the preset labels corresponding to 0.25 and 0.24 are determined as the target category.

[0152] 107. Based on the number category, perform text conversion on the speech text to obtain the target text.

[0153] It should be emphasized that, to further ensure the privacy and security of the aforementioned target text, the target text can also be stored in a node of a blockchain.

[0154] In at least one embodiment of the present invention, the target text refers to the text information obtained after converting the digital fragments whose digital category is not a specific category.

[0155] In at least one embodiment of the present invention, the electronic device performs text conversion on the speech text based on the digital category to obtain the target text, including:

[0156] If the number category is not a specific category, then obtain the category label corresponding to the number category;

[0157] Generate replacement statements based on the category labels and the fragment positions;

[0158] The speech text is updated based on the replacement statement to obtain the target text.

[0159] The specific category can be a numerical idiom type, and the text corresponding to the specific category can be: penniless.

[0160] The category label may be an identifier indicating the category of the number, for example, the category label is: <Arabic numeral>.

[0161] The replacement statement can be a code statement.

[0162] By updating number segments whose number category does not belong to the specific category, it is possible to avoid converting some numbers that should not be converted, thereby improving the conversion accuracy of the target text. Through the replacement statement, the speech text can be updated quickly, thereby improving the conversion efficiency of the target text.

[0163] As can be seen from the above technical solutions, this application can avoid the influence of digital segments on category detection by masking the digital segments in the speech text. By extracting features from the masked text through the embedding network layer, the receptive field of the text that affects the category of the digital segments can be expanded, thereby improving the representation ability of the text features for category detection of the speech text. By performing attention encoding on the text features through the encoding network layer, the representation ability of the encoding vector can be further improved. By combining the mapping matrix and configuration list of the output network layer to predict the encoding vector, the detection accuracy of the digital category can be further improved. Thus, it is possible to avoid converting all digital segments in the speech text, thereby improving the text conversion accuracy of the target text.

[0164] like Figure 4The diagram shown is a functional block diagram of a preferred embodiment of the text processing device of the present invention. The text processing device 11 includes a positioning unit 110, a masking unit 111, an acquisition unit 112, an extraction unit 113, an encoding unit 114, an input unit 115, a conversion unit 116, and an adjustment unit 117. The module / unit referred to in this invention is a series of computer-readable instruction segments that can be acquired by the processor 13 and perform a fixed function, stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0165] The positioning unit 110 is used to locate the position of a digital segment from the acquired speech text;

[0166] Masking unit 111 is used to perform masking processing on the speech text based on the segment position to obtain masked text;

[0167] Acquisition unit 112 is used to acquire a category detection model, the category detection model including an embedding network layer, an encoding network layer and an output network layer;

[0168] Extraction unit 113 is used to extract features from the masked text based on the embedded network layer to obtain text features;

[0169] Encoding unit 114 is used to perform attention encoding processing on the text features based on the encoding network layer to obtain an encoding vector;

[0170] Input unit 115 is used to input the encoding vector into the output network layer to obtain the digit category of the digit segment in the speech text;

[0171] The conversion unit 116 is used to perform text conversion on the speech text based on the number category to obtain the target text.

[0172] In at least one embodiment of the present invention, the positioning unit 110 is further configured to obtain the speech text from a translation device communicating with the electronic device;

[0173] Obtain all representations of text tags as preset tags from the translation device;

[0174] Based on all the aforementioned representation forms, the digital segments are selected from the speech text;

[0175] The position of the segment is located based on the arrangement order of the digital segments in the speech text.

[0176] In at least one embodiment of the present invention, the input unit 115 is further configured to perform mapping processing on the encoded vector based on the mapping matrix in the output network layer to obtain a mapping vector;

[0177] The mapping vector is normalized to obtain a probability vector, which includes the predicted probability value of the digital segment for each preset label.

[0178] If at least two of the predicted probability values ​​are greater than a preset probability threshold, the predicted probability values ​​that are greater than the preset probability threshold are determined as the target probability values.

[0179] Based on the probability difference of the target probability values, a target category is selected from multiple preset labels;

[0180] If there are multiple target categories, target words are extracted from the speech text based on the digital segments;

[0181] Based on the target word segmentation, the preset label corresponding to the number fragment is obtained from the configuration list of the output network layer as the number category.

[0182] In at least one embodiment of the present invention, the encoding unit 114 is further configured to perform dot product operations between the multiple weight matrices in the encoding network layer and the text features respectively to obtain an initial vector corresponding to each weight matrix;

[0183] The dot product of any two vectors among the multiple initial vectors is normalized and activated to obtain the vector weights;

[0184] The score vector is obtained by multiplying the vector weights with the target vector among the multiple initial vectors.

[0185] Based on the fully connected parameters in the coding network layer, the score vector is processed by a fully connected layer to obtain the coding vector.

[0186] In at least one embodiment of the present invention, the conversion unit 116 is further configured to obtain a category label corresponding to the number category if the number category is not a specific category;

[0187] Generate replacement statements based on the category labels and the fragment positions;

[0188] The speech text is updated based on the replacement statement to obtain the target text.

[0189] In at least one embodiment of the present invention, the masking unit 111 is further configured to obtain a configuration mask identifier from the category detection model;

[0190] Based on the configured mask identifier, the voice text is masked to obtain the masked text.

[0191] In at least one embodiment of the present invention, the extraction unit 113 is further configured to encode the masked text to obtain the representation vector of the masked text;

[0192] The representation vector is processed based on the dimensionality reduction matrix in the embedded network layer to obtain low-dimensional features;

[0193] The mask features of the configuration mask identifier are located from the low-dimensional features;

[0194] Extract the adjacent and non-adjacent features of the mask feature from the low-dimensional features;

[0195] The adjacent features are then subjected to dimensionality-upgrading processing to obtain high-dimensional features;

[0196] The text features are obtained by concatenating the high-dimensional features and the non-adjacent features.

[0197] In at least one embodiment of the present invention, before acquiring the category detection model, the acquisition unit 112 is further configured to acquire a preset detection network;

[0198] The acquisition unit 112 is also used to acquire training text and the labeled categories of text numbers in the training text from a preset library;

[0199] The input unit 115 is also used to input the training text into the preset detection network for detection to obtain the predicted category;

[0200] The adjustment unit 117 is used to adjust the hyperparameters in the preset detection network based on the predicted category and the annotation result until the loss value or prediction accuracy value of the preset detection network no longer changes, thereby obtaining the category detection model.

[0201] As can be seen from the above technical solutions, this application can avoid the influence of digital segments on category detection by masking the digital segments in the speech text. By extracting features from the masked text through the embedding network layer, the receptive field of the text that affects the category of the digital segments can be expanded, thereby improving the representation ability of the text features for category detection of the speech text. By performing attention encoding on the text features through the encoding network layer, the representation ability of the encoding vector can be further improved. By combining the mapping matrix and configuration list of the output network layer to predict the encoding vector, the detection accuracy of the digital category can be further improved. Thus, it is possible to avoid converting all digital segments in the speech text, thereby improving the text conversion accuracy of the target text.

[0202] like Figure 5The diagram shown is a schematic representation of the structure of an electronic device that implements the text processing method of the present invention.

[0203] In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer-readable instructions, such as a text processing program, stored in the memory 12 and executable on the processor 13.

[0204] Those skilled in the art will understand that the schematic diagram is merely an example of electronic device 1 and does not constitute a limitation on electronic device 1. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, electronic device 1 may also include input / output devices, network access devices, buses, etc.

[0205] The processor 13 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor 13 is the computing core and control center of the electronic device 1, connecting various parts of the electronic device 1 through various interfaces and lines, and executing the operating system of the electronic device 1, as well as various installed application programs and program code.

[0206] For example, the computer-readable instructions can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units can be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer-readable instructions in the electronic device 1. For example, the computer-readable instructions can be divided into a positioning unit 110, a masking unit 111, an acquisition unit 112, an extraction unit 113, an encoding unit 114, an input unit 115, a conversion unit 116, and an adjustment unit 117.

[0207] The memory 12 can be used to store the computer-readable instructions and / or modules. The processor 13 implements various functions of the electronic device 1 by running or executing the computer-readable instructions and / or modules stored in the memory 12 and calling the data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. The memory 12 may include non-volatile and volatile memory, such as: hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other storage devices.

[0208] The memory 12 can be the external memory and / or internal memory of the electronic device 1. Furthermore, the memory 12 can be a physical memory, such as a memory module, a TF card (Trans-flash Card), etc.

[0209] If the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by instructing related hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when executed by a processor, the computer-readable instructions can implement the steps of the various method embodiments described above.

[0210] The computer-readable instructions include computer-readable instruction code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer-readable instruction code, recording medium, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), and random access memory (RAM).

[0211] The blockchain referred to in this invention is a novel application model of computer technologies such as distributed text processing, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.

[0212] Combination Figure 2 The memory 12 in the electronic device 1 stores computer-readable instructions to implement a text processing method, and the processor 13 can execute the computer-readable instructions to achieve:

[0213] Locate the position of the digit segment from the acquired speech text;

[0214] The speech text is masked based on the segment position to obtain the masked text.

[0215] Obtain a category detection model, which includes an embedding network layer, an encoding network layer, and an output network layer;

[0216] Based on the embedded network layer, feature extraction is performed on the masked text to obtain text features;

[0217] The text features are subjected to attention encoding based on the encoding network layer to obtain an encoding vector;

[0218] The encoded vector is input into the output network layer to obtain the digit category of the digit segment in the speech text;

[0219] The speech text is converted into text based on the number category to obtain the target text.

[0220] Specifically, the specific implementation method of the processor 13 for the above-mentioned computer-readable instructions can be found in [reference needed]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.

[0221] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0222] The computer-readable storage medium stores computer-readable instructions, which, when executed by the processor 13, are used to perform the following steps:

[0223] Locate the position of the digit segment from the acquired speech text;

[0224] The speech text is masked based on the segment position to obtain the masked text.

[0225] Obtain a category detection model, which includes an embedding network layer, an encoding network layer, and an output network layer;

[0226] Based on the embedded network layer, feature extraction is performed on the masked text to obtain text features;

[0227] The text features are subjected to attention encoding based on the encoding network layer to obtain an encoding vector;

[0228] The encoded vector is input into the output network layer to obtain the digit category of the digit segment in the speech text;

[0229] The speech text is converted into text based on the number category to obtain the target text.

[0230] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0231] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0232] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.

[0233] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices described may also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.

[0234] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A text processing method, applied in an electronic device, characterized in that, The text processing method includes: Locate the position of the digit segment from the acquired speech text; The speech text is masked based on the segment position to obtain the masked text. Obtain a category detection model, which includes an embedding network layer, an encoding network layer, and an output network layer; Based on the embedded network layer, feature extraction is performed on the masked text to obtain text features; The text features are subjected to attention encoding based on the encoding network layer to obtain an encoding vector; The encoding vector is input into the output network layer to obtain the digit category of the digit segment in the speech text, including: mapping the encoding vector based on the mapping matrix in the output network layer to obtain a mapping vector; normalizing the mapping vector to obtain a probability vector, the probability vector including the predicted probability value of the digit segment for each preset label; if at least two of the predicted probability values ​​are greater than a preset probability threshold, the predicted probability values ​​greater than the preset probability threshold are determined as target probability values; based on the probability difference of the target probability values, a target category is selected from the multiple preset labels; if there are multiple target categories, target word segments are extracted from the speech text based on the digit segment; based on the target word segments, the preset label corresponding to the digit segment is obtained from the configuration list of the output network layer as the digit category; The speech text is converted into text based on the number category to obtain the target text.

2. The text processing method as described in claim 1, characterized in that, The step of locating the position of a digital segment from the acquired speech text includes: The speech text is obtained from a translation device that communicates with the electronic device; Obtain all representations of text tags as preset tags from the translation device; Based on all the aforementioned representation forms, the digital segments are selected from the speech text; The position of the segment is located based on the arrangement order of the digital segments in the speech text.

3. The text processing method as described in claim 1, characterized in that, The attention encoding process performed on the text features based on the encoding network layer to obtain the encoding vector includes: Based on the dot product operation between the multiple weight matrices in the coding network layer and the text features, an initial vector corresponding to each weight matrix is ​​obtained; The dot product of any two vectors among the multiple initial vectors is normalized and activated to obtain the vector weights; The score vector is obtained by multiplying the vector weights with the target vector among the multiple initial vectors. Based on the fully connected parameters in the coding network layer, the score vector is processed by a fully connected layer to obtain the coding vector.

4. The text processing method as described in claim 1, characterized in that, The text conversion based on the digital category to obtain the target text includes: If the number category is not a specific category, then obtain the category label corresponding to the number category; Generate replacement statements based on the category labels and the fragment positions; The speech text is updated based on the replacement statement to obtain the target text.

5. The text processing method as described in claim 1, characterized in that, The masking process performed on the speech text based on the segment position to obtain the masked text includes: Obtain the configuration mask identifier from the category detection model; Based on the configured mask identifier, the voice text is masked to obtain the masked text.

6. The text processing method as described in claim 5, characterized in that, The feature extraction of the masked text based on the embedded network layer to obtain text features includes: The masked text is encoded to obtain the representation vector of the masked text; The representation vector is processed based on the dimensionality reduction matrix in the embedded network layer to obtain low-dimensional features; The mask features of the configuration mask identifier are located from the low-dimensional features; Extract the adjacent and non-adjacent features of the mask feature from the low-dimensional features; The adjacent features are then subjected to dimensionality-upgrading processing to obtain high-dimensional features; The text features are obtained by concatenating the high-dimensional features and the non-adjacent features.

7. A text processing device, operating in an electronic device, characterized in that, The text processing device includes: The localization unit is used to locate the position of a digital segment from the acquired speech text. A masking unit is used to perform masking processing on the speech text based on the segment position to obtain masked text; An acquisition unit is used to acquire a category detection model, wherein the category detection model includes an embedding network layer, an encoding network layer, and an output network layer. An extraction unit is used to extract features from the masked text based on the embedded network layer to obtain text features; An encoding unit is used to perform attention encoding processing on the text features based on the encoding network layer to obtain an encoding vector; An input unit is configured to input the encoded vector into the output network layer to obtain the digit category of the digit segment in the speech text, including: mapping the encoded vector based on the mapping matrix in the output network layer to obtain a mapping vector; normalizing the mapping vector to obtain a probability vector, the probability vector including the predicted probability value of the digit segment for each preset label; if at least two of the predicted probability values ​​are greater than a preset probability threshold, determining the predicted probability value greater than the preset probability threshold as a target probability value; selecting a target category from the multiple preset labels based on the probability difference of the target probability values; if there are multiple target categories, extracting target word segments from the speech text based on the digit segment; and obtaining the preset label corresponding to the digit segment from the configuration list of the output network layer as the digit category based on the target word segment. The conversion unit is used to perform text conversion on the speech text based on the number category to obtain the target text.

8. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the text processing method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which are executed by a processor in an electronic device to implement the text processing method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Chinese sentence semantic intelligent matching method and device based on multi-granularity fusion model

    CN111310438A

  • Text classification method and device

    CN112528020A