Address resolution methods, electronic devices and media
By establishing an address entity dictionary and using a ternary tree search strategy, the problem of inaccurate address translation in machine translation is solved, the accuracy and completeness of translation are improved, the amount of computer calculations is reduced, and the flexible expansion and automatic expansion of the address library are realized. calibration.
Patent Information
- Application Number
- CN202111370407.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-18
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-11-18
AI Technical Summary
Existing machine translation is prone to errors in translation and missing translations when translating addresses, especially during the translation process of long addresses, resulting in inaccurate translations.
The address parsing method is used to build an address entity dictionary and use a ternary tree search strategy to match the address that needs to be translated with the entity address, generate predicted characters to improve the matching accuracy, and determine the most appropriate entity address through matrices and weights.
It improves the accuracy and completeness of address translation, reduces the amount of computer calculations, facilitates the expansion of the address library, and automatically calibrates the translation results through counting.
Smart Images

Figure CN114139558B
Abstract
Description
Technical Field
[0001] The invention relates to a machine language translation method, and in particular to an address resolution method, electronic equipment and a medium. Background Art
[0002] With the deepening of internationalization, there are more and more exchanges between countries, and the demand for translation is increasing. Among different neural machine translation models, models with attention mechanisms have become popular because they can focus on the most relevant parts of the source sentence in the translation sentence generation. This also gives the model an advantage when translating longer sentences.
[0003] Existing machine translation is limited by training data, and the effects vary greatly in different situations. In the general field, some texts of long address translation services, such as hotel addresses, will have problems such as missing or wrong translation of entities in the address during the translation process. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the defects of wrong translation and single omission of addresses in the prior art, and to provide an address resolution method, electronic device and medium.
[0005] The present invention solves the above technical problems through the following technical solutions:
[0006] An address resolution method comprises the steps of:
[0007] S1. Establishing an address entity dictionary, wherein the address entity dictionary includes a plurality of entity addresses and translation texts corresponding to the entity addresses;
[0008] The physical address includes a plurality of characters, the characters are sorted according to the encoding, and the physical address is sorted according to the sorting of the characters;
[0009] S2. Matching the address to be translated with the corresponding entity address;
[0010] The matching of the address to be translated with the corresponding entity address includes:
[0011] Matching the address to be translated with the physical address according to the ternary tree search tree strategy;
[0012] The ternary tree search tree strategy generates a predicted character for the nth character in the address to be translated, where n is a natural number greater than or equal to 1;
[0013] The predicted character is the next possible character to be searched in the physical address dictionary based on the characters that have been matched before the nth character in the address to be translated,
[0014] When the ranking of the nth character in the address to be translated is greater than / less than the ranking of the predicted character, the next predicted character is generated;
[0015] When the order of the nth character in the address to be translated is equal to the order of the predicted characters, the matching of the nth character is completed, and n is increased by 1;
[0016] When the nth character in the address to be translated does not have the predicted character in the physical address dictionary, the nth character in the address to be translated is used as the first character of the next address to be translated, and it is determined that the original address to be translated is matched with the corresponding physical address;
[0017] When it is determined that the original address to be translated is matched with the corresponding physical address, the address to be translated is replaced with the translation text corresponding to the physical address matched with the address to be translated.
[0018] Preferably, the predicted character is the character that has appeared most frequently in history among the next possible characters selected from the characters that have been matched in the physical address dictionary;
[0019] When the nth character in the address to be translated successfully matches the predicted character, the number of occurrences of the character is accumulated.
[0020] Preferably, there are three predicted characters;
[0021] The first predicted character is the character with the smallest order among the characters that may appear in the current entity address dictionary;
[0022] The second predicted character is the character ranked as the median among the characters that may appear in the current entity address dictionary as the first predicted character;
[0023] The third predicted character is the character with the largest ranking among the characters that may appear in the current physical address dictionary.
[0024] Preferably, the physical addresses are established into a matrix, the matrix including several rows, the physical addresses are allocated to corresponding rows according to the physical address information, and different weights are assigned between rows. The different weights between rows are used to determine the most appropriate physical addresses corresponding to each physical address before and after.
[0025] Preferably, the entity address information includes national, provincial units, municipal units, district units, county units, streets and landmark buildings.
[0026] Preferably, step S1 further includes S11, identifying a range of addresses that need to be translated in the text; and step S2 further includes S21, outputting the translated text.
[0027] Preferably, step S11 further includes preprocessing the text and replacing the placeholders of the addresses to be translated;
[0028] Step S21 also includes arranging the translated text in reverse order and replacing the placeholder.
[0029] Preferably, the characters are sorted according to the encoding order and the Unicode code order.
[0030] As a second aspect of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the address resolution method as described above when executing the computer program.
[0031] As a third aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the address resolution method as described above is implemented.
[0032] The positive and progressive effects of the present invention are:
[0033] 1. Different from machine deep learning, by matching the address to be translated with the physical address, and the physical address and the translated text correspond one by one, the accuracy and completeness of the translation can be improved.
[0034] 2. Through the ternary tree search strategy, the number of matches between the address that needs to be translated and the corresponding physical address in the physical address is reduced, which has little impact on the computer's computing power.
[0035] 3. It is convenient to expand the translation address database, making the address translation more accurate.
[0036] 4. The translated address characters are the addresses that are most likely to appear, which can reduce the number of searches. In addition, the translated addresses are counted, and automatic calibration can be performed based on the number of times the translated addresses appear. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a flowchart of the address resolution method according to Embodiment 1 of the present invention.
[0038] Figure 2 It is a schematic diagram of matching an address to be translated with a corresponding entity address in the address resolution method of embodiment 1 of the present invention.
[0039] Figure 3 This is a flow chart of a preferred solution in the address resolution method of embodiment 1 of the present invention.
[0040] Figure 4 This is a schematic diagram of the structure of an electronic device of the address resolution method according to embodiment 2 of the present invention. DETAILED DESCRIPTION
[0041] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.
[0042] Example 1
[0043] See also Figure 1 As shown, this embodiment provides an address resolution method, which includes the following steps:
[0044] S1. Establish an address entity dictionary, which includes a number of entity addresses and translation texts corresponding to the entity addresses;
[0045] The entity address includes a number of characters, the characters are sorted according to the encoding, and the entity address is sorted according to the order of the characters;
[0046] S2. Match the address to be translated with the corresponding entity address;
[0047] Matching the address to be translated with the corresponding entity address includes:
[0048] The address to be translated is matched with the entity address according to the ternary tree search tree strategy;
[0049] The ternary tree search tree strategy generates a predicted character for the nth character in the address to be translated, where n is a natural number greater than or equal to 1;
[0050] The predicted character is the next possible character to be searched in the entity address dictionary based on the characters that have been matched before the nth character in the address to be translated.
[0051] When the order of the nth character in the address to be translated is greater than / less than the order of the predicted character, the next predicted character is generated;
[0052] When the order of the nth character in the address to be translated is equal to the order of the predicted characters, the match of the nth character is completed and n is increased by 1;
[0053] When the nth character in the address to be translated does not have a predicted character in the physical address dictionary, the nth character in the address to be translated is used as the first character of the next address to be translated, and it is determined that the original address to be translated is matched with the corresponding physical address;
[0054] When it is determined that the original address to be translated has been matched with the corresponding physical address, the address to be translated is replaced with a translation text corresponding to the physical address matched with the address to be translated.
[0055] In this embodiment, the address entity depends on the required text, and the address entity can be in various languages, such as Chinese, English, Korean, Japanese, etc. And the translation text is in various languages different from the language of the physical address.
[0056] In the present embodiment, the entity address is Chinese, the translation text is English, and the address that needs to be translated is Beidaihe District Beidai South Beach as an example. When it is determined that the address that needs to be translated is Beidaihe District Beidaihe South Beach, a ternary tree search is performed in the address entity dictionary according to the sorting of "North", such as the first predicted character is "South", and the sorting of "South" is greater than / less than "North", then the second predicted character is a character of the arrangement of less than / greater than "South", and the third predicted character selects the fourth predicted character within the possible sorting of the first predicted character and the second predicted character, and so on, until the character "North" is found to match the first "North" of "Beidaihe District Beidaihe South Beach". After this, the "Wai" in "Beidaihe District Beidaihe South Beach" is searched in the address entity dictionary. After the "District" in "Beidaihe District Beidaihe South Beach" is matched, the second "North" is searched. At this time, since there is only "Beidaihe District" in the address entity dictionary, but there is no address containing "Beidaihe District North", "Beidaihe District" is taken as an address to be translated, and "Beidaihe South Beach" is taken as the next address to be translated. And "Beidaihe District" is replaced with the translation text "Beidaihe District".
[0057] Take the address that needs to be translated as "Room 707, Floor 5, Building 1, Room 1603, Xuchuan Alley, No. 398, Shixin Road, Chaoyang District, Beijing". Therefore, the segmentation result of the address that needs to be translated is "Beijing | Chaoyang District | Shixin Road | No. 398 | Xuchuan Alley | Jinmao Tower | Building 1 | Room 1603 | Floor 5 | Room 707". The result of the address translation is "Room 707, floor 5, room 1603, building 1, Jinmao building, xuchuan alley, No. 398, Shixin Road, Chaoyang District, Beijing"
[0058] When translating, the address to be translated is compared with the address entity dictionary character by character. Since each character is compared, there will be no phenomenon of missing characters. Since all addresses exist in the address entity dictionary, each address will accurately correspond to its translated text. Moreover, the entity addresses in the address entity dictionary can be expanded as needed, which is very convenient.
[0059] As a preferred solution in this embodiment, the predicted character is the character that has appeared most frequently in history among the next possible characters selected from the characters that have been matched in the entity address dictionary.
[0060] When the nth character in the address to be translated successfully matches the predicted character, the number of times the character appears is accumulated.
[0061] For example, the address to be translated is "Beidaihe". When the first character is determined to be "北 (North)", among the address entities in the address entity dictionary where the first character is "北 (North)", "北京市 (Beijing City)" appears the most times. At this time, the first predicted character for the second character in the address to be translated is "京 (Jing)". When it is found that the sorting of "京 (Jing)" is greater than that of "戴 (Dai)", the characters in the address entity dictionary that are less than "京 (Jing)" are used as the next predicted characters. That is, when the first character of "Beidaihe" is "北 (North)" and the sorting of the second character is less than that of "京 (Jing)", and the number of times "Beidaihe" appears is the most among those where the second character is less than "京 (Jing)", then "戴 (Dai)" is used as the second predicted character. When it is finally determined that "Beidaihe" matches "Beidaihe" in the address entity dictionary, the number of times "Beidaihe" appears in the address entity dictionary is accumulated.
[0062] As a preferred embodiment in this embodiment, please refer to Figure 2 .
[0063] At this time, there are three predicted characters. The first predicted character is the character with the smallest sorting among the characters that may appear in the current entity address dictionary.
[0064] The second predicted character is the character with the median sorting among the characters that may appear in the current entity address dictionary where the first predicted character is located.
[0065] The third predicted character is the character with the largest sorting among the characters that may appear in the current entity address dictionary where the first predicted character is located.
[0066] Suppose the entity addresses in the address entity dictionary are "北十 (North Ten)", "北京市 (Beijing City)", "北化 (North Chemical)", "北三 (North Three)", "北海市 (Beihai City)", "北辰镇 (Beichen Town)", "北辰区 (Beichen District)", "北辰湖 (Beichen Lake)", "北戴林 (Beidai Forest)", "北戴河 (Beidaihe)", "北戴市 (Beidai City)", etc. The address to be translated is "北戴河 (Beidaihe)", and the predicted character is the second character "戴 (Dai)" in "北戴河 (Beidaihe)".
[0067] Since the sorting of the second character is: "Hua" > "Jing" > "San" > "Dai" > "Hai" > "Chen". The sorting of the third character is: "Hu" > "Qu" > "Zhen" "Shi" > "He" > "Lin". Therefore, "Beihua" > "Beisan" > "Beijing City" > "Beidai City" > "Beidaihe" > "Beidailin" > "Beihai City" > "Beihai City" > "Beichen Lake" > "Beichen District" > "Beichen Town" > "Beishi".
[0068] When matching "Dai" with its corresponding characters, the first predicted character is "Shi". The second predicted character is "Jing", and the third predicted character is "Hua". When it is found that the character "Dai" is less than "Jing" but greater than "Shi", the next predicted character in the sorting between "Shi" and "Jing" is selected to compare with "Dai". Then, when the next third predicted character is "Dai", it is the same as the second character of the address "Beidaihe" to be translated, that is, the "Dai" in the "Beidaihe" to be translated is the same as the "Dai" in the address entity dictionary. At this time, search for "He". At this time, the first predicted character corresponding to the third character to be translated is "Lin", the second predicted character is "He", and the third predicted character is "Shi". Compare the sorting of "He" with the first predicted character, the second predicted character, and the third predicted character respectively. Since the second predicted character is the same as "He", and when there is no next character of the address to be translated in the entity address. It is determined that the entity address "Beidaihe" in the address entity dictionary matches the address "Beidaihe" to be translated, and the translation text corresponding to the entity address "Beidaihe". Since the second predicted character is the median, the number of predicted characters is reduced to the ceiling of log2N. N is the number of all predicted characters in the entity address. This reduces the computational load of the computer.
[0069] As a preferred embodiment in this embodiment, a matrix is established for entity addresses. The matrix includes several rows, and the entity addresses are allocated to the corresponding rows according to the entity address information, and different weights are assigned between rows. The different weights between rows are used to judge the most suitable entity addresses corresponding to the front and back of each entity address. The entity address information includes country, provincial unit, municipal unit, district unit, county unit, street, and landmark building. In this embodiment, the entity address information also includes scenic area. For example, the weight for the next address of the address to be translated being a county unit is 10000000, the weight for being a district unit is 10000000, the weight for being a street is 10000000, the probability for being a landmark building is 1000000, and the weight after the address to be translated is a landmark building is -100000, and the weight in the rows of other entity address information categories is 0. And in this embodiment, the weights are set artificially, and during the address matching process, the magnitudes of the weights can be changed.
[0070] In this embodiment, in order to put different addresses into corresponding rows, it is to prevent the situation of "West Lake District plus West Lake Scenic Area" from occurring. For example, in this case, "West Lake District" is in the row where the entity address information is a district unit, but West Lake Scenic Area is in the row corresponding to the scenic area. When translating "West Lake District West Lake Scenic Area", "West Lake District" will be translated first and then "West Lake Scenic Area", and the translation texts corresponding to "West Lake District" and "West Lake Scenic Area" will be arranged separately according to the word order of the target prediction, so as to avoid the situation where the same characters appear in different categories of address information.
[0071] As a preferred embodiment of this embodiment, please refer to Figure 3 Step S1 further includes S11, identifying the range of addresses that need to be translated in the text; and step S2 further includes S21, outputting the translated text.
[0072] Step S11 also includes text preprocessing and replacing the placeholders of the addresses to be translated;
[0073] Step S21 also includes arranging the translated text in reverse order and replacing the placeholders.
[0074] The text preprocessing in this embodiment refers to segmenting the text into paragraphs, sentences, and words.
[0075] As a preferred embodiment of the present invention, characters are sorted according to encoding and Unicode codes.
[0076] Example 2
[0077] Figure 4 The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the address resolution method of the first embodiment is implemented. Figure 4 The electronic device 30 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0078] like Figure 4 As shown, the electronic device 30 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 30 may include, but are not limited to: at least one processor 31, at least one memory 32, and a bus 33 connecting different system components (including the memory 32 and the processor 31).
[0079] The bus 33 includes a data bus, an address bus, and a control bus.
[0080] The memory 32 may include a volatile memory, such as a random access memory (RAM) 321 and / or a cache memory 322 , and may further include a read-only memory (ROM) 323 .
[0081] The memory 32 may also include a program / utility 325 having a set (at least one) of program modules 324, such program modules 324 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0082] The processor 31 executes various functional applications and data processing by running the computer programs stored in the memory 32, such as the address resolution method of the first embodiment of the present invention.
[0083] The electronic device 30 may also communicate with one or more external devices 34 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 35. Furthermore, the model-generated device 30 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 36. As shown, the network adapter 36 communicates with other modules of the model-generated device 30 via a bus 33. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (RAID) systems, tape drives, and data backup storage systems.
[0084] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0085] Example 3
[0086] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the address resolution method of Embodiment 1 is implemented.
[0087] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0088] In a possible implementation manner, the present invention may also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the address resolution method of embodiment 1.
[0089] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.
[0090] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that this is only for illustration and the protection scope of the present invention is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but these changes and modifications all fall within the protection scope of the present invention.
Claims
1. An address resolution method, characterized in that: Includes steps: S1. Establishing a physical address dictionary, wherein the physical address dictionary includes a plurality of physical addresses and translation texts corresponding to the physical addresses; The physical address includes a plurality of characters, the characters are sorted according to the encoding, and the physical address is sorted according to the sorting of the characters; S2. Match the address to be translated with the entity address according to the ternary tree search tree strategy; The ternary tree search tree strategy generates a predicted character for the nth character in the address to be translated, where n is a natural number greater than or equal to 1; The predicted character is the character that has appeared most frequently in history among the next possible characters to be searched in the physical address dictionary based on the characters that have been matched before the nth character in the address to be translated; When the ranking of the nth character in the address to be translated is greater than / less than the ranking of the predicted character, the next predicted character is generated; When the order of the nth character in the address to be translated is equal to the order of the predicted characters, the matching of the nth character is completed, and n is increased by 1; When the nth character in the address to be translated successfully matches the predicted character, the number of occurrences of the character is accumulated; When the nth character in the address to be translated does not have the predicted character in the physical address dictionary, the nth character in the address to be translated is used as the first character of the next address to be translated, and it is determined that the original address to be translated is matched with the corresponding physical address; When it is determined that the original address to be translated is matched with the corresponding physical address, the address to be translated is replaced with the translation text corresponding to the physical address matched with the address to be translated.
2. An address resolution method, characterized in that: Includes steps: S1. Establishing a physical address dictionary, wherein the physical address dictionary includes a plurality of physical addresses and translation texts corresponding to the physical addresses; The physical address includes a plurality of characters, the characters are sorted according to the encoding, and the physical address is sorted according to the sorting of the characters; S2. Match the address to be translated with the entity address according to the ternary tree search tree strategy; The ternary tree search tree strategy generates a predicted character for the nth character in the address to be translated, where n is a natural number greater than or equal to 1; The predicted character is the next possible character to be searched in the physical address dictionary based on the characters that have been matched before the nth character in the address to be translated; When the ranking of the nth character in the address to be translated is greater than / less than the ranking of the predicted character, the next predicted character is generated; When the order of the nth character in the address to be translated is equal to the order of the predicted characters, the matching of the nth character is completed, and n is increased by 1; When the nth character in the address to be translated does not have the predicted character in the physical address dictionary, the nth character in the address to be translated is used as the first character of the next address to be translated, and it is determined that the original address to be translated is matched with the corresponding physical address; When it is determined that the original address to be translated is matched with the corresponding physical address, the address to be translated is replaced with the translation text corresponding to the physical address matched with the address to be translated; There are three predicted characters; The first predicted character is the character with the smallest order among the characters that may appear in the current entity address dictionary; The second predicted character is the character ranked as the median among the characters that may appear in the current entity address dictionary as the first predicted character; The third predicted character is the character with the largest ranking among the characters that may appear in the current physical address dictionary.
3. An address resolution method, characterized in that: Includes steps: S1. Establishing a physical address dictionary, wherein the physical address dictionary includes a plurality of physical addresses and translation texts corresponding to the physical addresses; The physical address includes a plurality of characters, the characters are sorted according to the encoding, and the physical address is sorted according to the sorting of the characters; S2. Match the address to be translated with the entity address according to the ternary tree search tree strategy; The ternary tree search tree strategy generates a predicted character for the nth character in the address to be translated, where n is a natural number greater than or equal to 1; The predicted character is the next possible character to be searched in the physical address dictionary based on the characters that have been matched before the nth character in the address to be translated; When the ranking of the nth character in the address to be translated is greater than / less than the ranking of the predicted character, the next predicted character is generated; When the order of the nth character in the address to be translated is equal to the order of the predicted characters, the matching of the nth character is completed, and n is increased by 1; When the nth character in the address to be translated does not have the predicted character in the physical address dictionary, the nth character in the address to be translated is used as the first character of the next address to be translated, and it is determined that the original address to be translated is matched with the corresponding physical address; When it is determined that the original address to be translated is matched with the corresponding physical address, the address to be translated is replaced with the translation text corresponding to the physical address matched with the address to be translated; A matrix is established for the physical addresses, wherein the matrix includes several rows. The physical addresses are allocated to corresponding rows according to the physical address information, and different weights are assigned between rows. The different weights between rows are used to determine the most appropriate physical addresses corresponding to each physical address.
4. The address resolution method according to claim 3, characterized in that: The entity address information includes national, provincial units, municipal units, district units, county units, streets and landmark buildings.
5. The address resolution method according to any one of claims 1 to 3, characterized in that: Step S1 also includes S11, identifying a range of addresses that need to be translated in the text; Step S2 also includes S21, outputting the translated text.
6. The address resolution method according to claim 5, characterized in that: Step S11 also includes preprocessing the text and replacing the placeholders of the addresses to be translated; Step S21 also includes arranging the translated text in reverse order and replacing the placeholder.
7. The address resolution method according to any one of claims 1 to 3, characterized in that: The characters are sorted according to the encoding and Unicode codes.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the address resolution method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the address resolution method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Neural machine translation model training method and neural machine translation method and device
CN111539229A
Address matching method and system based on Chinese word segmentation device
CN112612863A
