Data processing method, device, equipment and readable storage medium

By adding constraint tags and mapping styles in rich-style text translation, the problem of being unable to preserve text format in the existing technology is solved, and the completeness and accuracy of translation are improved.

CN114417898BActive Publication Date: 2024-08-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210058761.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-18
Publication Date
2024-08-23
Estimated Expiration
2042-01-18

AI Technical Summary

Technical Problem

The existing technology cannot completely preserve the text format when translating rich-style text, resulting in low data processing accuracy.

Method used

By obtaining the position of the target source words in the rich-style text data, adding constraint tags, and mapping the styles in the source text data to the target text data based on the correspondence between these tags and words, ensuring that the translated text contains the original styles.

Benefits of technology

It achieves the preservation of text format during text translation and improves the integrity and accuracy of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114417898B
    Figure CN114417898B
Patent Text Reader

Abstract

The embodiment of the present application discloses a data processing method, device, equipment and readable storage medium, which relates to the field of artificial intelligence, wherein the method includes: obtaining rich-style source text data, the source text data is rich-style text data; obtaining the word position of the target source word in the source text data, adding a first constraint tag in the source text data based on the word position, and the style of the target source word is the target source style; based on the correspondence between the source text data and the words after adding the first constraint tag, obtaining the target text data with the second constraint tag added, the second constraint tag is added at the word position of the target word in the target text data; based on the first constraint tag and the second constraint tag, mapping the target source style to the target style of the target word corresponding to the second constraint tag, so as to obtain the target text data containing the target style. By adopting the embodiment of the present application, the text translation can be made more complete and the accuracy of data processing can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing in artificial intelligence, and in particular to a data processing method, apparatus, device and readable storage medium. Background Art

[0002] Text translation has been widely used in various fields and has made great progress to a certain extent. However, for rich-style text, that is, some sentences or words in the text contain multiple formats, such as different colors, bold text, underline format, etc. When translating such rich-style text, currently only the text content in the text can be translated, and the format in the text cannot be fully retained, which reduces the integrity of the text translation and leads to low data processing accuracy. Summary of the invention

[0003] The embodiments of the present application provide a data processing method, apparatus, device and readable storage medium, which can make text translation more complete and improve data processing accuracy.

[0004] In a first aspect, the present application provides a data processing method, comprising:

[0005] Get source text data, where the source text data is rich-style text data;

[0006] Obtaining a word position of a target source word in the source text data, adding a first constraint tag to the source text data based on the word position of the target source word, and the style of the target source word is the target source style;

[0007] Based on the correspondence between the source text data and the words after adding the first constraint tag, the target text data with the second constraint tag added is obtained, the target text data is obtained by translating the source text data, the second constraint tag is added at the word position of the target word in the target text data, and the target word is the word corresponding to the target source word;

[0008] The target source style is mapped to a target style of a target word corresponding to the second constraint tag based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

[0009] In a second aspect, the present application provides a data processing device, including:

[0010] A text acquisition module is used to acquire source text data, where the source text data is rich-style text data;

[0011] A first adding module is used to obtain the word position of the target source word in the source text data, and add a first constraint tag to the source text data based on the word position of the target source word, and the style of the target source word is the target source style;

[0012] A second adding module is used to obtain target text data with a second constraint label added thereto based on the correspondence between the source text data and the words after the first constraint label is added thereto, wherein the target text data is obtained by translating the source text data, and the second constraint label is added at the word position of the target word in the target text data, and the target word is a word corresponding to the target source word;

[0013] The data mapping module is used to map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

[0014] In a third aspect, the present application provides a computer device, including: a processor, a memory, and a network interface;

[0015] The processor is connected to a memory and a network interface, wherein the network interface is used to provide a data communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that a computer device including the processor executes the data processing method.

[0016] In a fourth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the above-mentioned data processing method.

[0017] In a fifth aspect, the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data processing method provided in various optional manners in the first aspect of the present application.

[0018] In an embodiment of the present application, by obtaining source text data with rich styles, and obtaining the word positions of target source words with target source styles in the source text data, a first constraint tag can be added to the source text data based on the word positions of the target source words; based on the correspondence between the source text data and words after adding the first constraint tag, the target text data with the second constraint tag added can be obtained, thereby mapping the target source style to the target style of the target words corresponding to the second constraint tag based on the first constraint tag and the second constraint tag, so as to obtain the target text data containing the target style. Since the position information of the target source words with source styles in the source text data is determined, constraint tags can be added to the source text data based on the position information of the target source words in the source text data, thereby obtaining the target text data with constraint tags based on the correspondence between the source text data and words after adding the constraint tags, and mapping the source style in the source text data to the target style in the target text data based on the constraint tags, so that the translated target text data can contain the target style, thereby achieving the retention of the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 It is a schematic diagram of the architecture of a data processing system provided in an embodiment of the present application;

[0021] Figure 2 It is a schematic diagram of an application scenario of a data processing method provided in an embodiment of the present application;

[0022] Figure 3 It is a flowchart of a data processing method provided in an embodiment of the present application;

[0023] Figure 4 It is a flowchart of another data processing method provided in an embodiment of the present application;

[0024] Figure 5 is a schematic diagram of a word correspondence relationship provided in an embodiment of the present application;

[0025] Figure 6 is a schematic diagram of another word correspondence relationship provided in an embodiment of the present application;

[0026] Figure 7 It is a schematic diagram of dividing empty words provided in an embodiment of the present application;

[0027] Figure 8 It is a schematic diagram of a model structure provided in an embodiment of the present application;

[0028] Fig. 9 It is a schematic diagram of the composition structure of a data processing device provided in an embodiment of the present application;

[0029] Fig.10 It is a schematic diagram of the composition structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0031] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0032] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0033] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.

[0034] The data related to user information in the embodiments of the present application are all data authorized by the user. The present application relates to natural language processing technology and machine learning technology in the field of artificial intelligence. Optionally, for example, natural language processing technology can be used to translate the source text data to obtain the target text data. Further, the present application can also use machine learning technology to translate the source text data to obtain the target text data; it can also use machine learning technology based on the correspondence between the source text data and the words after adding the first constraint tag to obtain the target text data with the second constraint tag added, and map the target source style to the target style of the target word to obtain the target text data containing the target style, and so on. The technical solution of the present application can be used to translate the rich-style source text data to obtain the rich-style target text data, for example, it can be applied to the translation of rich-style text data in bilingual teaching, the translation of rich-style text data in language testing, the translation of rich-style text data containing professional terms in the medical field, or other scenarios where rich-style text data needs to be translated. Since the position information of the target source words with the source style in the source text data is determined, constraint labels can be added to the source text data based on the position information of the target source words in the source text data, so as to obtain the target text data with the constraint labels based on the correspondence between the source text data and the words after adding the constraint labels. The source style in the source text data is mapped to the target style in the target text data based on the constraint labels, so that the target style can be included in the translated target text data, thereby achieving the goal of retaining the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing.

[0035] The rich-style text data refers to certain sentences or words in the text data that contain multiple formats, such as different colors, bold text, underline, and other formats.

[0036] See also Figure 1 , Figure 1 is a schematic diagram of the architecture of a data processing system provided in an embodiment of the present application, such as Figure 1As shown, the computer device 101 can exchange data with the user terminal, and the number of the user terminal can be one or more (at least two). For example, when the number of the user terminal is multiple, the user terminal may include Figure 1 The user terminal 102a, user terminal 102b and user terminal 102c in the computer device 101 are as follows. Taking the user terminal 102a as an example, the computer device 101 can obtain the source text data from the user terminal 102a. Further, the computer device 101 can obtain the word position of the target source word in the source text data, add a first constraint tag in the source text data based on the word position, and the style of the target source word is the target source style. Further, the computer device 101 can obtain the target text data with the second constraint tag added based on the correspondence between the source text data and the words after adding the first constraint tag, and map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain the target text data containing the target style. Optionally, the computer device 101 can send the target text data containing the target style to the user terminal 102a, so that the user terminal 102a renders and displays the target text data containing the target style.

[0037] Since the position information of the target source words with the source style in the source text data is determined, constraint labels can be added to the source text data based on the position information of the target source words in the source text data, so as to obtain the target text data with the constraint labels based on the correspondence between the source text data and the words after adding the constraint labels, and the source style in the source text data is mapped to the target style in the target text data based on the constraint labels, so that the target style can be included in the translated target text data, thereby achieving the goal of retaining the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing.

[0038] It is understandable that the computer devices mentioned in the embodiments of the present application include but are not limited to user terminals or servers. In other words, the computer device can be a server or a user terminal, or a system composed of a server and a user terminal. Among them, the user terminal mentioned above can be an electronic device, including but not limited to mobile phones, tablet computers, desktop computers, laptop computers, PDAs, vehicle-mounted devices, intelligent voice interaction devices, augmented reality / virtual reality (AR / VR) devices, helmet displays, wearable devices, smart speakers, smart home appliances, aircraft, digital cameras, cameras and other mobile Internet devices (mobile internet device, MID) with network access capabilities. Among them, the server mentioned above can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, vehicle-road collaboration, content distribution networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0039] For further information, see Figure 2 , Figure 2 Schematic diagram of an application scenario of a data processing method provided in an embodiment of the present application. Figure 2As shown, the user terminal 21 can send source text data 22 to the computer device 23, wherein the source text data 22 is rich-style text data. For example, the source text data is "Go to the amusement park tomorrow", wherein the word "amusement park" in the source text data is a rich-style word, for example, the style includes bold font and underline. Further, the computer device 23 can obtain the word position of the target source word in the source text data, such as the word position of "amusement park" in the source text data, and add a first constraint tag to the source text data based on the word position. The source text data after adding the first constraint tag is shown in 24, wherein the style of the target source word "amusement park" is the target source style, for example, the target source style is bold font and underline. Further, the computer device 23 can obtain the target text data with the second constraint tag added based on the correspondence between the source text data and the words after adding the first constraint tag. The target text data with the second constraint tag is shown in 25. The target text data is obtained by translating the source text data 22. Based on the first constraint tag and the second constraint tag, the target source style is mapped to the target style of the target word to obtain the target text data 26 containing the target style, wherein the target word is the word corresponding to the target source word. Optionally, the computer device can also send the target text data 26 containing the target style to the user terminal 21 so that the user terminal 21 renders and displays the target text data 26 containing the target style.

[0040] For further information, see Figure 3 , Figure 3 is a flow chart of a data processing method provided in an embodiment of the present application; Figure 3 As shown, the data processing method can be applied to a computer device, and the data processing method includes but is not limited to the following steps:

[0041] S101, obtaining source text data.

[0042] In the embodiment of the present application, the computer device can obtain the source text data from the user terminal, or from the text database storing the source text data, or from other paths. Wherein, the source text data is rich-style text data. The source text data may include but is not limited to text data in the field of teaching, text data in the field of medicine, or text data in other fields. The source text data may include but is not limited to Chinese, English, Korean, German or other language data. It is understandable that in the specific implementation of the present application, if the source text data involves relevant data such as user information, the source text data obtained by the computer device is the data authorized by the user. When the above embodiments of the present application are applied to specific products or technologies, it is necessary to obtain user permission or consent, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0043] S102, obtaining the word position of the target source word in the source text data, and adding a first constraint tag to the source text data based on the word position.

[0044] In an embodiment of the present application, a computer device can obtain the word position of a target source word in source text data, and add a first constraint tag to the source text data based on the word position. Among them, the style of the target source word is the target source style. The word position of the target source word can refer to the position of the word contained in the target source word in the source text data, for example, it can be a word sequence number. Since the word position of the target source word is determined, a first constraint tag can be added to the source text data based on the word position. For example, a first constraint tag can be added to the front and back positions of the target source word, that is, a first constraint tag is added to the position between the target source word and the previous word, and a first constraint tag is added to the position between the target source word and the next word. The first constraint tag is used to indicate the target source word.

[0045] like Figure 2 As shown, for example, the source text data is 22, the target source word in the source text data is "amusement park", and the text data obtained by the computer device after adding the first constraint tag to the source text data is 24, where " <b1> ”、" <e1>" indicates the first constraint tag.

[0046] Optionally, if there are at least two target source words in the source text data, the computer device can respectively obtain the word position of each target source word, and add a first constraint tag to the source text data based on the word position of each target source word, thereby realizing the display of each target source word with style in the source text data.

[0047] Optionally, the computer device can obtain the semantic scene where the source text data is located, determine the priority of each target source word in the source text data based on the semantic scene, obtain the word position of the target source word with a priority greater than the level threshold in the source text data, and add a first constraint tag in the source text data based on the word position of the target source word with a priority greater than the level threshold, thereby preferentially displaying the target source word with a priority greater than the level threshold. In other words, based on the semantic scene where the source text data is located, the computer device can determine the priority of multiple source words with styles in the semantic scene, thereby displaying the target source words according to the priority level. For example, the computer device can display each source word with a style in turn according to the priority and the target time interval. The data display method is more flexible, and it can highlight the key points in the text data and improve the user experience.

[0048] S103, based on the correspondence between the source text data after the first constraint tag is added and the words, the target text data after the second constraint tag is added is obtained.

[0049] In the embodiment of the present application, the target text data is obtained by translating the source text data. It can be understood that translating the source text data here means translating the words in the source text data. The target word is the word corresponding to the target source word.

[0050] Optionally, the computer device can process the source text data after adding the first constraint tag based on the target processing model to obtain the target text data after adding the second constraint tag. That is to say, the computer device inputs the source text data after adding the first constraint tag into the target processing model, processes the data through the target processing model, and while translating the source text data to generate the target text data, the second constraint tag can be added to the word position of the target word in the target text data, so that the target text data with the second constraint tag can be output through the target processing model. The target text data with the second constraint tag can be Figure 2 25, where " <b1> ”、" <e1>" indicates the second constraint tag.

[0051] Specifically, the target processing model can translate the source text data after adding the first constraint tag to obtain the target text data, and at the same time add the second constraint tag to the target text data, thereby obtaining the target text data with the second constraint tag added. In other words, the second constraint tag can also be considered to be obtained by "translating" the first constraint tag, that is, when translating the source text data, not only the source text data is translated but also the first constraint tag is translated, thereby obtaining the target text data with the second constraint tag added.

[0052] Optionally, the method for the target processing model to add a second constraint label to the target text data may include: obtaining the correspondence between words in the source text data and words in the target text data, determining the target words in the target text data corresponding to the target source words based on the correspondence between the words, and thereby adding the second constraint label to the target text data based on the word position of the target words in the target text data. In other words, the target processing model has the ability to translate the source text data, and determine the correspondence between words in the source text data and words in the translated text data corresponding to the source text data. In a specific implementation, the computer device may acquire a large amount of sample data in advance to train the target processing model, so that the target processing model has the ability to determine the correspondence between words in the source text data and words in the translated text data corresponding to the source text data. Among them, the method for training the target processing model can refer to Figure 4 The corresponding embodiments are not described in detail here. By using the target processing model to process text data, the efficiency of data processing can be improved. Since the target processing model is trained in advance, the accuracy of data processing can be improved by using the trained model to process text data.

[0053] In a possible implementation, the computer device may also translate the source text data to obtain the target text data, align the source text data and the target text data, and thereby determine the correspondence between the words in the source text data and the words in the target text data. By aligning the source text data and the target text data, it is subsequently possible to determine which words in the target text data the words in the source text data correspond to based on the correspondence, and then determine at which positions in the target text data to add the second constraint label. Optionally, the computer device may perform word segmentation processing on the source text data and the target text data, obtain the word correspondence between each word in the source text data and each word in the target text data, and then determine the word correspondence between each word in the source text data and the words in the target text data based on the word correspondence between the words, thereby determining whether the source text data and the target text data are aligned, and if the source text data and the target text data are aligned, the alignment relationship is determined as the correspondence between the words in the source text data and the words in the target text data. It can be understood that if the text data is in Chinese, the words in the text data may include single characters, words, idioms or punctuation marks in the text data, etc.; if the text data is in English, the words may include every English word or punctuation mark in the text data, etc.

[0054] Optionally, the computer device can use the alignment consistency principle to judge the words in the source text data and the words in the target text data, and determine whether the words in the source text data and the words in the target text data are aligned. If the words in the source text data and the words in the target text data are aligned, the computer device can also obtain the key words in the source text data and the key words in the target text data, and determine whether the key words in the source text data and the key words in the target text data are aligned based on the matching between the key words in the source text data and the key words in the target text data. Further optionally, if the key words in the source text data and the key words in the target text data are aligned, the computer device can also detect whether there are empty words in the source text data or the target text data, and if there are no empty words, it is determined that the source text data and the target text data are aligned. If there is a null word, the null word is added to the front neighbor words and the back neighbor words adjacent to the null word respectively, and it is determined that the null word belongs to the front neighbor words or the back neighbor words. Based on the neighbor words to which the null word belongs, the correspondence between the words in the source text data and the words in the target text data is adjusted so that the words in the source text data and the words in the target text data are aligned, and the alignment relationship is determined as the correspondence between the words in the source text data and the words in the target text data.

[0055] Optionally, in the embodiment of the present application, other methods may be used to determine whether the source text data and the target text data are aligned. After determining that the source text data and the target text data are aligned, the computer device may obtain key words in the source text data and match them with key words in the target text data, and determine the correspondence between words in the source text data and words in the target text data based on the key word matching relationship. Optionally, after determining that the source text data and the target text data are aligned, the computer device may detect whether there are empty words in the source text data or the target text data, and if there are empty words in the source text data or the target text data, divide the empty words in the source text data or the target text data, thereby dividing the empty words into corresponding combination words, and adjusting the correspondence between words in the source text data and words in the target text data based on the obtained combination words.

[0056] It can be understood that if the source text data and the target text data are not aligned, and the computer device does not need to perform subsequent processing, that is, the computer device has not determined the correspondence between the words in the source text data and the words in the target text data, then no subsequent processing is required; alternatively, the computer device can re-acquire the target text data corresponding to the source text data, and perform alignment processing based on the re-acquired target text data and the source text data to determine the correspondence between the words in the source text data and the words in the target text data.

[0057] S104: Map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

[0058] In the embodiment of the present application, the computer device can map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain the target text data containing the target style. Specifically, since the computer device can determine the correspondence between the words in the source text data and the words in the target text data, it can determine the target source words in the source text data and the corresponding words in the target text data, that is, the target words, then it can be determined to add the second constraint tag to the word position of the target word in the target text data. In other words, the word indicated by the second constraint tag is the target word, and the target word has a corresponding relationship with the target source word. That is to say, since the computer device can determine the target word corresponding to the target source word in the target text data based on the correspondence between the target source word and the words, the computer device can obtain the position information of the target word in the target text data, add the second constraint tag in the target text data based on the position information of the target word in the target text data, and map the target source style of the target source word to the target style of the target word based on the first constraint tag and the second constraint to obtain the target text data containing the target style.

[0059] like Figure 2 As shown, the computer device is based on the correspondence between the source text data 24 and the words after adding the first constraint tag. For example, the correspondence between the words includes the correspondence between the target source word "amusement park" in the source text data 22 and the target word "amusement park". Then the computer device adds the second constraint tag to the word position of the target word in the target text data to obtain the text data 25. After the computer device maps the target source style (bold and underline) corresponding to the first constraint tag to the target style (bold and underline) corresponding to the second constraint tag, the target text data 26 containing the target style is obtained.

[0060] Optionally, the computer device may also obtain user physiological characteristic data or user historical text display data, determine a style mapping relationship based on the user physiological characteristic data or the user historical text display data, and map the target source style to the target style of the target word based on the style mapping relationship. Among them, the user physiological characteristic data and the user historical text display data are both data authorized by the user. The user physiological characteristic data may include but is not limited to the user's preferences or whether the user has visual impairments, such as red and green color blindness, etc. The user historical text display data may refer to the user's commonly used styles in a historical time period. The style mapping relationship may include a mapping relationship between two identical styles or a mapping relationship between two different styles. If the style determined by the computer device based on the user physiological characteristic data or the user historical text display data is the same as the style of the target source word in the source text data, then the style mapping relationship represents the mapping relationship between the two identical styles, that is, the styles before and after the mapping are the same, for example, the target source style includes red and underline, and the target style obtained after mapping also includes red and underline. If the style determined by the computer device based on the user's physiological characteristic data or the user's historical text display data is different from the style of the target source word in the source text data, then the style mapping relationship represents the mapping relationship between two different styles, that is, the styles before and after mapping are different. For example, the target source style includes red and underline, and the target style obtained after mapping also includes purple and bold, and so on.

[0061] Since the styles in the target text data can be displayed in a targeted manner based on the user's physiological characteristics data and the user's historical text display data, the translated target text data can be displayed in a personalized manner. For example, if the user has a visual impairment, such as red-green color blindness, or the user prefers a certain style, this data display method is more flexible and can achieve personalized display, thereby improving the user experience.

[0062] Optionally, the computer device may also obtain a user selection instruction, determine a style mapping relationship based on the user selection instruction, and map the target source style to the target style of the target word based on the style mapping relationship. The user selection instruction includes a style selected by the user. In a specific implementation, the computer device may output at least one style through a user terminal, and the user may select a desired reference style from at least one style. When the user selects a reference style, the user selection instruction is triggered, and the computer device responds to the user selection instruction, determines a style mapping relationship based on the reference style selected by the user, and maps the target source style to the target style of the target word based on the style mapping relationship. Since the style in the target text data can be displayed in a targeted manner according to the user's selection, the data display method is more flexible and can achieve personalized display.

[0063] Optionally, in a possible implementation, the target processing model may also obtain source text data with rich styles; obtain the word position of the target source word in the source text data, and add a first constraint tag to the source text data based on the word position; based on the correspondence between the source text data and the words after adding the first constraint tag, add a second constraint tag to the word position of the target word in the target text data, and map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style. That is, in this implementation, the computer device may input the source text data with rich styles into the target processing model, add the first constraint tag to the source text data with rich styles based on the target processing model, and finally output the target text data containing the target style.

[0064] Optionally, the computer device can also render the target text data based on the target style of the target word to obtain the rendered target text data containing the target style; call the associated user terminal to output the rendered target text data containing the target style. If the computer device is a user terminal, the computer device can directly output the rendered target text data containing the target style; if the computer device is a server, the computer device can call the user terminal associated with the computer device to output the rendered target text data containing the target style. Optionally, the computer device can also call the associated user terminal to output the source text data. Optionally, the computer device can also send the rendered target text data containing the target style to other user terminals so that other user terminals output the target text data containing the target style. By rendering and outputting the target text data, the style corresponding to the source style in the source text data can be intuitively viewed in the target text data, thereby realizing the output of the source text data and the target text data containing the style, which is convenient for corresponding viewing. The user does not need to perform semantic search in the target text data according to the words containing the style in the source text data, which can improve the data viewing efficiency and thus improve the user experience.

[0065] In the embodiment of the present application, by obtaining the source text data with rich style, and obtaining the word position of the target source word with the target source style in the source text data, a first constraint tag can be added to the source text data based on the word position of the target source word; based on the correspondence between the source text data and the words after adding the first constraint tag, a second constraint tag can be added to the word position of the target word in the target text data obtained by translating the source text data, so as to map the target source style to the target style of the target word corresponding to the second constraint tag based on the first constraint tag and the second constraint tag, so as to obtain the target text data containing the target style. Since the position information of the target source word with the source style in the source text data is determined, the constraint tag can be added to the source text data based on the position information of the target source word in the source text data, so as to add the constraint tag to the word position of the corresponding target word in the target text data based on the correspondence between the source text data and the words after adding the constraint tag, and the source style in the source text data is mapped to the target style in the target text data based on the constraint tag, so that the translated target text data can contain the target style, thereby realizing the retention of the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing.

[0066] Optional, see Figure 4 , Figure 4 is a flow chart of another data processing method provided in an embodiment of the present application. The data processing method can be applied to a computer device; Figure 4 As shown, the data processing method includes but is not limited to the following steps:

[0067] S201, obtaining first sample data and second sample data.

[0068] In an embodiment of the present application, the method for a computer device to obtain the first sample data and the second sample data can refer to the method for obtaining the source text data in step S101, which is not described in detail here. Alternatively, the computer device can download a large number of bilingual corpus sample data sets from a database, and a large number of bilingual corpus sample data sets include the first sample data and the second sample data. The first sample data is rich-style text data, and the first sample data may include but is not limited to text data in the field of teaching, text data in the field of medicine, or text data in other fields. The second sample data is the translated text data of the first sample data, and the first sample data and the second sample data are text data in two different languages. It can be understood that if the first sample data and the second sample data involve data related to user information, the first sample data and the second sample data are both data authorized by the user, that is, the collection, use and processing of the first sample data and the second sample data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0069] S202: Perform alignment processing on the first sample data and the second sample data to determine a sample correspondence relationship between sample words in the first sample data and sample words in the second sample data.

[0070] In the embodiment of the present application, the computer device may perform alignment processing on the first sample data and the second sample data, so as to determine the sample correspondence relationship between the sample words in the first sample data and the sample words in the second sample data. By performing alignment processing on the first sample data and the second sample data, it is subsequently possible to determine which sample word in the second sample data the sample word in the first sample data corresponds to based on the sample correspondence relationship, so as to facilitate the subsequent mapping of the first style of the sample word in the first sample data to the second style of the sample word in the second sample data.

[0071] Optionally, the computer device may perform word segmentation processing on the first sample data and the second sample data to determine whether the first sample data and the second sample data are aligned. Specifically, the computer device may perform word segmentation processing on the first sample data and the second sample data to obtain a first correspondence between N first words and M second words, wherein the first word is any word in the first sample data, the second word is any word in the second sample data, N and M are both positive integers, and the first correspondence may refer to a correspondence between words; based on the first correspondence between the N first words and the M second words, determine a second correspondence between i first words and j second words, the first word is a word composed of at least one word in the N first words, the second word is a word composed of at least one word in the M second words, i is a positive integer less than or equal to N, j is a positive integer less than or equal to M, and the second correspondence may refer to a correspondence between words; based on the second correspondence, determine whether the first sample data and the second sample data are aligned. Further, if the first sample data and the second sample data are aligned, the alignment relationship is used as a sample correspondence between the sample words in the source text data and the sample words in the target text data.

[0072] It can be understood that, if the first sample data is in Chinese, the first word may include single characters, words, idioms or punctuation marks in the first sample data, etc.; if the second sample data is in Chinese, the second word may include single characters, words, idioms or punctuation marks in the second sample data, etc.; if the first sample data is in English, the first word may include each English word or punctuation mark in the first sample data, etc.; if the second sample data is in English, the second word may include each English word or punctuation mark in the second sample data, etc.

[0073] Optionally, the computer device may use a word alignment toolkit to align the first sample data and the second sample data. The word alignment toolkit may include but is not limited to fast_align (fast word alignment toolkit) and giza++ (a word alignment tool). By using the word alignment toolkit to align the first sample data and the second sample data, a word alignment matrix may be obtained. The word alignment matrix is ​​used to represent the first correspondence between words in the two sets of data in a matrix manner. Based on the word alignment matrix, the first correspondence between words in the first sample data and words in the second sample data can be determined. For example, the first sample data is "Go to amusement park to playtomorrow", and the second sample data is "Go to the amusement park tomorrow". After processing through the word alignment toolkit, the word alignment matrix [0-1 1-1 2-2 3-2 4-3 5-3 6-0] is output. Based on the word alignment matrix, it can be determined that "Go" corresponds to "go", "amusement" and "park" correspond to "amusement park", "play" corresponds to "play", and "tomorrow" corresponds to "tomorrow", thereby determining the second correspondence between the first word and the second word based on the first correspondence between the first word and the second word. For example, since "amusement" and "park" both correspond to "amusement park", the first word "amusement park" corresponds to the second word "amusement park". For example Figure 5 As shown, Figure 5 is a schematic diagram of a word correspondence relationship provided by an embodiment of the present application, wherein a gray circle 51 represents a first word in the first sample data, and a gray circle 52 represents a second word in the second sample data. Figure 5 The second corresponding relationship between the first word and the second word can be represented in .

[0074] Optionally, after acquiring the second corresponding relationship, the computer device may use the alignment consistency principle to determine whether the first word and the second word are aligned. Specifically, the computer device may use the alignment consistency principle to determine whether the first target word and the second target word are aligned, wherein the first target word is any one of the i first words, and the second target word is any one of the j second words, and the alignment consistency principle is used to indicate whether a word composed of multiple consecutive words in the first sample data corresponds to a word composed of multiple consecutive words in the second sample data; if the first target word and the second target word are aligned, it is determined that the first sample data and the second sample data are aligned; if the first target word and the second target word are not aligned, it is determined that the first sample data and the second sample data are not aligned.

[0075] In a specific implementation, since the computer device obtains the second correspondence between the i first words in the first sample data and the j second words in the second sample data, the computer device can obtain the first word composed of a plurality of consecutive words in the first sample data, and determine whether a second word composed of a plurality of consecutive words in the second sample data corresponds to the first word based on the word correspondence relationship. If a second word composed of a plurality of consecutive words in the second sample data corresponds to the first word, it is determined that the first sample data and the second sample data are aligned, such as Figure 5 If there is a first word consisting of multiple discontinuous words in the first sample data that corresponds to a second word consisting of multiple continuous words in the second sample data, it is determined that the first sample data and the second sample data are not aligned, such as Figure 6 As shown, Figure 6 6 is a schematic diagram of another word correspondence provided by an embodiment of the present application, wherein a gray circle 61 represents a first word in the first sample data, and a gray circle 62 represents a second word in the second sample data. Since there is a word (a white dotted circle) in the second sample data that corresponds to a word (a white dotted circle) other than the first word in the first sample data, it is determined that the first sample data and the second sample data are not aligned consistent bilingual words as a whole, and therefore it is determined that the first sample data and the second sample data are not aligned.

[0076] It can be understood that in the embodiment of the present application, the alignment consistency principle is used to judge any one of the i first words and any one of the j second words, and determine whether any one of the i first words is aligned with any one of the j second words. When each word in the i first words is aligned with the words in the j second words, it is determined that the first sample data and the second sample data are aligned. If one or more words in the i first words are not aligned with the words in the j second words, it is determined that the first sample data and the second sample data are not aligned. Since a large amount of sample data is used for training when training the model, that is, the number of the first sample data and the second sample data are both multiple, when there is a first sample data and the translation text data (that is, the second sample data) corresponding to the first sample data are not aligned, the computer device can delete the first sample data and the second sample data, that is, delete the error data in the sample data, so that the model training result is more accurate and the model training efficiency is improved.

[0077] Optionally, if the first target word and the second target word are aligned, the computer device may also obtain a keyword from the first sample data and obtain a keyword from the second sample data for matching, thereby determining whether the first sample data and the second sample data are aligned. Specifically, the computer device may obtain a first keyword from the first sample data and a second keyword from the second sample data; match the first keyword and the second keyword; if the first keyword and the second keyword match, the computer device may determine that the first sample data and the second sample data are aligned.

[0078] The first keyword may be used to indicate the meaning of the first sample data, and the second keyword may be used to indicate the meaning of the second sample data. For example, if the first sample data is "go to the amusement park tomorrow", the first keyword may include "amusement park", "tomorrow", etc. Matching the first keyword and the second keyword may refer to matching the meanings of the first keyword and the second keyword. If the meanings of the first keyword and the second keyword are the same, it means that the first keyword and the second keyword match; if the meanings of the first keyword and the second keyword are different, it means that the first keyword and the second keyword do not match.

[0079] For example, if the first sample data is "Spend a lot of time and energy and resources", and the second sample data is "Spend a lot of money, energy and resources", the first keyword may include "energy and resources" and "time", and the second keyword may include "energy and resources" and "money". Since "energy and resources" and "energy and resources" match, but "time" and "money" do not match, it means that the first keyword and the second keyword do not match, and it is determined that the first sample data and the second sample data are not aligned, then the computer device can delete the first sample data and the second sample data, that is, delete the error data in the sample data, so that the model training result is more accurate and the model training efficiency is improved. If the first keyword and the second keyword match, it is determined that the first sample data and the second sample data are aligned, then the computer device can use the alignment relationship as a sample correspondence relationship between the sample words in the first sample data and the sample words in the second sample data. Optionally, the computer device can use a keyword extraction tool to obtain keywords in the first sample data and the second sample data, and the keyword extraction tool includes but is not limited to rake-nltk (keyword automatic extraction module) and ckpe (a tool for quickly extracting and identifying key phrases from natural language text).

[0080] It is understandable that the first sample data may include multiple first keywords, and the second sample data may include multiple second keywords. If each first keyword in the first sample data matches the second keyword in the second sample data, it is determined that the first sample data and the second sample data are aligned. If one or more first keywords in the first sample data do not match the second keywords in the second sample data, it is determined that the first sample data and the second sample data are not aligned. Since the first keyword and the second keyword are further obtained to determine whether the first sample data and the second sample data are aligned based on the alignment consistency principle to determine whether the sample data are aligned, the accuracy of data alignment can be further improved, thereby improving the accuracy of model training.

[0081] Optionally, if the first target word and the second target word are aligned, the computer device may also detect whether there is a null word in the first sample data or the second sample data, and adjust the sample correspondence between the first sample data and the second sample data based on the null word. Specifically, if there is a null word in the sample data, the null word is added to the first neighbor word and the second neighbor word respectively to obtain a first combination word and a second combination word, wherein the first neighbor word and the second neighbor word are two words adjacent to the null word in the sample data, and the sample data is any one of the first sample data and the second sample data; determine the target combination word from the first combination word or the second combination word; and adjust the sample correspondence between the sample words in the first sample data and the sample words in the second sample data based on the target combination word. Wherein, the null word may indicate that a certain word in the first sample data does not correspond to each word in the second sample data, or the null word may indicate that a certain word in the second sample data does not correspond to each word in the first sample data. Optionally, the computer device may execute the step of detecting whether there are empty words in the first sample data or the second sample data after executing the step of determining whether key words in the first sample data and key words in the second sample data are aligned; or, the computer device may execute the step of determining whether key words in the first sample data and key words in the second sample data are aligned after executing the step of detecting whether there are empty words in the first sample data or the second sample data; or, the computer device may also execute both steps at the same time, which is not limited to this embodiment of the present application.

[0082] Optionally, in the embodiment of the present application, other methods may be used to determine whether the first sample data and the second sample data are aligned. After determining that the first sample data and the second sample data are aligned, the computer device may obtain a first keyword in the first sample data and a second keyword in the second sample data for matching, and determine a sample correspondence relationship between sample words in the first sample data and sample words in the second sample data based on the keyword matching relationship. Optionally, after determining that the first sample data and the second sample data are aligned, the computer device may detect whether there are empty words in the first sample data or the second sample data, and if there are empty words in the first sample data or the second sample data, divide the empty words in the source first sample data or the second sample data, thereby dividing the empty words into corresponding combination words, and adjusting the sample correspondence relationship between the sample words in the first sample data and the sample words in the second sample data based on the obtained combination words.

[0083] Optionally, after determining that the first sample data and the second sample data are not aligned, the computer device may further receive a correction request for the second sample data sent by the correction terminal, correct the second sample data based on the correction request, and align the corrected second sample data with the first sample data to determine a sample correspondence between sample terms in the first sample data and sample terms in the second sample data. The correction terminal may adjust the words or terms in the second sample data, and the correction request may include the words or terms that need to be corrected.

[0084] Since the first target word and the second target word are aligned through the alignment consistency principle in the foregoing steps, if it is detected that there is a null word in the first sample data or the second sample data, the computer device can divide the null word into its neighboring words, so as to realize the correspondence between each word in the first sample data and each word in the second sample data. For example, the first sample data is "On July 16 local time, Zhang San Yong in city A", and the second sample data is "当地时间7月16日,张三勇在A市". After aligning the first sample data and the second sample data, a word alignment matrix [0-5 1-2 2-4 3-0 4-1 5-6 6-7 7-7 8-7 9-9 10-10 11-10] is obtained. Among them, some alignment relationships in the word alignment matrix are "6-7 7-7 8-7", indicating that "Zhang San Yong" all corresponds to "张三". However, there is no word in the first sample data corresponding to "勇", which means that "勇" is a null word. Then the computer device can add "勇" to the first neighboring word "张三" and the second neighboring word "在" respectively, to obtain the first combined word "张三勇" and the second combined word "勇在". Further, the computer device can determine the target combined word from the first combined word or the second combined word based on the target dictionary. For example, if the target combined word is "张三勇", the computer device adjusts the sample correspondence relationship between the sample words in the first sample data and the sample words in the second sample data based on the target combined word. For example, before adjustment, "Zhang San Yong" all corresponds to "张三", and there is no word in the first sample data corresponding to "勇". After adjustment, "Zhang San Yong" corresponds to "张三勇". It can be understood that there is no null word in the sample text data after adjusting the sample correspondence relationship. The target dictionary can refer to a pre-set dictionary, which includes at least one single-character word, word, idiom, allegorical saying, name, place name, and so on.

[0085] As Figure 7 shown, Figure 7 Figure 7 is a schematic diagram of null word division provided by an embodiment of the present application. It can be seen that after the first sample data and the second sample data are aligned, there is a null word 70 in the second sample data, and there is no word in the first sample data corresponding to the null word 70 (the connection lines in the figure can represent the correspondence relationship between words). Then the computer device can add the null word 70 to the first neighboring word 73 and the second neighboring word 74 respectively, and determine the target combined word from the first combined word or the second combined word. For example, if the target combined word includes the first combined word 73 and the null word 70, the corresponding relationship after division is as shown in 75. It can be understood that Figure 7 It is a process performed on a certain empty word in the first sample data or the second sample data. If there are multiple empty words, the multiple empty words can be processed with reference to this method, and the multiple empty words can be divided into corresponding neighbor words, thereby adjusting the sample correspondence between the first sample data and the second sample data.

[0086] S203 , obtaining a sample word position of a first sample word in the aligned first sample data, and adding a first sample constraint label to the first sample data based on the sample word position.

[0087] In an embodiment of the present application, a computer device can obtain the sample word position of the first sample word in the aligned first sample data, and add a first sample constraint label in the first sample data based on the sample word position, and the style of the first sample word is the first style. The sample word position may refer to the position of the sample word contained in the first sample word in the first sample data, for example, it may be the sample word sequence number. Since the sample word position of the first sample word is determined, the first sample constraint label can be added to the first sample data based on the sample word position. For example, the first sample constraint label can be added to the front and back positions of the first sample word, that is, the first sample constraint label can be added to the position between the first sample word and the previous sample word, and the first sample constraint label can be added to the position between the first sample word and the next sample word. The first sample constraint label is used to indicate the first sample word. As Figure 2 As shown, for example, the first sample data is 22, the first sample word in the first sample data is "amusement park", and the sample data obtained by the computer device after adding the first sample constraint label to the first sample data is 24, where " <b1> ”、" <e1>” indicates the first sample constraint label.

[0088] S204, obtaining a reference sample, and training a target processing model based on the first sample data after adding the first sample constraint label, the sample correspondence relationship, and the reference sample.

[0089] In an embodiment of the present application, a computer device may obtain a reference sample, and train a target processing model based on the first sample data after adding the first sample constraint label, the sample correspondence relationship, and the reference sample. The reference sample may refer to a sample with a label added to the second sample data, that is, the expected output result of the target processing model. Specifically, the computer device may add a second sample constraint label to the word position of the second sample word in the second sample data based on the first sample data after adding the first sample constraint label, the sample correspondence relationship, and the second sample data, determine the loss function of the initial processing model based on the second sample data after adding the second sample constraint label and the reference sample, train the initial processing model based on the loss function, and obtain the target processing model.

[0090] Wherein, since the reference sample may refer to the expected output result of the model, the second sample data after adding the second sample constraint tag may refer to the actual output result of the model, and the computer device may determine the loss function of the initial processing model based on the overlap between the second sample data after adding the second constraint tag (i.e., the actual output result of the model) and the reference sample (i.e., the expected output result of the model). If the overlap between the second sample data after adding the second constraint tag and the reference sample is greater than the overlap threshold, the initial processing model at this time is saved, and the initial processing model at this time is determined as the target processing model. If the overlap between the second sample data after adding the second constraint tag and the reference sample is less than or equal to the overlap threshold, the parameters in the initial processing model continue to be adjusted, and when the overlap is greater than the overlap threshold, the initial processing model at this time is determined as the target processing model. Wherein, if the loss function of the model is greater than the loss threshold, it means that the accuracy of the model is lower than the accuracy threshold; if the loss function of the model is less than or equal to the loss threshold, it means that the accuracy of the model is higher than the accuracy threshold.

[0091] Specifically, since the computer device performs alignment processing on the first sample data and the second sample data and determines the sample correspondence relationship between the sample words in the first sample data and the sample words in the second sample data, it can determine the position in the second sample data to add the second sample constraint label based on the first sample data after adding the first sample constraint label and the sample correspondence relationship, and the second sample data, that is, add the second sample constraint label to the word position of the second sample word in the second sample data. In other words, the word indicated by the second sample constraint label is the second sample word, and the second sample word has a correspondence relationship with the first sample word. In other words, since the computer device can determine the second sample word in the second sample data corresponding to the first sample word based on the first sample word and the sample correspondence relationship, the computer device can obtain the position information of the second word in the second sample data, and add the second sample constraint label in the second sample data based on the position information of the second sample word in the second sample data.

[0092] Optionally, if there are empty words in the first sample data or the second sample data, the computer device divides the empty words, and then adjusts the sample correspondence between the sample words in the first sample data and the sample words in the second sample data based on the target word combination obtained after the division. The computer device can train the target processing model based on the first sample data after adding the first sample constraint label, the adjusted sample correspondence, and the reference sample.

[0093] like Figure 2 As shown, after the computer device performs alignment processing on the first sample data and the second sample data, it is determined that the first sample word "amusement park" in the first sample data 22 and the corresponding second sample word in the second sample data are "amusement park". After the computer device adds the second sample constraint label to the second sample data, the text data obtained is 25, where " <b1> ”、" <e1>" represents a second sample constraint tag. After the computer device maps the first style (bold and underline) of the first sample word to the second style (bold and underline) of the second sample word, the second sample data 26 containing the second style is obtained.

[0094] In the embodiment of the present application, by using a large amount of sample data to train the initial processing model, deleting sample data with errors during the training process, and adjusting the sample correspondence in the sample data, the accuracy of data processing can be improved, thereby improving the accuracy of model training, and then when the trained model is used to process text data, the accuracy of data processing can be improved. Since the error data is deleted during the model training process, the amount of calculation can be reduced and the efficiency of data processing can be improved.

[0095] Optionally, the model structure of the target processing model involved in the embodiments of the present application may include but is not limited to a Transformer model structure, a Recurrent Neural Network (RNN), and a Transformer-mixed model structure. The Transformer-mixed model is a variant of the Transformer model. The decoder part of the traditional Transformer model is composed of self-attention, such as Figure 8 As shown in 8a, Figure 8 is a schematic diagram of a model structure provided in an embodiment of the present application, Figure 8 8a is a schematic diagram of the decoder structure of the Transformer model. The Transformer model can include two decoders. The first decoder includes a self-attention layer, a first normalization layer, an attention encoding and decoding layer, a second normalization layer, and a feedforward neural network layer. The second decoder also includes a self-attention layer, a first normalization layer, an attention encoding and decoding layer, a second normalization layer, and a feedforward neural network layer. The Transformer model may also include an encoder. Specifically, after the computer device inputs the training data (such as the first sample data containing the first sample constraint label, the second sample data, and so on) into the Transformer model, the encoder may encode the training data to obtain the encoding features; the self-attention layer of the first decoder processes the training data to obtain the semantic features of the sentences in the training data; the semantic features of the sentences are normalized based on the first normalization layer to obtain the normalized semantic features; the normalized semantic features and encoding features are processed based on the attention encoding and decoding layer to obtain the combined features; the combined features are normalized based on the second normalization layer to obtain the normalized combined features; the normalized combined features are mapped based on the feedforward neural network layer to obtain the first decoder output result; and the first decoder output result and the encoding features are decoded based on the second decoder to obtain the model output result.

[0096] Among them, the self-attention layer can be used to capture the semantic features between words in a sentence; the first normalization layer and the second normalization layer can be used to normalize the data, thereby speeding up the training speed and improving the stability of the training. The attention encoding and decoding layer can be used to help the current node obtain the key content that needs to be paid attention to, that is, to capture the key information in the current sentence. The feedforward neural network layer can be used to enable the model to obtain nonlinear processing capabilities through a simple nonlinear processing unit, thereby realizing static nonlinear mapping of multiple feature vectors output by the second normalization layer. It can be understood that Figure 8 Both models can include multiple decoders. Figure 8 Only two decoders in each model are shown.

[0097] Figure 8 8b is a schematic diagram of the decoder structure of the Transformer-mixaan model. The first decoder includes an average attention layer, a first normalization layer, an attention encoding and decoding layer, a second normalization layer, and a feedforward neural network layer. The second decoder includes a self-attention layer, a first normalization layer, an attention encoding and decoding layer, a second normalization layer, and a feedforward neural network layer. In the Transformer model, the self-attention layer in the first decoder and the second decoder can be self-attention, the first normalization layer can be add&normalize, the attention encoding and decoding layer can be encoder-decoder attention, the second normalization layer can be add&normalize, and the feedforward neural network layer can be feedforward. In the Transformer-mixaan model, the average attention layer in the first decoder can be average-attention, the first normalization layer can be add&normalize, the attention encoding and decoding layer can be encoder-decoder attention, the second normalization layer can be add&normalize, and the feedforward neural network layer can be feedforward. It can be seen that the self-attention layers of the two decoders of the Transformer model are both composed of self-attention, while the two decoders of the Transformer-mixaan model are composed of self-attention and average-attention in an alternating manner, that is, the average attention layer of the first decoder is composed of average-attention, and the self-attention layer of the second decoder is composed of self-attention. Since self-attention obtains the semantic features between sentences by dynamically calculating the current attention weight, and average-attention calculates the cumulative historical weight based on a fixed average value, by summarizing the previous historical information, the Transformer-mixaan model has better diversity, and thus the model processing effect is better when the model is used to process text data.

[0098] Optionally, the embodiments of the present application may mainly include three parts: constructing a training corpus, model training, and model usage. Among them, when constructing the training corpus, the computer device can obtain a conventional bilingual training corpus. By performing alignment processing on the bilingual training corpus, the corresponding relationship between the words in the bilingual training corpus can be determined, thereby obtaining a bilingual training corpus with a corresponding relationship. Further, when training the model, by using the bilingual training corpus with a corresponding relationship to train the target processing model, the target processing model can generate a second constraint label corresponding to the first constraint label in the source text data while translating the source text data, obtaining the target text data with the second constraint label added. That is to say, when training the model, the target processing model is enabled to have the ability to translate text data and add the second constraint label at the same time. Further, when using the model, by obtaining rich-style text data, adding the first constraint label to the rich-style text data and then inputting it into the target processing model, the translated text data with the second constraint label added can be output based on the target processing model. Finally, by mapping the style of the word corresponding to the first constraint label to the style of the word corresponding to the second constraint label, rich-style translated text data can be obtained.

[0099] After training the target processing model through the above method, the target processing model can be used in the embodiments of the present application. Optionally, the computer device can first obtain the source text data, as Figure 2 shown in 22, where the source style of "amusement park" in the source text data is bold and underlined. Further, the computer device can obtain the word position of the target source word in the source text data. If the target source word is "amusement park", add the first constraint label in the source text data based on the word position of the target source word, such as "Go tomorrow <b1>Amusement Park <e1>Play", the first constraint label is " <b1> <e1>". Further, the computer device inputs the source text data with the first constraint tag added into the target processing model, and outputs the target text data with the second constraint tag added based on the target processing model. The target text data with the second constraint tag added is such as "Go to <b1>amusement park <e1>to play tomorrow", and the second constraint label is " <b1> <e1>Further, the computer device may map the target source style of the target source word to the target style of the target word based on the first constraint tag and the second constraint tag, such as Figure 2 By adding constraint tags to target source words with source styles in the source text data, the obtained target text data includes corresponding constraint tags, thereby mapping the source styles in the source text data to the target text data, retaining the style information in the text translation process, making the text translation more complete, and improving the accuracy of data processing.

[0100] In the embodiment of the present application, since the position information of the target source words with source style in the source text data is determined, the source text data can be added with constraint tags based on the position information of the target source words in the source text data, so as to obtain the target text data with constraint tags added based on the corresponding relationship between the source text data and words after adding the constraint tags, and the source style in the source text data is mapped to the target style in the target text data based on the constraint tags, so that the target style can be included in the translated target text data, thereby achieving the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing. Further, by obtaining a large amount of sample data to train the model, and deleting the sample data with errors during the training process, and adjusting the sample correspondence in the sample data, the accuracy of data processing can be improved, thereby improving the accuracy of model training, and then when the trained model is used to process the text data, the accuracy of data processing can be improved. Since the error data is deleted during the model training process, the amount of calculation can be reduced and the efficiency of data processing can be improved.

[0101] The method of the embodiment of the present application is introduced above, and the device of the embodiment of the present application is introduced below.

[0102] See also Fig. 9 , Fig. 9 : is a schematic diagram of the composition structure of a data processing device provided in an embodiment of the present application. The above-mentioned data processing device can be a computer program (including program code) running in a computer device. For example, the data processing device is an application software; the data processing device can be used to execute the corresponding steps in the data processing method provided in the embodiment of the present application. The data processing device 90 includes:

[0103] The text acquisition module 91 is used to acquire source text data, where the source text data is rich-style text data;

[0104] A first adding module 92 is used to obtain the word position of the target source word in the source text data, and add a first constraint tag to the source text data based on the word position of the target source word, and the style of the target source word is the target source style;

[0105] A second adding module 93 is used to obtain target text data with a second constraint tag added based on the correspondence between the source text data and the words after the first constraint tag is added, where the target text data is obtained by translating the source text data, and the target word is a word corresponding to the target source word;

[0106] The data mapping module 94 is used to map the target source style to the target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

[0107] Optionally, the data processing device 90 further includes a model training module 95, and the model training module 95 includes:

[0108] The sample acquisition module 951 is used to acquire first sample data and second sample data, where the second sample data is obtained by translating the first sample data, and the first sample data is rich-style text data;

[0109] A sample alignment module 952, configured to perform alignment processing on the first sample data and the second sample data to determine a sample correspondence relationship between a sample word in the first sample data and a sample word in the second sample data;

[0110] A sample adding module 953 is used to obtain a sample word position of a first sample word in the first sample data, and add a first sample constraint label to the first sample data based on the sample word position, wherein the style of the first sample word is a first style;

[0111] The sample mapping module 954 is used to obtain a reference sample label, and train a target processing model based on the first sample data after adding the first sample constraint label, the sample correspondence relationship and the reference sample;

[0112] The second adding module 93 is specifically used to obtain the target text data with the second constraint tag added thereto by adopting the target processing model based on the corresponding relationship between the source text data with the first constraint tag added thereto and the words.

[0113] Optionally, the sample alignment module 952 is specifically configured to:

[0114] Perform word segmentation processing on the first sample data and the second sample data to obtain a first correspondence between N first words and M second words, where the first words are words in the first sample data, the second words are words in the second sample data, and N and M are both positive integers;

[0115] Based on the first correspondence between the N first words and the M second words, determine a second correspondence between i first words and j second words, where the first word is a word composed of at least one word among the N first words, and the second word is a word composed of at least one word among the M second words, and i and j are both positive integers;

[0116] Based on the second correspondence, it is determined whether the first sample data and the second sample data are aligned. If the first sample data and the second sample data are aligned, the alignment relationship is used as a sample correspondence between the sample words in the source text data and the sample words in the target text data.

[0117] Optionally, the sample alignment module 952 is specifically configured to:

[0118] Adopting an alignment consistency principle to determine whether a first target word and a second target word are aligned, the first target word being any one of the i first words, the second target word being any one of the j second words, the alignment consistency principle being used to indicate whether a word consisting of a plurality of consecutive words in the first sample data corresponds to a word consisting of a plurality of consecutive words in the second sample data;

[0119] If the first target word and the second target word are aligned, then determining that the first sample data and the second sample data are aligned;

[0120] If the first target word and the second target word are not aligned, it is determined that the first sample data and the second sample data are not aligned.

[0121] Optionally, the data processing device 90 further includes a word matching module 96, which is used to:

[0122] If the first target word and the second target word are aligned, obtaining a first key word in the first sample data and a second key word in the second sample data;

[0123] Matching the first keyword and the second keyword;

[0124] If the first keyword matches the second keyword, it is determined that the first sample data is aligned with the second sample data.

[0125] Optionally, the data processing device 90 further includes a word segmentation module 97, which is used to:

[0126] If the first target word is aligned with the second target word, detecting whether there is a blank word in the sample data;

[0127] If there is a blank word in the sample data, the blank word is added to the first neighbor word and the second neighbor word respectively to obtain a first combination word and a second combination word, wherein the first neighbor word and the second neighbor word are two words adjacent to the blank word in the sample data, and the sample data is any one of the first sample data and the second sample data;

[0128] Determining a target combination word from the first combination word or the second combination word;

[0129] The sample correspondence between the sample words in the first sample data and the sample words in the second sample data is adjusted based on the target combination word.

[0130] Optionally, the data processing device 90 further includes a data rendering module 98, which is used to:

[0131] Rendering the target text data based on the target style of the target word to obtain rendered target text data containing the target style;

[0132] The associated user terminal is called to output the rendered target text data containing the target style.

[0133] It should be noted that Fig. 9 For the contents not mentioned in the corresponding embodiments, please refer to the description of the method embodiments, which will not be repeated here.

[0134] In an embodiment of the present application, by obtaining source text data with rich styles, and obtaining the word positions of target source words with target source styles in the source text data, a first constraint tag can be added to the source text data based on the word positions of the target source words; based on the correspondence between the source text data and words after adding the first constraint tag, the target text data with the second constraint tag added can be obtained, thereby mapping the target source style to the target style of the target words corresponding to the second constraint tag based on the first constraint tag and the second constraint tag, so as to obtain the target text data containing the target style. Since the position information of the target source words with source styles in the source text data is determined, constraint tags can be added to the source text data based on the position information of the target source words in the source text data, thereby obtaining the target text data with constraint tags based on the correspondence between the source text data and words after adding the constraint tags, and mapping the source style in the source text data to the target style in the target text data based on the constraint tags, so that the translated target text data can contain the target style, thereby achieving the retention of the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing.

[0135] See also Fig.10 , Fig.10 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.10 As shown, the above-mentioned computer device 100 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 100 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Fig.10 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.

[0136] exist Fig.10 In the computer device 100 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to perform the following operations:

[0137] Get source text data, where the source text data is rich-style text data;

[0138] Obtaining a word position of a target source word in the source text data, adding a first constraint tag to the source text data based on the word position of the target source word, and the style of the target source word is the target source style;

[0139] Based on the correspondence between the source text data and the words after adding the first constraint tag, the target text data with the second constraint tag added is obtained, the target text data is obtained by translating the source text data, and the target word is a word corresponding to the target source word;

[0140] The target source style is mapped to a target style of a target word corresponding to the second constraint tag based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

[0141] It should be understood that the computer device 100 described in the embodiment of the present application can execute the above Figure 3 and Figure 4 The description of the above data processing method in the corresponding embodiment can also be performed as described above. Fig. 9 The description of the above data processing device in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here.

[0142] In an embodiment of the present application, by obtaining source text data with rich styles, and obtaining the word positions of target source words with target source styles in the source text data, a first constraint tag can be added to the source text data based on the word positions of the target source words; based on the correspondence between the source text data and words after adding the first constraint tag, the target text data with the second constraint tag added can be obtained, thereby mapping the target source style to the target style of the target words corresponding to the second constraint tag based on the first constraint tag and the second constraint tag, so as to obtain the target text data containing the target style. Since the position information of the target source words with source styles in the source text data is determined, constraint tags can be added to the source text data based on the position information of the target source words in the source text data, thereby obtaining the target text data with constraint tags based on the correspondence between the source text data and words after adding the constraint tags, and mapping the source style in the source text data to the target style in the target text data based on the constraint tags, so that the translated target text data can contain the target style, thereby achieving the retention of the style in the text while translating the text, ensuring the integrity of the text data translation, and improving the accuracy of data processing.

[0143] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, which includes program instructions, which, when executed by a computer, causes the computer to execute the method of the aforementioned embodiment, and the computer may be part of the computer device mentioned above. For example, it is the above-mentioned processor 1001. As an example, the program instructions may be deployed on a computer device for execution, or deployed on multiple computer devices located at one location for execution, or, executed on multiple computer devices distributed at multiple locations and interconnected by a communication network, and multiple computer devices distributed at multiple locations and interconnected by a communication network may constitute a blockchain network.

[0144] Those skilled in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0145] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application. < / b1> < / b1> < / b1> < / b1> < / b1> < / b1>

Claims

1. A data processing method, characterized in that: include: Acquire source text data, where the source text data is rich-style text data; Acquire a word position of a target source word in the source text data, and add a first constraint tag to the front and back positions of the target source word in the source text data based on the word position of the target source word, wherein the target source word is a rich-style word and the style of the target source word is a target source style; Based on the correspondence between the source text data and the words after adding the first constraint tag, the target text data with the second constraint tag added is obtained, wherein the second constraint tag is added before and after the target word in the target text data, the target word is a word corresponding to the target source word, and the target text data is obtained by translating the source text data; The target source style is mapped to a target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

2. The method according to claim 1, characterized in that Before obtaining the source text data, the method further includes: Acquire first sample data and second sample data, where the second sample data is obtained by translating the first sample data, and the first sample data is rich-style text data; Performing alignment processing on the first sample data and the second sample data to determine a sample correspondence relationship between sample words in the first sample data and sample words in the second sample data; Acquire a sample word position of a first sample word in the first sample data, and add a first sample constraint label to the first sample data based on the sample word position, wherein the style of the first sample word is a first style; Acquire a reference sample, and train a target processing model based on the first sample data after adding the first sample constraint label, the sample correspondence relationship, and the reference sample; The method of obtaining the target text data with the second constraint tag added based on the correspondence between the source text data with the first constraint tag added and the words includes: The target processing model is used to obtain target text data with a second constraint tag added thereto based on the source text data with the first constraint tag added thereto and the corresponding relationship between the words.

3. The method according to claim 2, characterized in that The aligning the first sample data and the second sample data to determine a sample correspondence relationship between sample words in the first sample data and sample words in the second sample data includes: Performing word segmentation processing on the first sample data and the second sample data to obtain a first correspondence between N first words and M second words, where the first words are words in the first sample data, the second words are words in the second sample data, and N and M are both positive integers; Based on the first correspondence between the N first words and the M second words, determine a second correspondence between i first words and j second words, where the first word is a word composed of at least one word among the N first words, and the second word is a word composed of at least one word among the M second words, and i and j are both positive integers; Based on the second correspondence, determine whether the first sample data and the second sample data are aligned. If the first sample data and the second sample data are aligned, use the alignment relationship as a sample correspondence between the sample words in the source text data and the sample words in the target text data.

4. The method according to claim 3, characterized in that The determining whether the first sample data and the second sample data are aligned based on the second corresponding relationship includes: Adopting an alignment consistency principle to determine whether a first target word and a second target word are aligned, the first target word is any one of the i first words, the second target word is any one of the j second words, and the alignment consistency principle is used to indicate whether a word composed of a plurality of consecutive words in the first sample data corresponds to a word composed of a plurality of consecutive words in the second sample data; If the first target word and the second target word are aligned, determining that the first sample data and the second sample data are aligned; If the first target word and the second target word are not aligned, it is determined that the first sample data and the second sample data are not aligned.

5. The method according to claim 4, characterized in that The method further comprises: If the first target word and the second target word are aligned, obtaining a first key word in the first sample data and a second key word in the second sample data; matching the first keyword and the second keyword; If the first keyword and the second keyword match, a step of determining that the first sample data and the second sample data are aligned is performed.

6. The method according to claim 4, characterized in that The method further comprises: If the first target word and the second target word are aligned, detecting whether there is a blank word in the sample data; If there is a blank word in the sample data, the blank word is added to a first neighbor word and a second neighbor word respectively to obtain a first combined word and a second combined word, wherein the first neighbor word and the second neighbor word are two words adjacent to the blank word in the sample data, and the sample data is any one of the first sample data and the second sample data; Determining a target combination of words from the first combination of words or the second combination of words; The sample correspondence between the sample words in the first sample data and the sample words in the second sample data is adjusted based on the target combination word.

7. The method according to claim 1, characterized in that The method further comprises: Rendering the target text data based on the target style of the target word to obtain rendered target text data containing the target style; The associated user terminal is called to output the rendered target text data containing the target style.

8. A data processing device, characterized in that: include: A text acquisition module, used to acquire source text data, wherein the source text data is rich-style text data; A first adding module is used to obtain a word position of a target source word in the source text data, and add a first constraint tag to the front and back positions of the target source word in the source text data based on the word position, wherein the target source word is a rich-style word and the style of the target source word is a target source style; A second adding module is used to obtain target text data with a second constraint label added based on the correspondence between the source text data and the words after the first constraint label is added, wherein the target text data is obtained by translating the source text data, and the second constraint label is added before and after the target word in the target text data, and the target word is a word corresponding to the target source word; A data mapping module is used to map the target source style to a target style of the target word based on the first constraint tag and the second constraint tag to obtain target text data containing the target style.

9. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store program code, and the processor is used to call the program code so that the computer device executes the method described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 7.

11. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.