Translation method and system for electronic document containing rich text field and medium
By dividing the units to be translated and using two translation engines to process plain text and rich text fields, selecting the translation method at the calculation cost, the translation delay problem caused by frequent process switching in the existing technology is solved, and the efficiency of rich text document translation and users are improved. Experience.
Patent Information
- Application Number
- CN202410918660.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-11-12
AI Technical Summary
When translating rich text documents, the prior art frequently calls different parsing and translation engines, resulting in process switching too frequently, affecting the timeliness of the translation process and user experience.
By pre-dividing electronic documents into multiple units to be translated, and using two translation engines to process plain text and rich text fields respectively, the jump cost and direct translation cost are calculated, and the optimal translation method is selected to avoid process switching.
It improves the timeliness of translation of rich text documents, avoids lag problems, improves user experience, and ensures the efficiency of the translation process.
Smart Images

Figure CN118940769A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer-aided translation, and in particular relates to a translation method, system and medium for an electronic document containing a rich text field. Background Art
[0002] "Rich text" is a document editing and presentation technology relative to "plain text". Plain text is generally only expressed as text and punctuation; while rich text contains rich styles and formats, and can insert elements such as pictures, hyperlinks, and tables to enhance the expressiveness and readability of the text.
[0003] Computer-assisted translation technology for plain text is already very mature. However, when the relevant technology is applied to rich text documents containing a large number of rich text fields, if the translation logic similar to that of plain text is continued, the readability of the rich text documents themselves will be reduced.
[0004] For example, Chinese patent application CN201210395210 proposes a method for implementing word retrieval and translation in a rich text editor, including: recording the text to be translated and the translation instructions in the rich text editor in the front end; sending the character string to be translated and the translation instruction corresponding to the text to be translated to the translation background; obtaining the character string to be translated and the translation instruction received by the translation background, and loading the English word mapping file corresponding to the translation instruction; traversing the character string to be translated, splitting the character string to be translated into multiple phrases, and searching the English word mapping file for a word character string that matches the phrase; sending the found word character string to the front end rich text editor; matching and displaying the English word corresponding to the word character string with the phrase of the text to be translated.
[0005] Although the specific content can be obtained and then translated by parsing the inserted images, hyperlinks, tables, etc. contained in the rich text, if the document to be translated contains a large number of rich text fields, directly calling different parsing engines and translation engines each time the translation is started will also cause frequent process switching, making the translation process not timely enough (for example, obvious lags occur), affecting the user experience. Summary of the invention
[0006] In order to solve the above technical problems, the present invention proposes a translation method, system and medium for an electronic document including a rich text field.
[0007] In a first aspect of the present invention, a method for translating an electronic document containing a rich text field is provided, wherein the method is applied to an electronic device, wherein the electronic device contains at least two translation engines;
[0008] The specific technical solution includes the following steps:
[0009] S0: Divide the electronic document into a plurality of units to be translated in advance.
[0010] S1: In response to the output of the Kth translation result for the Kth unit to be translated, determining whether the K+1th unit to be translated contains a rich text domain identifier;
[0011] The K-th translation result for the K-th unit to be translated is output by the first translation engine.
[0012] S2: If the K+1th unit to be translated contains a rich text domain identifier, proceed to step S3; otherwise, proceed to step S6;
[0013] S3: Determine whether there is a translation result for the rich text field corresponding to the rich text field identifier contained in the K+1th unit to be translated. If yes, proceed to step S4; otherwise, proceed to step S5;
[0014] S4: calculating a jump cost from the rich text domain identifier to the translation result, and determining whether to jump to the translation result according to the jump cost;
[0015] S5: using a second translation engine to translate the rich text field corresponding to the rich text field identifier;
[0016] S6: using the first translation engine to translate the K+1th unit to be translated; K is a positive integer, for example, K=1, 2, 3, ...;
[0017] The rich text domain identifier includes one of a hyperlink domain identifier, an audio domain identifier, a video domain identifier, and an image domain identifier, or any combination thereof.
[0018] The step S4 calculates the jump cost from the rich text field identifier to the translation result, specifically including:
[0019] S401: Simulate clicking the rich text field logo to determine the time t1 for loading the translation result and the data volume D of the translation result;
[0020] S402: Obtaining the currently available remaining memory M1 and network transmission rate V1 of the first translation engine;
[0021] S403: Calculate the jump cost S1 according to the following formula (1):
[0022]
[0023] In step S4, determining whether to jump to the translation result according to the jump cost specifically includes:
[0024] S501: Acquire the time t2 of calling the second translation engine and the currently available remaining memory M2 and network transmission rate V2 of the first translation engine;
[0025] S502: Simulate clicking on the rich text identifier, and determine the time t0 for loading the rich text field corresponding to the rich text identifier and the data volume size D0 of the rich text field;
[0026] S503: Calculate the direct translation cost S0 according to formula (2):
[0027]
[0028] S504: If S1 < S0, then jump to the translation result.
[0029] In the second aspect of the present invention, a translation system for an electronic document containing a rich text field is proposed, which can be used to execute the translation method for an electronic document containing a rich text field described in the first aspect.
[0030] In terms of functional units, the system includes an electronic document preprocessing unit, a first translation engine, a unit to be translated identification unit, a rich text field translation result acquisition unit, a jump cost calculation unit, a direct translation cost calculation unit, and a translation selection unit;
[0031] Each functional unit specifically performs the following functions:
[0032] The electronic document preprocessing unit is used to divide the input electronic document to be translated into multiple units to be translated;
[0033] The first translation engine is used to output the K-th translation result of the K-th unit to be translated;
[0034] The unit to be translated identification unit is used to determine whether the (K + 1)-th unit to be translated contains a rich text field identifier;
[0035] The rich text field translation result acquisition unit is used to obtain the translation result corresponding to the rich text field corresponding to the rich text field identifier;
[0036] The jump cost calculation unit is used to calculate the jump cost S1 from the rich text field identifier to the translation result;
[0037] The direct translation cost calculation unit is used to calculate the direct translation cost S0 for directly translating the rich text field corresponding to the rich text field identifier by invoking the second translation engine;
[0038] The translation selection unit is used to select the corresponding translation method based on the comparison result of the jump cost S1 calculated by the jump cost calculation unit and the direct translation cost S0 calculated by the direct translation cost calculation unit, and output the (K + 1)-th translation result of the (K + 1)-th unit to be translated; where K is a positive integer.
[0039] The system technical solution described in the second aspect corresponds to the method technical solution described in the first aspect in terms of functional steps.
[0040] Specifically, calculate the jump cost S1 from the rich text domain identifier to the translation result
[0041] The formula (1) is as follows:
[0042] Wherein, t1 is the time to simulate clicking the rich text domain identifier to determine the loading of the translation result; D is the data volume size of the translation result;
[0043] M1 is the remaining memory available for the first translation engine currently;
[0044] V1 is the current available network transmission rate V1 of the first translation engine.
[0045] The process of calculating the direct translation cost S0 for directly translating the rich text domain corresponding to the rich text domain identifier by calling the second translation engine is as follows:
[0046] Obtain the time t2 for calling the second translation engine, the remaining memory M2 available for the first translation engine currently, and the network transmission rate V2;
[0047] Simulate clicking the rich text identifier to determine the time t0 for loading the rich text domain corresponding to the rich text identifier and the data volume size D0 of the rich text domain;
[0048] Calculate the direct translation cost S0 according to formula (2):
[0049]
[0050] If S1 < S0, then there is no need to repeat the translation this time, and directly use the existing translation result, that is, jump to the translation result (in fact, it also selects a translation method);
[0051] On the contrary, if the jump cost is too high this time, it is better to directly translate, that is, the translation selection unit selects to use the second translation engine to translate the rich text domain corresponding to the rich text domain identifier.
[0052] Specifically, the rich text domain identifier includes one of a hyperlink domain identifier, an audio domain identifier, a video domain identifier, an image domain identifier or any combination thereof;
[0053] At least one of the units to be translated contains at least one rich text domain identifier.
[0054] The method for translating an electronic document containing a rich text field described in the first aspect can be automatically implemented through various forms of electronic devices through computer program instructions; the computer program instructions can be stored in storage media of different forms and loaded into computer electronic devices for execution.
[0055] Therefore, in the third aspect of the present invention, a computer-readable storage medium is also provided for storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes a method for translating an electronic document containing a rich text field as described in the first aspect.
[0056] In a fourth aspect of the present invention, an electronic device is also proposed, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call the instructions in the memory so that the electronic device executes a translation method for an electronic document containing a rich text field.
[0057] Further advantages of the present invention will be further reflected in detail in the specific embodiments section in conjunction with the drawings of the specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 The main flow chart of the method for translating an electronic document containing a rich text field according to an embodiment of the present invention is
[0060] Figure 2 yes Figure 1 Schematic diagram of calculation principle of jump cost of translation process in the embodiment of the method
[0061] Figure 3 Schematic diagram of the functional framework of a translation system for an electronic document including a rich text field according to an embodiment of the present invention
[0062] Figure 4 The present invention is a schematic diagram of an electronic device and a computer-readable storage medium for implementing the method for translating an electronic document containing a rich text field according to the present invention.
[0063] Figure 5 Schematic diagram of an application scenario for implementing the method for translating an electronic document containing a rich text field according to the present invention DETAILED DESCRIPTION
[0064] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments that are the same as the present application. Instead, they are only examples of devices and methods that are the same as some aspects of the present application as detailed in the attached claims.
[0065] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0066] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0067] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0068] It should be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.
[0069] Figure 1 The main flow chart of a method for translating an electronic document containing a rich text field according to an embodiment of the present invention.
[0070] Figure 1 The execution subject of the method is an electronic device, and in particular may be various terminal systems / devices containing electronic documents to be translated.
[0071] The terminal device can be an independent physical server or physical machine, or a computer host running multiple virtual machines, or a server cluster or distributed system composed of multiple physical servers, where the server cluster or distributed system includes cloud servers for providing 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 distribution networks (CDNs), and big data and artificial intelligence platforms, without specific limitation.
[0072] It should be noted that in the specific implementation of this application, if user-related data is involved, when the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0073] As a specific example, the method execution subject is taken as an electronic device.
[0074] The electronic device supports computer-assisted translation technology, for example, it may include a variety of computer translation tools, the translation tools may be in the form of hardware (such as a translation chip processor) or software (such as a translation APP), hereinafter collectively referred to as a translation engine;
[0075] As a non-limiting example, assume that the electronic device includes independent first and second translation engines.
[0076] Figure 1 The method shown includes steps S1-S6 (of course, other branch steps of the method are also included), and the specific functions performed by each step are described in detail below:
[0077] S1: In response to the output of the Kth translation result for the Kth unit to be translated, determining whether the K+1th unit to be translated contains a rich text domain identifier.
[0078] For ease of understanding, for an electronic document to be translated, the method further includes the following steps before step S1 and the following processing step S0:
[0079] S0: Divide the electronic document into a plurality of units to be translated in advance.
[0080] As an example, after receiving the electronic document to be translated, the electronic document content is divided into a plurality of units to be translated based on separators;
[0081] A rough division method may be to divide the electronic document into multiple paragraphs based on paragraph separators, with each paragraph corresponding to a unit to be translated;
[0082] The precise division method may be to divide the electronic document into multiple sentences based on sentence delimiters, with each sentence corresponding to a unit to be translated.
[0083] The specific division method to be adopted can be determined based on experience, input requirements of the translation engine and other factors, and the present invention does not limit this.
[0084] Next, assume that the electronic document contains N units to be translated;
[0085] For K=1, i.e. the first unit to be translated, the traditional computer-assisted translation method can be used to obtain the first translation result; at this time, if the first unit to be translated is plain text (excluding rich text fields), it can be translated directly; if the first unit to be translated contains rich text fields, the inserted pictures, hyperlinks, tables, etc. contained in the rich text can be parsed to obtain its specific content and then translate it.
[0086] It is understandable that for most documents to be translated, the first sentence or the first paragraph of the content usually does not directly contain content containing rich text domains, or only contains a small amount (one) of rich text domain content. Therefore, traditional computer-assisted translation methods can be used.
[0087] After the current (Kth translation result) is output, the next (K+1th unit to be translated) needs to be translated.
[0088] At this time, it is necessary to first determine whether the K+1th unit to be translated contains a rich text domain identifier.
[0089] As a specific example, the rich text domain identifier includes one of a hyperlink domain identifier, an audio domain identifier, a video domain identifier, and an image domain identifier, or any combination thereof.
[0090] It can be understood that the hyperlink domain identifier can be, for example, an identifier with a URL address, and by clicking on the URL address identifier, the corresponding resource file can be accessed through the network;
[0091] The audio domain identifier, video domain identifier, and image domain identifier are similar. By clicking the audio domain identifier, video domain identifier, and image domain identifier, you can access the corresponding audio, video, and image files through the network, or jump to the local storage space to access them.
[0092] It is understandable that in the main content of the document, especially in the middle paragraphs, middle sentences, body paragraphs, etc., the probability of rich text tags appearing is high, and the number of rich text tags appearing is relatively large. At this time, traditional computer-assisted translation technology cannot be directly used.
[0093] Next, step S2 is executed: if the K+1th unit to be translated contains a rich text domain identifier, step S3 is executed; otherwise, step S6 is executed.
[0094] If the unit to be translated has a tag with a URL address, an audio domain tag, a video domain tag, or an image domain tag, it means that the unit to be translated contains a rich text domain tag;
[0095] Considering that the same URL address may appear repeatedly in multiple different units to be translated in an electronic document to be translated, at this time, when it is determined in step S2 that the K+1th unit to be translated contains a rich text domain identifier, the process proceeds to step S3: determining whether there is a translation result for the rich text domain corresponding to the rich text domain identifier contained in the K+1th unit to be translated, if yes, the process proceeds to step S4; otherwise, the process proceeds to step S5.
[0096] The rich text field corresponding to the rich text field identifier contained in the K+1th unit to be translated has a translation result, which means that the unit to be translated has appeared at least once before and has been translated once, and there are available historical stock translation results;
[0097] In the prior art, when there are historical translation results, most of them directly obtain the historical translation results, or directly jump to the historical translation results;
[0098] However, the historical stock translation results may be far away from the current time point, or the data volume of the historical stock translation results may be too small and the current network transmission conditions are not good. There are also negative factors such as the process switching cost caused by the jump. The inventor found that directly jumping to the historical translation results may sometimes not work well. Therefore, in this embodiment, continue to step S4:
[0099] S4: Calculate a jump cost from the rich text field identifier to the translation result, and determine whether to jump to the translation result according to the jump cost.
[0100] Preferably, Figure 2 The calculation process of the jump cost is given as follows:
[0101] S401: Simulate clicking the rich text field logo to determine the time t1 (unit: second, s) for loading the translation result and the data volume D (unit: MB, megabyte) of the translation result;
[0102] S402: Obtain the remaining memory M1 (unit: MB, megabyte) and network transmission rate V1 (unit: MB / s, megabyte / second) currently available to the first translation engine;
[0103] S403: Calculate the jump cost S1 according to the following formula (1):
[0104]
[0105] On this basis, in step S4, determining whether to jump to the translation result according to the jump cost specifically includes:
[0106] S501: Obtain the time t2 (unit: second, s) for calling the second translation engine, the remaining available memory M2 (unit: MB, megabyte) of the second translation engine currently, and the network transmission rate V2 (unit: MB / s, megabyte per second);
[0107] S502: Simulate clicking the rich text identifier, and determine the time t0 (unit: second, s) for loading the rich text field corresponding to the rich text identifier and the data volume size D0 (unit: MB, megabyte) of the rich text field;
[0108] S503: Calculate the direct translation cost S0 according to formula (2):
[0109]
[0110] S504: If S1 < S0, then jump to the translation result.
[0111] If S1 < S0, then there is no need to repeat the translation this time, and directly use the existing translation result, that is, jump to the translation result, and load the translation result to the current interface for display.
[0112] On the contrary, the jump cost this time is too high, and it is better to directly translate. That is, the translation selection unit selects to use the second translation engine to translate the rich text field corresponding to the rich text field identifier.
[0113] Return to another branch of step S3, that is, if there is no translation result for the rich text field corresponding to the rich text field identifier included in the (K + 1)-th unit to be translated, then it is also necessary to enter step S5:
[0114] S5: Use the second translation engine to translate the rich text field corresponding to the rich text field identifier;
[0115] Return to another branch of step S2, that is, if the (K + 1)-th unit to be translated does not include a rich text field identifier, then enter step S6:
[0116] S6: Use the first translation engine to translate the (K + 1)-th unit to be translated;
[0117] K is a positive integer.
[0118] It can be seen that when the K+1th unit to be translated does not contain a rich text domain identifier, there is no need to switch the translation engine, which further reduces the cost; that is, the Kth translation result for the Kth unit to be translated is output by the first translation engine, and the K+1th translation result for the K+1th unit to be translated is still output by the first translation engine.
[0119] When the K+1th unit to be translated contains a rich text domain identifier, it is necessary to select the translation method by calculating the jump cost. If the jump is not selected, the second translation engine will be switched to avoid the cost of frequent process switching. If the jump is selected, it means that the jump cost is lower, and no other process resource support is required (no need to call a new translation engine).
[0120] exist Figure 1-Figure 2 Based on the method embodiment, Figure 3 A schematic diagram showing the functional framework of a translation system for an electronic document containing a rich text field according to an embodiment of the present invention.
[0121] exist Figure 3 In the translation system, the functional framework includes an electronic document preprocessing unit, a first translation engine, a unit to be translated identifying unit, a rich text domain translation result obtaining unit, a jump cost calculating unit, a direct translation cost calculating unit and a translation selecting unit;
[0122] Each functional unit performs the following functions:
[0123] An electronic document preprocessing unit, used for dividing the input electronic document to be translated into a plurality of units to be translated;
[0124] The first translation engine is used to output the Kth translation result of the Kth unit to be translated;
[0125] The unit to be translated identification unit is used to determine whether the K+1th unit to be translated contains a rich text domain identifier;
[0126] A rich text domain translation result obtaining unit, used to obtain a translation result corresponding to the rich text domain corresponding to the rich text domain identifier;
[0127] A jump cost calculation unit, used to calculate a jump cost S1 of jumping from the rich text domain identifier to the translation result;
[0128] A direct translation cost calculation unit, used to calculate a direct translation cost S0 of calling a second translation engine to directly translate the rich text field corresponding to the rich text field identifier;
[0129] A translation selection unit, configured to select a corresponding translation method based on a comparison result between the jump cost S1 calculated by the jump cost calculation unit and the direct translation cost S0 calculated by the direct translation cost calculation unit, and output the (K + 1)-th translation result of the (K + 1)-th unit to be translated; where K is a positive integer.
[0130] The system technical solution described in the second aspect corresponds to the method technical solution described in the first aspect in terms of functional steps.
[0131] Specifically, calculate the jump cost S1 from the rich text domain identifier to the translation result
[0132] The formula (1) is as follows:
[0133] Where t1 is the time for simulating a click on the rich text domain identifier to determine the time for loading the translation result; D is the data volume size of the translation result;
[0134] M1 is the remaining memory available for the first translation engine currently;
[0135] V1 is the current available network transmission rate V1 of the first translation engine.
[0136] The process of calculating the direct translation cost S0 for directly translating the rich text domain corresponding to the rich text domain identifier by invoking the second translation engine is as follows:
[0137] Obtain the time t2 for invoking the second translation engine, the remaining memory M2 available for the second translation engine currently, and the network transmission rate V2;
[0138] Simulate a click on the rich text identifier to determine the time t0 for loading the rich text domain corresponding to the rich text identifier and the data volume size D0 of the rich text domain;
[0139] Calculate the direct translation cost S0 according to formula (2):
[0140]
[0141] If S1 < S0, then there is no need to repeat the translation this time, and the existing translation result can be directly used, that is, jump to the translation result (in fact, a translation method is also selected);
[0142] On the contrary, if the jump cost is too high this time, it is better to directly translate, that is, the translation selection unit selects to use the second translation engine to translate the rich text domain corresponding to the rich text domain identifier.
[0143] Specifically, the rich text domain identifier includes one of or any combination of a hyperlink domain identifier, an audio domain identifier, a video domain identifier, and an image domain identifier;
[0144] At least one of the units to be translated includes at least one rich text field identifier.
[0145] The method for translating an electronic document containing a rich text field mentioned in the above embodiment can be automatically implemented through various forms of electronic devices through computer program instructions; the computer program instructions can be stored in storage media of different forms and loaded into computer electronic devices for execution.
[0146] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0147] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0148] Figure 4 The embodiment schematically shows the relationship between the electronic device and the computer-readable storage medium. Figure 4 The electronic device shown may include: a processor 1002, a memory 1001, a communication component 1003, an audio component 1006, a power component 1005 and a display component 1004. The processor 1002, the memory 1001, the communication component 1003, the audio component 1006, the power component 1005 and the display component 1004 are connected to a computer-readable storage medium via a universal serial bus (USB) interface 130, and computer program instructions are read and loaded into the computer electronic device for execution.
[0149] For more examples, see Figure 5, providing a translation electronic device 10g, the translation electronic device is connected to a translation server 10f, so that the translation server 10f executes the translation method of the electronic document containing the rich text field as described in the first aspect.
[0150] Specifically, the translation server 10f is connected to various terminal devices that generate electronic documents to be translated, including desktop terminals 10a, portable notebook terminals 10b, handheld terminals 10c, etc., through an external direct data access (DMA) interface 10d, to provide computer-assisted translation for the terminal devices.
[0151] It can be seen that the technical solution of the present invention includes at least the following advantages:
[0152] (1) Avoid the problem that the existing technology directly jumps to the historical translation results, which may sometimes have poor results;
[0153] (2) Avoids the problem of repeated resource calls caused by frequent process switching;
[0154] (3) Ability to quickly select the appropriate translation method based on the actual situation of the next unit to be translated.
[0155] (4) The translation response for rich text fields is timely, with no obvious lag issues, which can effectively improve the user experience.
[0156] In various embodiments of the present invention, embodiments of the present invention have been shown and described, but it can be understood by those skilled in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and the scope of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for translating an electronic document containing a rich text field, the method being applied to an electronic device, the electronic device comprising at least two translation engines, characterized in that: The method includes the following steps: S1: In response to the output of the K-th translation result for the K-th unit to be translated, determine whether the (K + 1)-th unit to be translated contains a rich text field identifier; S2: If the (K + 1)-th unit to be translated contains a rich text field identifier, proceed to step S3; otherwise, proceed to step S6; S3: Determine whether there is a translation result for the rich text field corresponding to the rich text field identifier contained in the (K + 1)-th unit to be translated. If so, proceed to step S4; Otherwise, proceed to step S5; S4: Calculate the jump cost from the rich text field identifier to the translation result, and determine whether to jump to the translation result according to the jump cost; S5: Use a second translation engine to translate the rich text field corresponding to the rich text field identifier; S6: Use a first translation engine to translate the (K + 1)-th unit to be translated; K is a positive integer.
2. The translation method of an electronic document containing a rich text field according to claim 1, wherein: The K-th translation result for the K-th unit to be translated is output by the first translation engine.
3. The translation method of an electronic document containing a rich text field according to claim 1, wherein: The rich text field identifier includes one of a hyperlink field identifier, an audio field identifier, a video field identifier, an image field identifier or any combination thereof.
4. The translation method of an electronic document containing a rich text field according to claim 1, wherein: Calculating the jump cost from the rich text field identifier to the translation result in step S4 specifically includes: S401: Simulate clicking the rich text field identifier to determine the time t1 for loading the translation result and the data volume size D of the translation result; S402: Obtain the remaining memory M1 and network transmission rate V1 currently available to the first translation engine; S403: Calculate the jump cost S1 according to the following formula (1):
5. The translation method of an electronic document containing a rich text field according to claim 4, wherein: Determining whether to jump to the translation result according to the jump cost in step S4 specifically includes: S501: Obtain the time t2 for calling the second translation engine and the remaining memory M2 and network transmission rate V2 currently available to the second translation engine; S502: Simulate clicking the rich text identifier to determine the time t0 for loading the rich text field corresponding to the rich text identifier and the data volume size D0 of the rich text field; S503: Calculate the direct translation cost S0 according to formula (2); S504: If S1 < S0, then jump to the translation result.
6. A method for translating an electronic document containing a rich text field as claimed in any one of claims 1 to 5, characterized in that: The method further includes: S0: Divide the electronic document into multiple units to be translated in advance.
7. A translation system for an electronic document containing a rich text field, characterized in that: The system includes: An electronic document preprocessing unit for dividing the input electronic document to be translated into multiple units to be translated; A first translation engine for outputting the K-th translation result of the K-th unit to be translated; A unit to be translated recognition unit for determining whether the (K + 1)-th unit to be translated contains a rich text field identifier; A rich text domain translation result obtaining unit, used to obtain a translation result corresponding to the rich text domain corresponding to the rich text domain identifier; A jump cost calculation unit, used to calculate a jump cost S1 of jumping from the rich text domain identifier to the translation result; A direct translation cost calculation unit, used to calculate a direct translation cost S0 of calling a second translation engine to directly translate the rich text field corresponding to the rich text field identifier; A translation selection unit, configured to select a corresponding translation mode and output a K+1th translation result of the K+1th unit to be translated based on a comparison result between the jump cost S1 calculated by the jump cost calculation unit and the direct translation cost S0 calculated by the direct translation cost calculation unit; Wherein, K is a positive integer.
8. A translation system for an electronic document containing a rich text field as claimed in claim 7, characterized in that: Wherein, t1 is the time for simulating clicking the rich text field logo to determine loading the translation result; D is the data size of the translation result; M1 is the remaining amount of memory currently available to the first translation engine; V1 is the network transmission rate V1 currently available to the first translation engine.
9. A translation system for an electronic document containing a rich text field as claimed in claim 8, characterized in that: The rich text domain identifier includes one of a hyperlink domain identifier, an audio domain identifier, a video domain identifier, and an image domain identifier, or any combination thereof; At least one of the units to be translated includes at least one rich text field identifier.
10. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute a method for translating an electronic document containing a rich text field as claimed in any one of claims 1 to 6.
