Intelligent alignment method, device, equipment and medium for physical characters
By annotating named entities and using neural translation models and matching algorithms, the problem of character alignment dependence on vocabulary in the prior art is solved, and the high accuracy alignment of entity characters is achieved.
Patent Information
- Application Number
- CN202210814664.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-11
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-07-11
AI Technical Summary
Existing character alignment techniques rely on high-quality bilingual vocabulary lists, resulting in some characters not being recorded, reducing the accuracy of character alignment.
Cross-language translation is performed by annotating named entities, using the trained neural translation model, and matching the translated text and entities using a matching algorithm. If the match is successful, the position sequence will be obtained. If the match fails, the entity characters will be divided to determine the position sequence.
Improve the accuracy of entity character alignment, ensure that the position of named entities in the translated text is determined, and the precise alignment of statement text and translated text is achieved.
Smart Images

Figure CN115034195B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent decision-making, and in particular to an intelligent alignment method, device, electronic device and computer-readable storage medium for physical characters. Background Art
[0002] Alignment technology is primarily used in the construction of bilingual parallel corpora. The idea is to find mutually translatable source and target text segments in bilingual texts and calculate the alignment granularity of the source text, from coarse to fine, including chapters, paragraphs, sentences, words, and even characters. The smaller the granularity, the more difficult the alignment. Different languages in a text have different grammatical rules. Even those from similar language families can experience significant changes in expression after translation. Character alignment is the process of aligning the characters in the source text to be translated with the characters in the target text segment. Character alignment can improve the accuracy of subsequent translation and avoid translation errors.
[0003] Existing character alignment is often based on pre-organized bilingual word lists and sub-lists. By constructing a matching matrix, bilingual words are aligned. However, this method relies on high-quality bilingual word lists and sub-lists. However, some characters may not be recorded in the bilingual word lists and sub-lists, which in turn affects character alignment and reduces its accuracy. Summary of the Invention
[0004] In order to solve the above technical problems, the present invention provides a method, device, electronic device and computer-readable storage medium for intelligent alignment of physical characters, which can improve the accuracy of physical character alignment.
[0005] In a first aspect, the present invention provides a method for intelligently aligning entity characters, comprising:
[0006] Obtaining a sentence text to be translated and marking named entities in the sentence text;
[0007] Using the trained neural translation model to perform cross-language translation on the sentence text and the named entity, respectively, to obtain a translation text and a translation entity, and matching the translation text with the translation entity using a preset matching algorithm;
[0008] If the translation text successfully matches the translation entity, obtaining a first position sequence of the translation entity in the translation text, and marking a final position sequence of the named entity in the translation text according to the first position sequence;
[0009] If the translation text fails to match the translation entity, the entity characters in the translation entity are segmented to obtain segmented entity characters, and based on the segmented entity characters, the second position sequence of the translation entity in the translation text is determined, and based on the second position sequence, the final position sequence of the named entity in the translation text is marked.
[0010] In a possible implementation of the first aspect, the marking the named entities in the sentence text includes:
[0011] Performing entity extraction on the sentence text to obtain entity text, and performing entity screening on the entity text to obtain screened entities;
[0012] The screened entities are labeled to obtain named entities.
[0013] In a possible implementation of the first aspect, before using the trained neural translation model to perform cross-language translation on the sentence text and the named entity, the method includes:
[0014] Obtaining training samples and their corresponding real translation results, and performing vector position encoding on the training samples using an encoding layer in a pre-built neural translation model to obtain an encoding position vector;
[0015] Performing feature encoding on the encoding position vector using an encoder in a pre-built neural translation model to obtain a feature encoding vector;
[0016] Decoding the feature encoding vector using a decoder in a pre-built neural translation model to obtain a decoded feature vector;
[0017] Outputting a predicted translation result of the training sample using an activation function in the pre-built neural translation model according to the decoded feature vector, and calculating a loss value between the predicted translation result and the true translation result using a loss function in the pre-built neural translation model;
[0018] If the loss value is greater than a preset threshold, the parameters in the pre-built neural translation model are adjusted, and the step of performing vector position encoding on the training sample using the encoding layer in the pre-built neural translation model is returned to execution. If the loss value is not greater than the preset threshold, a trained neural translation model is obtained.
[0019] In a possible implementation of the first aspect, matching the translation text with the translation entity using a preset matching algorithm includes:
[0020] Segmenting the translation text to obtain segmented translations;
[0021] extracting the segmented translations to obtain extracted translations;
[0022] Calculating the matching degree between the extracted translation and the translation entity using the preset matching algorithm;
[0023] If the matching degree is greater than a preset matching degree, the extracted translation successfully matches the translation entity;
[0024] If the matching degree is not greater than the preset matching degree, the extracted translation fails to match the translation entity.
[0025] In a possible implementation of the first aspect, obtaining a first position sequence of the translated entity in the translated text includes:
[0026] Identifying the number of characters in the translation entity, and if the number of characters meets a first preset range, directly position-encoding the characters in the translation entity to obtain a first position sequence of the translation entity;
[0027] If the number of characters meets the second preset range, the starting position and the ending position of the characters in the translation entity are located, and the characters in the translation entity are position-coded according to the starting position and the ending position to obtain a first position sequence of the translation entity.
[0028] In a possible implementation of the first aspect, segmenting the entity characters in the translation entity to obtain segmented entity characters includes:
[0029] Character information in the entity characters is identified, and the character information is segmented according to a preset segmentation order to obtain segmented entity characters.
[0030] In a possible implementation of the first aspect, determining a second position sequence of the translated entity in the translated text based on the segmented entity characters includes:
[0031] Locating a start segmentation character and an end segmentation character for segmenting the entity characters, searching for a first position of the start segmentation character in the translation text, and searching for a second position of the end segmentation character in the translation text;
[0032] The characters between the first position and the second position are combined in a preset order to obtain a combined character, and when the segmented entity character is consistent with the combined character, the position sequence of the combined character is used as the second position sequence of the translated entity in the translated text.
[0033] In a second aspect, the present invention provides an intelligent alignment device for physical characters, the device comprising:
[0034] A named entity annotation module is used to obtain a sentence text to be translated and annotate the named entities in the sentence text;
[0035] A translation matching module is used to use a trained neural translation model to perform cross-language translation on the sentence text and the named entity to obtain a translation text and a translation entity, and to match the translation text with the translation entity using a preset matching algorithm;
[0036] a position sequence marking module, configured to obtain a first position sequence of the translation entity in the translation text when the translation text successfully matches the translation entity, and mark a final position sequence of the named entity in the translation text based on the first position sequence;
[0037] A character segmentation module is used to segment the entity characters in the translation entity when the translation text fails to match the translation entity to obtain segmented entity characters, and determine the second position sequence of the translation entity in the translation text based on the segmented entity characters, and mark the final position sequence of the named entity in the translation text based on the second position sequence.
[0038] In a third aspect, the present invention provides an electronic device, comprising:
[0039] at least one processor; and a memory communicatively coupled to the at least one processor;
[0040] The memory stores a computer program executable by the at least one processor, so that the at least one processor can execute the intelligent alignment method of entity characters as described in any one of the first aspects above.
[0041] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the method for intelligent alignment of entity characters as described in any one of the first aspects above is implemented.
[0042] Compared with the existing technology, the technical principle and beneficial effects of this solution are:
[0043] The embodiment of the present invention firstly marks the named entities in the sentence text to be translated, so as to display all the named entities in the sentence text by marking, so as to facilitate the positioning of the named entities in the later stage, and uses the trained neural translation model to perform cross-language translation on the sentence text and the named entities respectively, and uses a preset matching algorithm to match the translation text with the translation entity, which can improve the accuracy of the cross-language translation of the sentence text and the named entity; secondly, when the translation text and the translation entity are successfully matched, the embodiment of the present invention obtains the first position sequence of the translation entity in the translation text to mark the final position sequence of the named entity in the translation text, so as to determine the location of the named entity. The specific position in the translation text is determined, so that the entity characters of the sentence text and the translation text are aligned, and the accuracy of entity character alignment is improved; further, when the translation text fails to match the translation entity, the embodiment of the present invention segments the entity characters in the translation entity to obtain segmented entity characters, and the specific position of the translation entity in the translation text can be determined, so that the second position sequence of the translation entity in the translation text can be determined, and according to the second position sequence, the final position sequence of the named entity in the translation text is marked, and the specific position of the named entity in the translation text can be determined, so that the entity characters of the sentence text and the translation text are aligned, and the accuracy of entity character alignment is improved. Therefore, the intelligent alignment method, device, electronic device and storage medium of entity characters proposed in the embodiment of the present invention can improve the accuracy of entity character alignment. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A schematic diagram of a flow chart of an intelligent alignment method for entity characters provided by one embodiment of the present invention;
[0047] Figure 2 A schematic diagram of a module of an intelligent alignment device for physical characters provided by one embodiment of the present invention;
[0048] Figure 3A schematic diagram of the internal structure of an electronic device for implementing a method for intelligent alignment of physical characters provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0050] An embodiment of the present invention provides a method for intelligent alignment of physical characters, and the execution subject of the character alignment includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present invention. In other words, the intelligent alignment method of physical characters can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0051] See Figure 1 FIG. 1 is a flow chart of an intelligent alignment method for entity characters provided by an embodiment of the present invention. Figure 1 The intelligent alignment method for entity characters described in the embodiment includes the following steps S1-S4:
[0052] S1. Obtain a sentence text to be translated, mark named entities in the sentence text, and identify the first position sequence of the named entities in the sentence text.
[0053] In an embodiment of the present invention, the sentence text refers to a collection of data that needs to be translated, which can be in the form of a single text collection or a collection of sentences in a logical order. Optionally, the sentence text is generated based on different business scenarios. For example, in a medical scenario, the sentence text can be a medical text to be translated, and in a financial scenario, the sentence text can be a financial text to be translated.
[0054] Furthermore, by marking the named entities in the sentence text, the present embodiment can display all named entities in the sentence text through annotation, so as to facilitate the subsequent positioning of the named entities. The named entities refer to names of people, organizations, places, and all other entities identified by names. A broader range of entities also includes numbers, dates, currencies, addresses, etc. For example, in the sentence "Hefei is a beautiful city," both "Hefei" and "city" are named entities.
[0055] As an embodiment of the present invention, the labeling of named entities in the sentence text includes: performing entity extraction on the sentence text to obtain entity text, performing entity screening on the entity text to obtain screened entities, and labeling the screened entities to obtain named entities.
[0056] Furthermore, in an optional implementation of the present invention, the entity extraction of the sentence text can be achieved through an entity extraction tool, such as a NER tool, the screening of the entity text can be performed through a classification algorithm, such as a KNN algorithm, and the labeling of the screened entities can be achieved through a labeling tool, such as a color labeling tool.
[0057] S2. Use the trained neural translation model to perform cross-language translation on the sentence text and the named entity to obtain a translation text and a translation entity, and use a preset matching algorithm to match the translation text with the translation entity.
[0058] In an embodiment of the present invention, the trained neural translation model is constructed through a transform neural network, which includes an encoding layer, an encoder, and a decoder, wherein the encoding layer converts the sentence text from text to vector form, the encoder compiles the features of the vector to facilitate reading by the neural translation model, and the decoder decodes the feature vector to facilitate the subsequent neural translation model to translate the feature vector. Furthermore, the translation text and the translation entity refer to the translation text obtained after the translation of the sentence text and the named entity, and the language of the translation text may be English, Spanish, Russian, or other languages.
[0059] Furthermore, in an embodiment of the present invention, before using the trained neural translation model to perform cross-language translation on the sentence text and the named entity respectively, it also includes: obtaining a training sample and its corresponding real translation result, using the encoding layer in the pre-constructed neural translation model to perform vector position encoding on the training sample to obtain an encoding position vector, using the encoder in the pre-constructed neural translation model to perform feature encoding on the encoding position vector to obtain a feature encoding vector, using the decoder in the pre-constructed neural translation model to decode the feature encoding vector to obtain a decoding feature vector, according to the decoded feature vector, using the activation function in the pre-constructed neural translation model to output the predicted translation result of the training sample, using the loss function in the pre-constructed neural translation model to calculate the loss value of the predicted translation result and the real translation result, if the loss value is greater than a preset threshold, adjusting the parameters in the pre-constructed neural translation model, and returning to execute the step of performing vector position encoding on the training sample using the encoding layer in the pre-constructed neural translation model, if the loss value is not greater than the preset threshold, obtaining a trained neural translation model.
[0060] Furthermore, in an optional embodiment of the present invention, the vector position encoding of the training sample can be implemented by an encoding function, such as a PNG encoding function, the feature encoding of the encoding position vector by the encoder can be implemented by an encoding model, the activation function includes a Softmax function, the loss value of the predicted translation result and the true translation result can be calculated by a loss function, the preset threshold can be set to 0.1, or can be set according to the actual application scenario, and the decoding of the feature encoding vector can be implemented by a decoding function, such as a discrete cosine transform function.
[0061] Furthermore, the embodiment of the present invention matches the translation text with the translation entity by using a preset matching algorithm, thereby determining whether the translation entity corresponds to the translation text, thereby facilitating improving the accuracy of entity character alignment.
[0062] Furthermore, in an embodiment of the present invention, the matching of the translation text with the translation entity using a preset matching algorithm includes: segmenting the translation text to obtain segmented translations, extracting the segmented translations to obtain extracted translations, and calculating a matching degree between the extracted translation and the translation entity using the preset matching algorithm; if the matching degree is greater than a preset matching degree, the extracted translation successfully matches the translation entity; if the matching degree is not greater than the preset matching degree, the extracted translation fails to match the translation entity.
[0063] Among them, the segmented translation refers to the segmented translation fragments, the translation segmentation is performed according to the correspondence between the named entities and the sentence text, the segmentation of the translation text is achieved by a text segmentation function, and the extraction of the segmented translation is achieved by an extraction tool, such as a NER tool. Furthermore, optionally, the matching algorithm is a cosine similarity algorithm, and the preset matching degree can be set to 0.88, or can be set according to the actual business scenario.
[0064] S3. If the translation text successfully matches the translation entity, obtain a first position sequence of the translation entity in the translation text, and mark a final position sequence of the named entity in the translation text according to the first position sequence.
[0065] It should be understood that if the translation text successfully matches the translation entity, it means that the translation entity can be found by searching in the translation text, and the translation entity is obtained by translating the named entity. Therefore, the embodiment of the present invention obtains the first position sequence of the translation entity in the translation text, thereby determining the specific position of the translation entity in the translation text, thereby ensuring the premise for determining the position of the subsequent named entity in the translation text. The first position sequence refers to the specific position of the translation entity in the translation text.
[0066] As an embodiment of the present invention, obtaining the first position sequence of the translation entity in the translation text includes: identifying the number of characters in the translation entity; if the number of characters meets a first preset range, directly position-encoding the characters in the translation entity to obtain the first position sequence of the translation entity; if the number of characters meets a second preset range, locating the starting position and the ending position of the characters in the translation entity; and position-encoding the characters in the translation entity according to the starting position and the ending position to obtain the first position sequence of the translation entity.
[0067] Furthermore, in an optional embodiment of the present invention, the first preset range is set to (0, 1], and the second preset range is set to be greater than 1. The first preset range and the second preset range may also be set according to actual business scenarios.
[0068] Furthermore, in an optional embodiment of the present invention, the number of characters in the translation entity is realized by a character number recognition function, and the character number recognition function is obtained by automatic script compilation. The starting position and the ending position of the characters in the translation entity are realized by the find method in the find function, and the position encoding of the characters in the translation entity is realized by a position encoding function, such as a trigonometric function.
[0069] Furthermore, the present invention marks the final position sequence of the named entity in the translation text according to the first position sequence to determine the specific position of the named entity in the translation text, thereby achieving entity character alignment between the sentence text and the translation text.
[0070] S4. If the translation text fails to match the translation entity, segment the entity characters in the translation entity to obtain segmented entity characters, and determine a second position sequence of the translation entity in the translation text based on the segmented entity characters; and mark the final position sequence of the named entity in the translation text based on the second position sequence.
[0071] It should be understood that if the translation text fails to match the translation entity, it means that the translation entity cannot be found in the translation text. Therefore, the embodiment of the present invention can reduce the number of entity characters in the translation entity by segmenting the entity characters in the translation entity, making it easier to query the entity characters in the translation entity in the translation text, thereby determining the second position sequence premise of the translation entity in the translation text.
[0072] As an embodiment of the present invention, segmenting the entity characters in the translation entity to obtain segmented entity characters includes: identifying character information in the entity characters, segmenting the character information according to a preset segmentation order, and obtaining segmented entity characters.
[0073] The character information in the entity characters can be realized by a character recognition algorithm, such as an OCR recognition algorithm, and the preset segmentation order is to segment the entity characters in sequence starting from the left.
[0074] Furthermore, embodiments of the present invention can determine the specific location of the translated entity in the translated text by determining a second position sequence of the translated entity in the translated text based on the segmented entity characters, thereby ensuring the premise for determining the position of the subsequent named entity in the translated text. The second position sequence refers to the specific location of the translated entity in the translated text.
[0075] As an embodiment of the present invention, determining the second position sequence of the translation entity in the translation text based on the segmented entity characters includes: locating the starting segmentation character and the ending segmentation character of the segmented entity characters, searching for the first position of the starting segmentation character in the translation text, and searching for the second position of the ending segmentation character in the translation text, combining the characters between the first position and the second position in a preset order to obtain a combined character, and when the segmented entity character is consistent with the combined character, using the position sequence of the combined character as the second position sequence of the translation entity in the translation text.
[0076] The starting segmentation character refers to the first character in the segmentation entity characters, and the ending segmentation character refers to the last character in the segmentation entity characters.
[0077] Furthermore, the embodiment of the present invention marks the final position sequence of the named entity in the translation text according to the second position sequence to determine the specific position of the named entity in the translation text, thereby achieving entity character alignment between the sentence text and the translation text.
[0078] It can be seen that the embodiment of the present invention firstly marks the named entities in the sentence text to be translated, and can display all the named entities in the sentence text by marking, so as to facilitate the positioning of the named entities in the later stage, and use the trained neural translation model to perform cross-language translation on the sentence text and the named entities respectively, and use the preset matching algorithm to match the translation text with the translation entity, which can improve the accuracy of the cross-language translation of the sentence text and the named entity; secondly, when the translation text and the translation entity are successfully matched, the embodiment of the present invention obtains the first position sequence of the translation entity in the translation text to mark the final position sequence of the named entity in the translation text, which can determine the named entity The specific position of the translation text is located in the translation text, so as to realize the entity character alignment of the sentence text and the translation text, and improve the accuracy of entity character alignment; further, when the translation text fails to match the translation entity, the embodiment of the present invention segments the entity characters in the translation entity to obtain segmented entity characters, and can determine the specific position of the translation entity in the translation text, thereby determining the second position sequence of the translation entity in the translation text, and marking the final position sequence of the named entity in the translation text according to the second position sequence, and can determine the specific position of the named entity in the translation text, realize the entity character alignment of the sentence text and the translation text, and improve the accuracy of entity character alignment. Therefore, the intelligent alignment method of entity characters proposed in the embodiment of the present invention can improve the accuracy of entity character alignment.
[0079] like Figure 2 FIG. 1 is a functional module diagram of the intelligent alignment device for physical characters of the present invention.
[0080] The intelligent alignment device 200 for physical characters described in the present invention can be installed in an electronic device. Depending on the functionality implemented, the intelligent alignment device for physical characters can include a named entity tagging module 201, a translation matching module 202, a position sequence tagging module 203, and a character segmentation module 204. A module described in the present invention, also referred to as a unit, refers to a series of computer program segments that can be executed by an electronic device processor and perform a fixed function, and is stored in the memory of the electronic device.
[0081] In the embodiment of the present invention, the functions of each module / unit are as follows:
[0082] The named entity tagging module 201 is used to obtain a sentence text to be translated and tag the named entities in the sentence text;
[0083] The translation matching module 202 is used to use the trained neural translation model to perform cross-language translation on the sentence text and the named entity to obtain a translation text and a translation entity, and match the translation text with the translation entity using a preset matching algorithm;
[0084] The position sequence marking module 203 is configured to obtain a first position sequence of the translation entity in the translation text when the translation text successfully matches the translation entity, and mark a final position sequence of the named entity in the translation text based on the first position sequence;
[0085] The character segmentation module 204 is configured to segment the entity characters in the translated entity when the translated text fails to match the translated entity, obtain segmented entity characters, determine a second position sequence of the translated entity in the translated text based on the segmented entity characters, and mark the final position sequence of the named entity in the translated text based on the second position sequence.
[0086] In detail, the modules in the intelligent alignment device 200 for entity characters in the embodiment of the present invention adopt the same method as above when in use. Figure 1 The intelligent alignment method of entity characters described in the preceding text is the same technical means and can produce the same technical effects, so I will not go into details here.
[0087] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the intelligent alignment method of physical characters according to the present invention.
[0088] The electronic device may include a processor 30 , a memory 31 , a communication bus 32 , and a communication interface 33 , and may also include a computer program stored in the memory 31 and executable on the processor 30 , such as a smart alignment program for physical characters.
[0089] In some embodiments, the processor 30 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 30 is the control core (Control Unit) of the electronic device, connecting the various components of the entire electronic device using various interfaces and lines, and executing the programs or modules stored in the memory 31 (for example, executing the intelligent alignment program for physical characters, etc.), as well as calling the data stored in the memory 31, to execute various functions of the electronic device and process data.
[0090] The memory 31 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 31 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 31 can also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the memory 31 can also include both an internal storage unit of the electronic device and an external storage device. The memory 31 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the intelligent alignment program of physical characters, etc., but can also be used to temporarily store data that has been output or is to be output.
[0091] The communication bus 32 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable communication between the memory 31 and at least one processor 30.
[0092] The communication interface 33 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, for displaying information processed in the electronic device and for displaying a visual user interface.
[0093] Figure 3 Only the electronic device with components is shown, and it can be understood by those skilled in the art that Figure 3The structure shown does not limit the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0094] For example, although not shown, the electronic device may further include a power source (such as a battery) for powering various components. Preferably, the power source may be logically connected to the at least one processor 30 via a power management device, thereby implementing functions such as charge management, discharge management, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The electronic device may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0095] It should be understood that the embodiment is for illustrative purposes only and the scope of the patent invention is not limited to this structure.
[0096] The intelligent alignment program for physical characters stored in the memory 31 of the electronic device is a combination of multiple computer programs. When running in the processor 30, it can achieve the following:
[0097] Obtaining a sentence text to be translated and marking named entities in the sentence text;
[0098] Using the trained neural translation model to perform cross-language translation on the sentence text and the named entity, respectively, to obtain a translation text and a translation entity, and matching the translation text with the translation entity using a preset matching algorithm;
[0099] If the translation text successfully matches the translation entity, obtaining a first position sequence of the translation entity in the translation text, and marking a final position sequence of the named entity in the translation text according to the first position sequence;
[0100] If the translation text fails to match the translation entity, the entity characters in the translation entity are segmented to obtain segmented entity characters, and based on the segmented entity characters, the second position sequence of the translation entity in the translation text is determined, and based on the second position sequence, the final position sequence of the named entity in the translation text is marked.
[0101] Specifically, the specific implementation method of the processor 30 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0102] Furthermore, if the module / unit integrated into the electronic device is implemented as a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0103] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor of an electronic device, the computer program can implement:
[0104] Obtaining a sentence text to be translated and marking named entities in the sentence text;
[0105] Using the trained neural translation model to perform cross-language translation on the sentence text and the named entity, respectively, to obtain a translation text and a translation entity, and matching the translation text with the translation entity using a preset matching algorithm;
[0106] If the translation text successfully matches the translation entity, obtaining a first position sequence of the translation entity in the translation text, and marking a final position sequence of the named entity in the translation text according to the first position sequence;
[0107] If the translation text fails to match the translation entity, the entity characters in the translation entity are segmented to obtain segmented entity characters, and based on the segmented entity characters, the second position sequence of the translation entity in the translation text is determined, and based on the second position sequence, the final position sequence of the named entity in the translation text is marked.
[0108] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical function division, and other division methods may be used in actual implementation.
[0109] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0110] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.
[0111] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0112] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0113] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0114] The foregoing description is intended only to provide specific embodiments of the present invention, which will enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown herein, but is to be construed in the widest possible manner consistent with the principles and novel features disclosed herein.
Claims
1. A method for intelligent alignment of entity characters, characterized in that: The method comprises: Obtaining a sentence text to be translated and marking named entities in the sentence text; Using the encoding layer of the trained neural translation model to perform vector position encoding on the sentence text and the named entity to obtain an encoding position vector, using the encoder of the neural translation model to perform feature encoding on the encoding position vector to obtain a feature encoding vector, using the decoder of the neural translation model to decode the feature encoding vector to obtain a decoding feature vector, obtaining a translation text and a translation entity based on the decoded feature vector, and matching the translation text with the translation entity using a preset matching algorithm; If the translation text successfully matches the translation entity, obtaining a first position sequence of the translation entity in the translation text, and marking a final position sequence of the named entity in the translation text according to the first position sequence; If the translation text fails to match the translation entity, the entity characters in the translation entity are segmented to obtain segmented entity characters, the starting segmentation character and the ending segmentation character of the segmented entity characters are located, the first position of the starting segmentation character in the translation text is found, and the second position of the ending segmentation character in the translation text is found, the characters between the first position and the second position are combined in a preset order to obtain a combined character, and when the segmented entity characters are consistent with the combined characters, the position sequence of the combined characters is used as the second position sequence of the translation entity in the translation text, and the final position sequence of the named entity in the translation text is marked according to the second position sequence.
2. The intelligent alignment method for entity characters according to claim 1, wherein: The marking of named entities in the sentence text includes: Performing entity extraction on the sentence text to obtain entity text; Performing entity screening on the entity text to obtain screened entities; The screened entities are labeled to obtain named entities.
3. The intelligent alignment method for entity characters according to claim 1, wherein: Before using the trained neural translation model to perform cross-language translation on the sentence text and the named entity, the method includes: Obtaining training samples and their corresponding real translation results, and performing vector position encoding on the training samples using the encoding layer in the pre-built neural translation model to obtain an encoding position vector; Performing feature encoding on the encoding position vector using an encoder in a pre-built neural translation model to obtain a feature encoding vector; Decoding the feature encoding vector using a decoder in a pre-built neural translation model to obtain a decoded feature vector; Outputting a predicted translation result of the training sample using an activation function in the pre-built neural translation model according to the decoded feature vector, and calculating a loss value between the predicted translation result and the true translation result using a loss function in the pre-built neural translation model; If the loss value is greater than a preset threshold, the parameters in the pre-built neural translation model are adjusted, and the step of performing vector position encoding on the training sample using the encoding layer in the pre-built neural translation model is returned to execution. If the loss value is not greater than the preset threshold, a trained neural translation model is obtained.
4. The intelligent alignment method of entity characters according to claim 1, wherein: The matching of the translation text with the translation entity using a preset matching algorithm includes: Segmenting the translation text to obtain segmented translations, and extracting the segmented translations to obtain extracted translations; Calculating the matching degree between the extracted translation and the translation entity using the preset matching algorithm; If the matching degree is greater than a preset matching degree, the extracted translation successfully matches the translation entity; If the matching degree is not greater than the preset matching degree, the extracted translation fails to match the translation entity.
5. The intelligent alignment method of entity characters according to claim 1, wherein: The obtaining of the first position sequence of the translated entity in the translated text includes: Identifying the number of characters in the translation entity, and if the number of characters meets a first preset range, directly position-encoding the characters in the translation entity to obtain a first position sequence of the translation entity; If the number of characters meets the second preset range, the starting position and the ending position of the characters in the translation entity are located, and the characters in the translation entity are position-coded according to the starting position and the ending position to obtain a first position sequence of the translation entity.
6. The intelligent alignment method for entity characters as claimed in claim 1, characterized in that: The step of segmenting the entity characters in the translation entity to obtain segmented entity characters includes: Character information in the entity characters is identified, and the character information is segmented according to a preset segmentation order to obtain segmented entity characters.
7. An intelligent alignment device for physical characters, characterized in that: The device comprises: A named entity annotation module is used to obtain a sentence text to be translated and annotate the named entities in the sentence text; A translation matching module is configured to perform vector position encoding on the sentence text and the named entity using the encoding layer of the trained neural translation model to obtain an encoding position vector, perform feature encoding on the encoding position vector using the encoder of the neural translation model to obtain a feature encoding vector, decode the feature encoding vector using the decoder of the neural translation model to obtain a decoded feature vector, obtain a translation text and a translation entity based on the decoded feature vector, and match the translation text with the translation entity using a preset matching algorithm; a position sequence marking module, configured to obtain a first position sequence of the translation entity in the translation text when the translation text successfully matches the translation entity, and mark a final position sequence of the named entity in the translation text based on the first position sequence; A character segmentation module is used for, when the translation text fails to match the translation entity, segmenting the entity characters in the translation entity to obtain segmented entity characters, locating the starting segmentation character and the ending segmentation character of the segmented entity characters, searching for the first position of the starting segmentation character in the translation text, and searching for the second position of the ending segmentation character in the translation text, combining the characters between the first position and the second position in a preset order to obtain a combined character, and when the segmented entity characters are consistent with the combined characters, using the position sequence of the combined characters as the second position sequence of the translation entity in the translation text, and marking the final position sequence of the named entity in the translation text according to the second position sequence.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the intelligent alignment method of entity characters as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the computer program implements the intelligent alignment method of entity characters as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Cross-language knowledge graph-oriented Chinese-Thai entity alignment method
CN111723587A