Page processing method and device, computer device and computer readable storage medium

CN116502597BActive Publication Date: 2026-10-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210060759.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-19
Publication Date
2026-10-27
Estimated Expiration
2042-01-19

AI Technical Summary

Technical Problem

[0004]然而,目前翻译应用提供的对照翻译功能,原文数据和译文数据的匹配度不高,导致对照阅读的效率下降

Benefits of technology

[0054]本申请第五方面提供一种计算机程序产品,包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现第一方面所提供的页面处理方法中的步骤。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116502597B_ABST
    Figure CN116502597B_ABST
Patent Text Reader

Abstract

The application discloses a page processing method and device, computer equipment and a computer readable storage medium. The method displays a contrast translation page. In response to an adjustment operation received by a first display area, third text data is displayed in the first display area and fourth text data is displayed in a second display area. The third text data is obtained by adjusting first text data according to a first adjustment parameter corresponding to the adjustment operation. The fourth text data is obtained by adjusting second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the text size difference between a first language and a second language. The method can effectively improve the matching degree of original text data and translation text data in the contrast translation process, thereby improving the efficiency of contrast reading.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a page processing method, apparatus, computer device, and computer-readable storage medium. Background Technology

[0002] Currently, as people participate in more and more international exchanges in their daily lives and work, they frequently need to use foreign languages ​​for communication and learning. For example, in academic research, it is often necessary to consult and study foreign language literature in order to integrate and exchange ideas, and to improve each other's skills.

[0003] When reading foreign language literature, researchers often use the comparative translation function provided by translation applications to assist in reading and improve the efficiency of reading and understanding the literature.

[0004] However, the current translation apps' comparative translation functions do not match the source and translation data very well, resulting in a decrease in the efficiency of comparative reading. Summary of the Invention

[0005] This application provides a page processing method, apparatus, computer device, and computer-readable storage medium. The method can effectively improve the matching degree between source text data and translation data during the comparative translation process, thereby improving the efficiency of comparative reading.

[0006] The first aspect of this application provides a page processing method, the method comprising:

[0007] The comparison translation page includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data.

[0008] In response to an adjustment operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation. The fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the text size difference between the first language and the second language.

[0009] Accordingly, a second aspect of this application provides a page processing apparatus, the apparatus comprising:

[0010] A first display unit is used to display a translation page, the translation page including a first display area and a second display area, the first display area including first text data in a first language, and the second display area including second text data in a second language corresponding to the first text data;

[0011] The second display unit is configured to respond to an adjustment operation received from the first display area by displaying third text data in the first display area and fourth text data in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the text size difference between the first language and the second language.

[0012] In some embodiments, the second display unit includes:

[0013] The first display subunit is used to display a scroll bar in the first display area;

[0014] The second display subunit is configured to display third text data in the first display area and fourth text data in the second display area in response to a drag operation on the scroll bar.

[0015] In some embodiments, the second display unit is further configured to:

[0016] In response to a swipe operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area.

[0017] In some embodiments, the second display unit includes:

[0018] The first determining subunit is used to determine the first adjustment parameter corresponding to the adjustment operation;

[0019] The calculation subunit is used to calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing corresponding to the first edge of the first display area, and the second sentence spacing corresponding to the first sentence spacing.

[0020] The second determining subunit is used to determine the adjusted third text data based on the first adjustment parameter and the first text data, and to determine the adjusted fourth text data based on the second adjustment parameter and the second text data.

[0021] The third display subunit is configured to display the third text data in the first display area and the fourth text data in the second display area.

[0022] In some embodiments, the first display unit includes:

[0023] A generation subunit is used to receive source text data in the first language to be translated and to generate a first document object model view corresponding to the source text data.

[0024] The translation subunit is used to extract subtext data from each text node in the first document object model view and translate the subtext data into translated data in a second language.

[0025] The replacement sub-unit is used to replace the sub-text data in the corresponding text node with the translated data to obtain a second document object model view;

[0026] The third determining subunit is used to determine the first text data in the first document object model view based on the parameter information of the initial display area, and to determine the second text data in the second document object model view based on the parameter information of the initial display area.

[0027] The fourth display subunit is used to display the comparison translation page, and to display the first text data in the first display area of ​​the comparison translation page, and to display the second text data in the second display area of ​​the comparison translation page.

[0028] In some embodiments, the generating subunit includes:

[0029] The first receiving module is used to receive the source text document in the first language to be translated, and send the source text document to a preset server for data conversion;

[0030] The second receiving module is used to receive the Hypertext Markup Language data returned by the preset server, and construct document object model nodes based on the Hypertext Markup Language data;

[0031] The rendering module is used to determine the layout structure of the document object model nodes and render the document object model nodes based on the layout structure to obtain a first document object model view.

[0032] In some embodiments, the computing subunit includes:

[0033] The first determining module is used to determine, in the first document object model view, the position of the first statement start point and the position of the second statement start point closest to the first edge of the display area;

[0034] The first calculation module is used to calculate the first sentence spacing based on the starting position of the first sentence and the starting position of the second sentence.

[0035] The second determining module is used to determine the third statement starting position corresponding to the first statement starting position and the fourth statement starting position corresponding to the second statement starting position in the second document object model view;

[0036] The second calculation module is used to calculate the spacing between the second sentences based on the starting positions of the third and fourth sentences.

[0037] The third calculation module is used to calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing.

[0038] In some embodiments, the second determining module includes:

[0039] The numbering submodule is used to number each sentence in the source text data.

[0040] The acquisition submodule is used to acquire the set of first statements corresponding to the starting position of the first statement and the set of second statements corresponding to the starting position of the second statement.

[0041] The first determination submodule is used to determine, based on the number of each statement, the third statement set corresponding to the first statement set and the fourth statement set corresponding to the second statement set in the second document object model view;

[0042] The second determining submodule is used to determine the starting position of the third statement corresponding to the third statement set and the starting position of the fourth statement corresponding to the fourth statement set.

[0043] In some embodiments, the first computing module includes:

[0044] A submodule is constructed to build a coordinate system with the bottom edge of the first document object model view as the horizontal coordinate and the side edge as the vertical coordinate.

[0045] The third determining submodule is used to determine the first ordinate corresponding to the starting position of the first statement and the second ordinate corresponding to the starting position of the second statement based on the coordinate system.

[0046] The first calculation submodule is used to calculate the first sentence spacing based on the first ordinate and the second ordinate.

[0047] In some embodiments, the third computing module includes:

[0048] An extraction submodule is used to extract the first adjustment distance information and adjustment direction information contained in the first adjustment parameter;

[0049] The second calculation submodule is used to calculate the ratio of the first adjustment distance information to the first sentence spacing;

[0050] The third calculation submodule is used to calculate the product of the ratio and the second sentence spacing to obtain the second adjustment distance information;

[0051] The fourth determining submodule is used to determine the second adjustment parameter based on the second adjustment distance information and the adjustment direction information.

[0052] A third aspect of this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to perform the steps of the page processing method provided in the first aspect of this application.

[0053] A fourth aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the page processing method provided in the first aspect of this application.

[0054] The fifth aspect of this application provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps in the page processing method provided in the first aspect.

[0055] The page processing method provided in this application embodiment displays a translation page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received by the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the difference in text size between the first language and the second language.

[0056] Therefore, the page processing method provided in this application can adjust the adjustment parameters of the source and translation regions according to the differences in text size between different languages ​​when adjusting the content of any area on the comparative translation page. This makes the adjustment range of the source and translation areas more reasonable, thereby effectively improving the matching degree between the source and translation data in the comparative translation process, and thus improving the efficiency of comparative reading. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 This is a schematic diagram of a page processing scenario in this application;

[0059] Figure 2 This is a flowchart illustrating the page processing method provided in this application;

[0060] Figure 3 This is another scenario illustration of page processing in this application:

[0061] Figure 4 This is another schematic diagram of page processing in this application;

[0062] Figure 5 This is another flowchart illustrating the page processing method provided in this application;

[0063] Figure 6 This is a schematic diagram of the structure of the page processing apparatus provided in this application;

[0064] Figure 7 This is a schematic diagram of the structure of the computer device provided in this application. Detailed Implementation

[0065] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0066] This invention provides a page processing method, apparatus, computer device, and computer-readable storage medium. The page processing method can be used in a page processing apparatus. This apparatus can be integrated into a computer device, which can be a terminal or a server. The terminal can be a mobile phone, tablet computer, laptop computer, smart TV, wearable smart device, personal computer (PC), or in-vehicle terminal, etc. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The server can also be a node in a blockchain.

[0067] Please see Figure 1 This is a schematic diagram of a scenario for the page processing method provided in this application. As shown, computer device A displays a translation page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received by the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter based on the difference in text size between the first language and the second language.

[0068] It should be noted that, Figure 1 The illustrated page processing scenario diagram is merely an example. The page processing scenario described in this application is intended to more clearly illustrate the technical solution of this application and does not constitute a limitation on the technical solution provided in this application. Those skilled in the art will understand that, with the evolution of page processing scenarios and the emergence of new business scenarios, the technical solution provided in this application is equally applicable to similar technical problems.

[0069] The implementation scenarios described above will be explained in detail below.

[0070] In related technologies, the comparative translation functions provided by various translation applications typically display the source and translation texts separately. When a user adjusts either the source or translation area, the content displayed in both areas is adjusted synchronously and with the same parameters. However, due to differences between texts in different languages ​​(e.g., Chinese uses pictographs while English uses the Latin alphabet), and variations in text length for expressing the same meaning, particularly with lengthy articles such as scientific literature or lengthy works, adjusting the same parameters during comparative translation can lead to mismatches between the source and translation texts after a period of adjustment. In some cases, the source and translation texts may even be unable to fit on the same page, impacting the efficiency of comparative reading. To address this, this application provides a page processing method to improve the matching degree between source and translation data, thereby enhancing the efficiency of comparative reading.

[0071] This application embodiment will be described from the perspective of a page processing device, which can be integrated into a computer device. The computer device can be a terminal or a server. The terminal can be a mobile phone, tablet computer, laptop computer, smart TV, wearable smart device, personal computer (PC), or in-vehicle terminal, etc. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) acceleration services, and big data and artificial intelligence platforms. Figure 2 The diagram shown is a flowchart of the page processing method provided in this application, which includes:

[0072] Step 101: Display the translation comparison page.

[0073] The comparison translation page can be displayed on the screen of the page processing device. The comparison translation page includes a first display area and a second display area. The first display area displays the source text data in the first language to be translated, and the second display area displays the translated text data in the second language. In some cases, because the source text data to be translated is large, it cannot all be displayed in the first display area. In this case, the data displayed in the first display area may be a portion of the source text data, referred to here as the first text data. Similarly, the translated data may not all be displayed in the second display area. In this case, the data displayed in the second display area may be a portion of the translated data, referred to here as the second text data.

[0074] It is understandable that, since this is a comparative translation, the second text data should also be the translated data obtained by translating the first text data into the second language. Due to the differences in text length between different languages, the second text data may not contain the translated data corresponding to all the text data of the first text data, and the second text data may also contain more text data than the translated data corresponding to all the text data of the first text data.

[0075] The first language is the language of the source text to be translated, and the second language can be a user-defined language or a default language. For example, when translating English documents, the default setting is to translate the English documents into Simplified Chinese; of course, users can also set it to translate the English documents into Traditional Chinese or other languages ​​such as Korean or Japanese.

[0076] In some embodiments, the process of displaying the comparative translation page may include the following steps:

[0077] 1. Receive the source text data in the first language to be translated, and generate the first document object model view corresponding to the source text data;

[0078] 2. Extract subtext data from each text node in the first document object model view, and translate the subtext data into translated data in the second language;

[0079] 3. Replace the sub-text data in the corresponding text nodes with the translated data to obtain the second document object model view;

[0080] 4. Determine the first text data in the first document object model view based on the parameter information of the initial display area, and determine the second text data in the second document object model view based on the parameter information of the initial display area;

[0081] 5. Display the translation comparison page, and display the first text data in the first display area of ​​the translation comparison page, and display the second text data in the second display area of ​​the translation comparison page.

[0082] In this embodiment, when a user needs to translate source text data, they can upload a text document corresponding to the source text, such as a doc (document) format text document, to the page processing device. The page processing device can generate a corresponding Document Object Model (DOM) view based on the uploaded text document, which can be referred to here as the first Document Object Model view or the first DOM view. It is understood that the first DOM view is the overall view displaying the source text data to be translated in the translation application. The Document Object Model is a standard programming interface recommended by the W3C organization for processing Extensible Markup Language (EXPLAIN). It is a platform- and language-independent application programming interface (API) that allows dynamic access to programs and scripts, updating their content, structure, and the style of web page documents. The document can be further processed, and the processing results can be added to the current page. The DOM is a tree-based API document that requires the entire document to be represented in memory during processing.

[0083] The first DOM view is rendered from a DOM tree with multiple DOM nodes according to a certain layout structure. Each DOM node in the DOM tree contains multiple text nodes. Traversing these text nodes yields a sequence of text nodes. The sub-text data contained within this text node sequence continuously forms the source text data.

[0084] Furthermore, the page processing device can extract sub-text data from each text node in the first DOM view, and then send the extracted sub-text data to the translation engine for translation to obtain the translation data in the second language corresponding to each sub-text data.

[0085] Then, by replacing the sub-text data in each text node of the first DOM view with the corresponding translated data, the first DOM view can be updated to the second DOM view. It can be understood that the second DOM view here is the overall view displaying the translated data corresponding to the source text data in the translation application. Moreover, the DOM layout structure of the second DOM view is consistent with that of the first DOM view; only the node content has changed, from source text data to translated data. Because the lengths of the translated data and the source text data differ, the size of the same DOM node will differ between the first and second DOM views.

[0086] Because the display area of ​​the page processing device's screen is limited, it is impossible to display the first DOM view and the second DOM view as a whole; only a portion of the data from the first DOM view and the second DOM view can be displayed.

[0087] like Figure 3 The diagram shown illustrates another scenario of the page processing method provided in this application. As shown, the page processing device generates a first DOM view 10 corresponding to the source text data uploaded by the user. Then, the page processing device replaces the sub-text data in each text node of the first DOM view 10 with the translated text data, obtaining a second DOM view 20 corresponding to the translated text data. Figure 3 This is merely a schematic diagram of one scenario for page processing and should not be construed as limiting the scope of page processing scenarios. Those skilled in the art will understand that, within display area 30, the first display area 31 and the second display area 32 may be arranged vertically rather than horizontally. When the first display area 31 and the second display area 32 are arranged horizontally, the first display area for the first text data corresponding to the source text data can be on the left or right side; no limitation is made here.

[0088] in, Figure 3 The diagram also shows a display area 30 of the page processing device, which can also be called a viewport. Display area 30 includes a first display area 31 and a second display area 32. Due to the limited size of the display screen of the page processing device, the display space of the viewport cannot display all the content of the first DOM view 10 and the second DOM view 20. Therefore, only a portion of the content of the first DOM view 10, namely the first text data 11, and a portion of the content of the second DOM view 20, namely the second text data 21, are displayed. The first text data 11 is displayed in the first display area 31, and the second text data 21 is displayed in the second display area 32.

[0089] Specifically, the content of the first text data 11 and the second text data 21 can be determined in the first DOM view 10 and the second DOM view 20 by parameters of the initial display area, specifically coordinate parameters and height parameters. The coordinates of the top edge of the initial display area can be consistent with the height of the top edge of the initial text in the first DOM view 10 and the second DOM view 20, and the height of the initial display area can be determined based on the height of the display area 30. After determining the initially displayed first and second text data, the page processing device can display a translation page on its monitor. This translation page can be the aforementioned display area 30, which includes a first display area 31 and a second display area 32. The first display area 31 displays the first text data 11, and the second display area 32 displays the second text data 21.

[0090] In some embodiments, receiving source text data in a first language to be translated and generating a first document object model view corresponding to the source text data includes:

[0091] 1.1 Receive the source text document in the first language to be translated, and send the source text document to the preset server for data conversion;

[0092] 1.2 Receive Hypertext Markup Language (HMR) data returned by the preset server, and construct Document Object Model (DOM) nodes based on the HMR data;

[0093] 1.3 Determine the layout structure of the document object model nodes, and render the document object model nodes based on the layout structure to obtain the first document object model view.

[0094] In this embodiment, before generating the first DOM view based on the text document corresponding to the user-uploaded source text data, the page processing device needs to convert the text document of the source text data into a different format. Specifically, the page processing device can call a Hyper Text Markup Language (HTML) service, that is, send the user-uploaded doc format text document to a preset server for format conversion, and then receive the HTML format string data returned by the server. Further, the page processing device constructs DOM nodes based on the returned HTML format string data, then determines the DOM layout structure, and further renders each DOM node according to the DOM layout structure to obtain the first DOM view.

[0095] Step 102: In response to the adjustment operation received in the first display area, display the third text data in the first display area and the fourth text data in the second display area.

[0096] In this embodiment, the first display area can be either a display area showing a portion of the source text data to be translated or a display area showing a portion of the translation data. That is, the first text data displayed in the first display area can be either a portion of the source text data or a portion of the translation data. In other words, the adjustment operation can be adjusting the text data displayed in the display area corresponding to the source text data to be translated or adjusting the text data displayed in the display area corresponding to the translation data. In this embodiment, the third text data can be data obtained by adjusting the first text data according to the first adjustment parameter corresponding to the adjustment operation, and the fourth text data can be data obtained by adjusting the second text data according to the second adjustment parameter. The second adjustment parameter can be a parameter obtained by correcting the first adjustment parameter based on the text size difference between the first and second languages.

[0097] The adjustment operation received by the first display area can be either a scrolling operation or a page-turning operation on the content displayed in the display area. In this embodiment, a scrolling operation is used as an example for explanation. When the adjustment operation is a scrolling operation, the adjustment parameters corresponding to the adjustment operation include the scrolling direction and scrolling distance of the displayed content.

[0098] In some embodiments, in response to an adjustment operation received in a first display area, determining a first adjustment parameter corresponding to the adjustment operation includes:

[0099] a. Display a scroll bar in the first display area;

[0100] b. In response to a drag operation on the scroll bar, determine the drag distance and drag direction corresponding to the drag operation, with the drag distance and drag direction indicating the first adjustment parameter.

[0101] In this embodiment, the user can adjust the text data displayed in the first display area by dragging a scroll bar. Specifically, when displaying a translation page that includes a first display area and a second display area, scroll bars can be displayed in both areas. When a drag operation is detected on either scroll bar, the drag direction and drag distance corresponding to the drag operation are obtained. Dragging the scroll bar can be achieved by clicking with a mouse or by using the mouse scroll bar. The drag direction and drag distance constitute the first adjustment parameters of the adjustment operation.

[0102] In some embodiments, in response to an adjustment operation received in a first display area, determining a first adjustment parameter corresponding to the adjustment operation includes:

[0103] A. In response to the swipe operation received in the first display area, determine the start and end positions of the swipe operation;

[0104] B. Calculate the first adjustment parameter based on the starting and ending positions.

[0105] In this embodiment, the user can adjust the text data displayed in the first display area by tapping and swiping the screen of the page processing device. Specifically, when a tap or swipe operation is detected on the display screen of the page processing device, the start and end positions of the swipe operation are detected. Then, the scrolling direction of the displayed content is determined based on the angle between the direction from the start to the end position of the swipe operation and the scrollable direction of the displayed content. Specifically, the scrollable directions of the displayed content are two opposite directions, such as scrolling up and scrolling down. When the angle between the direction from the start to the end position of the swipe operation and a target scrolling direction is acute, the scrolling direction of the displayed content is determined to be the target scrolling direction. Further, the distance traveled from the start to the end position of the swipe operation in the target scrolling direction can be calculated and determined as the scrolling distance.

[0106] Based on the rolling distance and rolling direction, the first adjustment parameter corresponding to the adjustment operation can be determined.

[0107] In this embodiment of the application, after determining the first adjustment parameter for adjusting the display content in the first display area, a second adjustment parameter for adjusting the display content in the second display area can be further calculated based on the first adjustment parameter.

[0108] The second adjustment parameter also includes the scrolling direction and scrolling distance of the displayed content. The scrolling direction included in the second adjustment parameter is the same as that included in the first adjustment parameter. The scrolling distance of the displayed content included in the second adjustment parameter can be calculated based on the scrolling distance in the first adjustment parameter, combined with the first sentence spacing corresponding to the first edge of the first display area and the second sentence spacing corresponding to the first sentence spacing.

[0109] In some embodiments, in response to an adjustment operation received in a first display area, displaying third text data in a first display area and displaying fourth text data in a second display area includes:

[0110] Determine the first adjustment parameter corresponding to the adjustment operation;

[0111] The second adjustment parameter is calculated based on the first adjustment parameter, the first sentence spacing corresponding to the first edge of the first display area, and the second sentence spacing corresponding to the first sentence spacing.

[0112] The adjusted third text data is determined based on the first adjustment parameter and the first text data, and the adjusted fourth text data is determined based on the second adjustment parameter and the second text data;

[0113] The third text data is displayed in the first display area, and the fourth text data is displayed in the second display area.

[0114] The first edge of the first display area can be set according to reading habits. For example, if the user's reading habit is to adjust the content displayed in the display area by scrolling up and down, the first edge of the first display area can be set to the top edge of the first display area. Alternatively, if the user's reading habit is to adjust the content displayed in the display area by scrolling left and right, the first edge of the first display area can be set to the left edge of the first display area.

[0115] The first sentence spacing corresponding to the first edge can be the distance between the two nearest starting positions to the first edge. Here, the starting position refers to the starting position of a sentence or a set of sentences. For example... Figure 4 The diagram illustrates another scenario of the page processing method provided in this application. As shown, the two sentence starting positions closest to the upper edge of the first display area, i.e., the upper edge of display area 30, are S1 and S2, respectively. As can be seen, starting position S1 is the upper edge of sentence block 111, and starting position S2 is the upper edge of sentence block 112. Sentence blocks 111 and 112 can be a single sentence or a set of multiple sentences. When sentence block 111 or sentence block 112 is a set of multiple sentences in one dimension, the first line of the sentence block contains all or part of the content of each sentence in the set, and the other lines of the sentence block only contain part of the content of the last sentence in the set. For example, when sentence block 111 contains three sentences, numbered 01, 02, and 03, then sentences 01 and 02 are short sentences, and both sentences 01 and 02 are in the first line of sentence block 111. Sentence 03 is a long sentence, which also starts from the first line of sentence block 111 but ends at the end of sentence block 111. After determining the two starting positions S1 and S2, the height difference between S1 and S2 can be calculated to obtain the first sentence spacing corresponding to the first edge.

[0116] Then, the second sentence spacing corresponding to the first sentence spacing in the second DOM view can be further calculated. Then, based on the first sentence spacing, the second sentence spacing, and the first adjustment parameter, a second adjustment parameter is calculated to adjust the content displayed in the second display area. Specifically, when the first adjustment parameter is the parameter for adjusting the content displayed in the viewport of the first DOM view corresponding to the source text data, the second adjustment parameter is the parameter for adjusting the content displayed in the viewport of the second DOM view corresponding to the translated text data.

[0117] In some embodiments, calculating the second adjustment parameter based on the first adjustment parameter, the first sentence spacing corresponding to the first edge of the first display area, and the second sentence spacing corresponding to the first sentence spacing includes:

[0118] 1. In the first document object model view, determine the positions of the first and second statement start points closest to the first edge of the display area;

[0119] 2. Calculate the spacing between the first and second statements based on their starting positions;

[0120] 3. In the second document object model view, determine the starting position of the third statement corresponding to the starting position of the first statement and the starting position of the fourth statement corresponding to the starting position of the second statement;

[0121] 4. Calculate the spacing between the second sentence and the third sentence based on their starting positions;

[0122] 5. Calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing.

[0123] In this embodiment, when an adjustment operation instruction is received at any location in the source text display area or the translated text display area of ​​the translation page, a first adjustment parameter corresponding to the adjustment operation can be determined based on the adjustment operation. Specifically, when the adjustment operation is received in the source text display area, the first adjustment parameter is the parameter for adjusting the content displayed in the source text display area. When the adjustment operation is received in the translated text display area, the first adjustment parameter is the parameter for adjusting the content displayed in the translated text display area. This application uses the example of the first adjustment parameter being the parameter for adjusting the content displayed in the source text display area for further explanation.

[0124] After determining the first adjustment parameter, a second adjustment parameter can be calculated based on the first adjustment parameter to adjust the content displayed in the translation display area.

[0125] Specifically, the relative positions of the current display area (viewport) with the first DOM view and the second DOM view can be determined first. Based on these relative positions, the starting positions of the first and second statements closest to the top edge of the viewport in the first DOM view can be determined. The top edge of the viewport can be located between the first and second statement starting positions (the top edge of the viewport can coincide with either the first or second statement starting position). After determining the first and second statement starting positions, the spacing between the first and second statement starting positions can be calculated.

[0126] Then, the page processing device can further determine the starting position of the third statement corresponding to the starting position of the first statement in the second DOM view, and determine the starting position of the fourth statement corresponding to the starting position of the second statement in the second DOM view. After determining the starting positions of the third and fourth statements in the second DOM view, the page processing device can further calculate the distance between the starting positions of the third and fourth statements to obtain the second statement spacing.

[0127] After calculating the first sentence spacing and the second sentence spacing, a second adjustment parameter can be calculated based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing to adjust the content displayed in the translation display area.

[0128] In some embodiments, calculating the first sentence spacing based on the starting position of the first sentence and the starting position of the second sentence includes:

[0129] 2.1 Construct a coordinate system with the bottom edge of the first document object model view as the x-axis and the side edge as the y-axis;

[0130] 2.2 Determine the first ordinate corresponding to the starting position of the first statement and the second ordinate corresponding to the starting position of the second statement based on the coordinate system;

[0131] 2.3 Calculate the spacing of the first sentence based on the first and second ordinates.

[0132] In this embodiment, a standard two-dimensional coordinate system can be pre-constructed. Specifically, a coordinate system can be constructed with the bottom left corner of the first DOM view as the origin, the bottom edge of the first DOM view as the horizontal axis, and the left side as the vertical axis. Then, based on this coordinate system, the first vertical coordinate of the starting position of the first statement and the second vertical coordinate of the starting position of the second statement are determined.

[0133] Then, by calculating the difference between the first and second ordinates, the spacing between the first and second sentences can be obtained.

[0134] In some embodiments, determining the start position of the third statement corresponding to the start position of the first statement and the start position of the fourth statement corresponding to the start position of the second statement in the second document object model view includes:

[0135] 3.1 Number each sentence in the source text data;

[0136] 3.2 Obtain the set of first statements corresponding to the starting position of the first statement and the set of second statements corresponding to the starting position of the second statement;

[0137] 3.3. Based on the number of each statement, determine the third statement set corresponding to the first statement set and the fourth statement set corresponding to the second statement set in the second document object model view;

[0138] 3.4 Determine the starting position of the third statement corresponding to the third statement set and the starting position of the fourth statement corresponding to the fourth statement set.

[0139] In this embodiment, the calculation of the second sentence spacing can be aided by numbering the text sentences. Specifically, each sentence in the source text data can be numbered to obtain a numbering sequence. Identifying a sentence in the source text data can be done using punctuation recognition or a natural language processing model. It is understood that after translating the source text data to obtain the translation data, the sentence numbers in the source text data are still retained in the translated text. That is, the sentence numbered 03 in the source text will still have the sentence number 03 in the translation data.

[0140] Thus, after determining the starting positions of the first and second statements in the first DOM view based on the top edge of the viewport, the first statement set corresponding to the first statement's starting position and the second statement set corresponding to the second statement's starting position can be determined respectively. It can be understood that the first and second statement sets can contain only one statement element or multiple statement elements. Furthermore, the first number set corresponding to the first statement set and the second number set corresponding to the second statement set can be determined based on the number of each sentence.

[0141] After determining the first and second numbered sets, we can further search for the first set of translated sentences corresponding to the first numbered set in the second DOM view, also known as the third set of sentences; similarly, we can search for the second set of translated sentences corresponding to the second numbered set in the second DOM view, also known as the fourth set of sentences. The third and fourth set of sentences each form a sentence block, and the upper edges of these sentence blocks can be determined as the starting positions of the third and fourth sentences, respectively.

[0142] In some embodiments, calculating the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing includes:

[0143] 5.1 Extract the first adjustment distance information and adjustment direction information contained in the first adjustment parameter;

[0144] 5.2 Calculate the ratio of the first adjustment distance information to the first sentence spacing;

[0145] 5.3 Calculate the product of the ratio and the spacing of the second sentence to obtain the second adjustment distance information;

[0146] 5.4 Determine the second adjustment parameters based on the second adjustment distance information and the adjustment direction information.

[0147] In this embodiment, after obtaining the first adjustment parameter, the first sentence spacing, and the second sentence spacing, a second adjustment parameter for adjusting the displayed content of the translation display area can be calculated based on these parameters. Specifically, the first adjustment distance information and adjustment direction information can be extracted from the first adjustment parameter. As mentioned earlier, the adjustment direction of the second adjustment parameter is the same as that of the first adjustment parameter, but the adjustment distance differs. Then, the ratio of the first adjustment distance to the first sentence spacing can be calculated, and the product of this ratio and the aforementioned second sentence spacing can be further calculated to obtain the second adjustment distance. Thus, the second adjustment parameter is determined.

[0148] In some cases, the second sentence spacing may be 0, resulting in a calculated second adjustment distance of 0. In such cases, when the content displayed in the source text display area is adjusted, the content displayed in the translation display area remains unchanged. Specifically, a second sentence spacing of 0 can occur when the third sentence set consists of short sentences, and the total length of the third sentence set is less than one line. In this case, the starting position of the third sentence in the third sentence set is the same as the starting position of the fourth sentence in the fourth sentence set. Therefore, the second sentence spacing is 0, and the calculated second adjustment distance is also 0. This means that when the content displayed in the source text display area changes, the content displayed in the translation display area may remain unchanged. Similarly, when the content displayed in the translation display area is adjusted, the content displayed in the source text display area may not change.

[0149] Specifically, after determining the first text data displayed in the first display area before adjustment and the first adjustment parameter for adjusting the displayed content in the first display area, the third text data that should be displayed in the first display area after adjustment can be determined in the first DOM view based on the first adjustment parameter. Similarly, after determining the second text data displayed in the second display area before adjustment and the second adjustment parameter for adjusting the displayed content in the second display area, the fourth text data that should be displayed in the second display area after adjustment can be determined in the second DOM view based on the second adjustment parameter.

[0150] After determining the third text data to be displayed in the first display area and the fourth text data to be displayed in the second display area following the adjustment operation, the aforementioned third text data can be displayed in the first display area and the aforementioned fourth text data can be displayed in the second display area. This achieves synchronous adjustment of the source text and the translation, and the adjustment range is corrected according to the sentence spacing near the edge of the viewport, ensuring that the source text and the translation remain consistent at all times.

[0151] When the span of the adjustment operation is large, the large-span adjustment operation can be divided into multiple sub-adjustment operations, and then the smaller adjustment operations can be executed one by one to achieve smooth scrolling.

[0152] Furthermore, to avoid frequent adjustments leading to decreased response efficiency, each DOM node element and its related parameters can be stored in a cache, thereby improving the response efficiency of adjustment operations.

[0153] As described above, the page processing method provided in this application embodiment displays a translation page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received by the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the difference in text size between the first language and the second language.

[0154] Therefore, the page processing method provided in this application can adjust the adjustment parameters of the source and translation regions according to the differences in text size between different languages ​​when adjusting the content of any area on the comparative translation page. This makes the adjustment range of the source and translation areas more reasonable, thereby effectively improving the matching degree between the source and translation data in the comparative translation process, and thus improving the efficiency of comparative reading.

[0155] This application also provides a page processing method that can be used in a computer device, which may be a terminal. Figure 5 The diagram shown is another flowchart illustrating the page processing method provided in this application. The method specifically includes:

[0156] Step 201: The computer device receives the doc document in the first language to be translated.

[0157] In this embodiment, the computer device can be a personal computer or a mobile phone. The application for translating the source text data to be translated can be a translation website accessed through a browser. When a user needs to translate the source text data to be translated, they can upload a .doc format source text document in the first language to be translated to the browser.

[0158] Step 202: The computer device calls the HTML conversion service to convert the doc document to HTML, and obtains an HTML string.

[0159] Since doc format files cannot be previewed in a browser, in this application, when a doc format source text document is received, the computer device can invoke an HTML conversion service to convert the doc format source text document. Specifically, the computer device can send the doc format source text document to a server for format conversion and receive the HTML string returned by the server after conversion.

[0160] Step 203: The computer device constructs a DOM tree based on the HTML string and performs layout and rendering to obtain the first document view.

[0161] In this process, after receiving the HTML string returned by the server, the computer device can extract all the content of the `body` tag from the HTML string and render it in the browser to obtain the first document view, or first DOM view, corresponding to the source text. Specifically, the computer device can parse the HTML string returned by the server into a DOM tree, which contains multiple text nodes. The text content contained in these text nodes, when connected, constitutes the text content of the source text document. Then, the computer device lays out each DOM node in a top-to-bottom, left-to-right order. After the layout is completed, it is further rendered to obtain the final first DOM view.

[0162] Step 204: The computer device translates the text in each text node of the DOM tree to obtain the translation information in the second language.

[0163] In this DOM, all text nodes in the constructed document can be stored sequentially in an array. The text content of each text node is then sent to a translation engine for translation. The translation engine segments the received text into sentences, translates the segments according to the set second language information, and returns the second language translation result to the computer. Upon receiving the translated data, the computer stores the translated data corresponding to the text contained in each text node back into the original array for safekeeping.

[0164] Step 205: The computer device replaces the text in each text node of the first document view with the translated information to obtain the second document view.

[0165] Then, the computer device reuses the DOM structure of the first DOM view and replaces the text data in the first language contained in each text node of the first DOM view with its corresponding translation data, thereby obtaining the second document view, i.e., the second DOM view. Please continue reading. Figure 3 After the above processing, the computer equipment obtains a first DOM view 10 corresponding to the source text data and a second DOM view 20 corresponding to the translated text data. At this point, the first DOM view corresponding to the source text data and the second DOM view corresponding to the translated text data are determined and will not change in subsequent adjustments. The only changes are the portions of each DOM view displayed in the display area 30 (i.e., the viewport).

[0166] Step 206: The computer device determines the first text information corresponding to the display area in the first document view, and determines the second text information corresponding to the display area in the second document view.

[0167] Furthermore, the computer equipment formats the DOM nodes corresponding to the source and translated texts based on the sentence segmentation information in the source and translated text data, marking each sentence in the source and translated text data so that each sentence is surrounded by several marked DOM nodes. Specifically, marking statements in DOM nodes is divided into three cases, taking "This is a sentence" as a complete sentence as an example:

[0168] 1. If a sentence is contained within a single DOM node, then...

[0169] DOM nodes before the tag: This is a sentence.

[0170] Marked DOM nodes: <p class=”translate-root translate-a”>This is a sentence.

[0171]

[0172] 2. If a sentence is contained within a DOM node, but that node contains other content, then...

[0173] DOM nodes before the tag: This is a sentence.

[0174] Marked DOM nodes:

[0175]

[0176] 3. If a sentence is contained within multiple DOM nodes, then...

[0177] DOM nodes before the tag: xxx This is A sentence talk.

[0178] xxx

[0179] Marked DOM nodes:

[0180]

[0181]

[0182] Here, `translate-root` is a DOM tag that marks this as a container for a specific sentence, and `translate-xxx` (xxx = a, b, c) is DOM identifier information that indicates which sentence it belongs to. For example, if the DOM tag for a sentence is `translate-a`, then the tag for that sentence is `a`. After tagging each sentence, the correspondence between the original text and the translation can be clearly obtained.

[0183] After processing the relevant data, the computer device can display the first DOM view and the second DOM view in the display area of ​​the computer device. Specifically, the computer device first determines the initial display area, which is the area where the top edge of the display area coincides with the top edge of both the first and second DOM views. Then, based on the height of the display area, the computer device extracts the first text data and the second text data corresponding to the height of the display area from the first and second DOM views, respectively.

[0184] Step 207: The computer device displays the first text information in the first display area of ​​the display screen and the second text information in the second display area.

[0185] The computer device's display screen includes a first display area and a second display area. The computer device displays first text information in the first display area and second text information in the second display area. The first and second display areas are independent of each other and can be adjusted separately.

[0186] Step 208: In response to the adjustment operation received in the first display area, the computer device determines a first sentence block and a second sentence block associated with the upper edge of the display area in the first document view.

[0187] When a first or second display area in a computer device receives an adjustment operation, it can trigger changes to the display content of that display area and the other display area. In this application, the example of receiving an adjustment operation in the first display area will be used for illustration.

[0188] When an adjustment operation is received in the first display area of ​​the computer device's screen, the computer device can obtain the first adjustment parameter corresponding to the adjustment operation. The first adjustment parameter includes the scrolling direction and scrolling distance for scrolling the display content in the first display area.

[0189] Then, the computer device further determines, within the first DOM view, a first sentence block and a second sentence block associated with the top edge of the current display area. Determining the first and second sentence blocks associated with the top edge of the current display area can be done by identifying the first sentence block closest to the top edge of the display area among all sentence blocks whose starting point is above it, and the second sentence block closest to the top edge of the display area among all sentence blocks whose starting point is below it. That is, the top edge of the display area is located between the starting points of the first and second sentence blocks (the top edge of the display area can coincide with either starting point).

[0190] The first sentence block and the second sentence block can contain one sentence element or multiple sentence elements.

[0191] Step 209: The computer device determines, in the second document view, the third sentence block corresponding to the first sentence block and the fourth sentence block corresponding to the second sentence block.

[0192] Once the first sentence block is determined, the set of first statements contained within it can be obtained, and the set of first statement identifiers corresponding to that set can be determined. Then, based on the set of first statement identifiers, the set of third statements can be determined in the second DOM view, and consequently, the third sentence block can be determined in the second DOM view based on the set of third statements.

[0193] Similarly, after determining the second sentence block, the set of second statements contained within the second sentence block can be obtained, and the set of second statement identifiers corresponding to the second statement set can be determined. This allows for the further determination of the fourth statement set in the second DOM view based on the second statement identifier set, and subsequently, the fourth sentence block can be determined in the second DOM view based on the fourth statement set.

[0194] Step 210: The computer device acquires the first adjustment parameter corresponding to the adjustment operation, and calculates the second adjustment parameter based on the first adjustment parameter, the first distance between the first sentence block and the second sentence block, and the second distance between the third sentence block and the fourth sentence block.

[0195] As previously mentioned, the computer device can determine adjustment parameters based on the adjustment operations received in the first display area. These parameters include the adjustment direction and a first adjustment distance x1. Since the computer device has already determined the first and second sentence blocks in the first DOM view, and the third and fourth sentence blocks in the second DOM view, the first distance between the starting points of the first and second sentence blocks can be calculated, i.e., the height difference h1 between the top edge of the first sentence block and the top edge of the second sentence block. Then, the second distance h2 between the third and fourth sentence blocks can be calculated using the same method.

[0196] Furthermore, the adjustment distance x2 for adjusting the display content in the second display area can be calculated based on the first adjustment distance x1, the first distance h1, and the second distance h2. Where x2 = x1 * h2 / h1.

[0197] Step 211: The computer device determines third text information in the first document view based on the first text information and the first adjustment parameter, and determines fourth text information in the second document view based on the second text information and the second adjustment parameter.

[0198] Specifically, after determining the first adjustment parameter for adjusting the content displayed in the first display area and the second adjustment parameter for adjusting the content displayed in the second display area, the third text information that should be displayed in the first display area after the adjustment operation can be determined in the first DOM view based on the first text information in the first display area before adjustment and the first adjustment parameter. Similarly, the fourth text information that should be displayed in the second display area after the adjustment operation can be determined in the second DOM view based on the second adjustment parameter and the second text information.

[0199] Step 212: The computer device displays the third text information in the first display area and the fourth text information in the second display area.

[0200] Once the adjustment operation determines the third text information that should be displayed in the first display area and the fourth text information that should be displayed in the second display area, the computer device can then display the aforementioned third text information in the first display area and the aforementioned fourth text information in the second display area, thereby completing the adjustment of the display area.

[0201] As described above, the page processing method provided in this application involves displaying a translation page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received by the first display area, a first adjustment parameter corresponding to the adjustment operation is determined. A second adjustment parameter is calculated based on the first adjustment parameter, a first sentence spacing corresponding to a first edge of the first display area, and a second sentence spacing corresponding to the first sentence spacing. Adjusted third text data is determined based on the first adjustment parameter and the first text data, and adjusted fourth text data is determined based on the second adjustment parameter and the second text data. The third text data is displayed in the first display area, and the fourth text data is displayed in the second display area.

[0202] Therefore, the page processing method provided in this application can adjust the adjustment parameters of the source and translation regions according to the differences in text size between different languages ​​when adjusting the content of any area on the comparative translation page. This makes the adjustment range of the source and translation areas more reasonable, thereby effectively improving the matching degree between the source and translation data in the comparative translation process, and thus improving the efficiency of comparative reading.

[0203] To better implement the above page processing method, this application also provides a page processing device that can be integrated into a terminal or server.

[0204] For example, such as Figure 6The diagram shown is a schematic representation of the page processing apparatus provided in an embodiment of this application. The page processing apparatus may include a first display unit 301 and a second display unit 302, as follows:

[0205] The first display unit 301 is used to display a translation page. The translation page includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data.

[0206] The second display unit 302 is configured to respond to an adjustment operation received from the first display area by displaying third text data in the first display area and fourth text data in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the text size difference between the first language and the second language.

[0207] In some embodiments, the second display unit includes:

[0208] The first display subunit is used to display a scroll bar in the first display area;

[0209] The second display subunit is configured to display third text data in the first display area and fourth text data in the second display area in response to a drag operation on the scroll bar.

[0210] In some embodiments, the second display unit is further configured to:

[0211] In response to a swipe operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area.

[0212] In some embodiments, the second display unit includes:

[0213] The first determining subunit is used to determine the first adjustment parameter corresponding to the adjustment operation;

[0214] The calculation subunit is used to calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing corresponding to the first edge of the first display area, and the second sentence spacing corresponding to the first sentence spacing.

[0215] The second determining subunit is used to determine the adjusted third text data based on the first adjustment parameter and the first text data, and to determine the adjusted fourth text data based on the second adjustment parameter and the second text data.

[0216] The third display subunit is configured to display the third text data in the first display area and the fourth text data in the second display area.

[0217] In some embodiments, the first display unit includes:

[0218] A generation subunit is used to receive source text data in the first language to be translated and to generate a first document object model view corresponding to the source text data.

[0219] The translation subunit is used to extract subtext data from each text node in the first document object model view and translate the subtext data into translated data in a second language.

[0220] The replacement sub-unit is used to replace the sub-text data in the corresponding text node with the translated data to obtain a second document object model view;

[0221] The third determining subunit is used to determine the first text data in the first document object model view based on the parameter information of the initial display area, and to determine the second text data in the second document object model view based on the parameter information of the initial display area.

[0222] The fourth display subunit is used to display the comparison translation page, and to display the first text data in the first display area of ​​the comparison translation page, and to display the second text data in the second display area of ​​the comparison translation page.

[0223] In some embodiments, the generating subunit includes:

[0224] The first receiving module is used to receive the source text document in the first language to be translated, and send the source text document to a preset server for data conversion;

[0225] The second receiving module is used to receive the Hypertext Markup Language data returned by the preset server, and construct document object model nodes based on the Hypertext Markup Language data;

[0226] The rendering module is used to determine the layout structure of the document object model nodes and render the document object model nodes based on the layout structure to obtain a first document object model view.

[0227] In some embodiments, the computing subunit includes:

[0228] The first determining module is used to determine, in the first document object model view, the position of the first statement start point and the position of the second statement start point closest to the first edge of the display area;

[0229] The first calculation module is used to calculate the first sentence spacing based on the starting position of the first sentence and the starting position of the second sentence.

[0230] The second determining module is used to determine the third statement starting position corresponding to the first statement starting position and the fourth statement starting position corresponding to the second statement starting position in the second document object model view;

[0231] The second calculation module is used to calculate the spacing between the second sentences based on the starting positions of the third and fourth sentences.

[0232] The third calculation module is used to calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing.

[0233] In some embodiments, the second determining module includes:

[0234] The numbering submodule is used to number each sentence in the source text data.

[0235] The acquisition submodule is used to acquire the set of first statements corresponding to the starting position of the first statement and the set of second statements corresponding to the starting position of the second statement.

[0236] The first determination submodule is used to determine, based on the number of each statement, the third statement set corresponding to the first statement set and the fourth statement set corresponding to the second statement set in the second document object model view;

[0237] The second determining submodule is used to determine the starting position of the third statement corresponding to the third statement set and the starting position of the fourth statement corresponding to the fourth statement set.

[0238] In some embodiments, the first computing module includes:

[0239] A submodule is constructed to build a coordinate system with the bottom edge of the first document object model view as the horizontal coordinate and the side edge as the vertical coordinate.

[0240] The third determining submodule is used to determine the first ordinate corresponding to the starting position of the first statement and the second ordinate corresponding to the starting position of the second statement based on the coordinate system.

[0241] The first calculation submodule is used to calculate the first sentence spacing based on the first ordinate and the second ordinate.

[0242] In some embodiments, the third computing module includes:

[0243] An extraction submodule is used to extract the first adjustment distance information and adjustment direction information contained in the first adjustment parameter;

[0244] The second calculation submodule is used to calculate the ratio of the first adjustment distance information to the first sentence spacing;

[0245] The third calculation submodule is used to calculate the product of the ratio and the second sentence spacing to obtain the second adjustment distance information;

[0246] The fourth determining submodule is used to determine the second adjustment parameter based on the second adjustment distance information and the adjustment direction information.

[0247] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0248] As described above, the page processing apparatus provided in this application embodiment displays a translation page through a first display unit 301. The translation page includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received by the first display area, the second display unit 302 displays third text data in the first display area and fourth text data in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the difference in text size between the first language and the second language.

[0249] Therefore, the page processing method provided in this application can adjust the adjustment parameters of the source and translation regions according to the differences in text size between different languages ​​when adjusting the content of any area on the comparative translation page. This makes the adjustment range of the source and translation areas more reasonable, thereby effectively improving the matching degree between the source and translation data in the comparative translation process, and thus improving the efficiency of comparative reading.

[0250] This application also provides a computer device, which can be a terminal or a server, such as... Figure 7 The diagram shown is a structural schematic of the computer device provided in this application. Specifically:

[0251] The computer device may include components such as a processing unit 401 with one or more processing cores, a storage unit 402 with one or more storage media, a power module 403, and an input module 404. Those skilled in the art will understand that... Figure 7 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0252] The processing unit 401 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the storage unit 402, and by calling data stored in the storage unit 402. Optionally, the processing unit 401 may include one or more processing cores; preferably, the processing unit 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processing unit 401.

[0253] Storage unit 402 can be used to store software programs and modules. Processing unit 401 executes various functional applications and data processing by running the software programs and modules stored in storage unit 402. Storage unit 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, and web page access); the data storage area may store data created based on the use of the computer device. In addition, storage unit 402 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, storage unit 402 may also include a memory controller to provide processing unit 401 with access to storage unit 402.

[0254] The computer equipment also includes a power supply module 403 that supplies power to various components. Preferably, the power supply module 403 can be logically connected to the processing unit 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply module 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0255] The computer device may also include an input module 404, which can be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0256] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processing unit 401 in the computer device loads the executable files corresponding to the processes of one or more applications into the storage unit 402 according to the following instructions, and the processing unit 401 runs the applications stored in the storage unit 402 to realize various functions, as follows:

[0257] The page displays a translation comparison page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the difference in text size between the first language and the second language.

[0258] It should be noted that the computer device provided in this application embodiment and the method in the above embodiment belong to the same concept. The specific implementation of each of the above operations can be found in the previous embodiments, and will not be repeated here.

[0259] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0260] Therefore, embodiments of the present invention provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:

[0261] The page displays a translation comparison page, which includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. In response to an adjustment operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter according to the difference in text size between the first language and the second language.

[0262] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0263] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0264] Since the instructions stored in the computer-readable storage medium can execute the steps of any of the methods provided in the embodiments of the present invention, the beneficial effects that any of the methods provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.

[0265] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the page processing method described above.

[0266] The page processing method, apparatus, computer device, and computer-readable storage medium provided in the embodiments of the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A page processing method, characterized in that, The method includes: The comparison translation page includes a first display area and a second display area. The first display area includes first text data in a first language, and the second display area includes second text data in a second language corresponding to the first text data. The steps include: receiving source text data in the first language to be translated, and generating a first document object model view corresponding to the source text data; extracting sub-text data from each text node in the first document object model view and translating the sub-text data into translated data in the second language; replacing the sub-text data in the corresponding text nodes with the translated data to obtain a second document object model view; determining the first text data in the first document object model view based on parameter information of the initial display area, and determining the second text data in the second document object model view based on the parameter information of the initial display area; displaying the comparison translation page, showing the first text data in the first display area of ​​the comparison translation page, and showing the second text data in the second display area of ​​the comparison translation page. In response to an adjustment operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation, and the fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter based on the text size difference between the first language and the second language. This step includes: Determine the first adjustment parameter corresponding to the adjustment operation; The second adjustment parameter is calculated based on the first adjustment parameter, the first sentence spacing corresponding to the first edge of the first display area, and the second sentence spacing corresponding to the first sentence spacing. This step includes: determining the first and second sentence starting positions closest to the first edge of the display area in the first document object model view; calculating the first sentence spacing based on the first and second sentence starting positions; determining the third and fourth sentence starting positions corresponding to the first and second sentence starting positions in the second document object model view; calculating the second sentence spacing based on the third and fourth sentence starting positions; and calculating the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing. The adjusted third text data is determined based on the first adjustment parameter and the first text data, and the adjusted fourth text data is determined based on the second adjustment parameter and the second text data; The third text data is displayed in the first display area, and the fourth text data is displayed in the second display area.

2. The method according to claim 1, characterized in that, The step of displaying third text data in the first display area and fourth text data in the second display area in response to an adjustment operation received in the first display area includes: A scroll bar is displayed in the first display area; In response to a drag operation on the scroll bar, third text data is displayed in the first display area and fourth text data is displayed in the second display area.

3. The method according to claim 1, characterized in that, The step of displaying third text data in the first display area and fourth text data in the second display area in response to an adjustment operation received in the first display area includes: In response to a swipe operation received in the first display area, third text data is displayed in the first display area and fourth text data is displayed in the second display area.

4. The method according to claim 1, characterized in that, The step of receiving source text data in a first language to be translated and generating a first document object model view corresponding to the source text data includes: Receive the source text document in the first language to be translated, and send the source text document to a preset server for data conversion; Receive the Hypertext Markup Language data returned by the preset server, and construct a Document Object Model node based on the Hypertext Markup Language data; The layout structure of the document object model node is determined, and the document object model node is rendered based on the layout structure to obtain a first document object model view.

5. The method according to claim 1, characterized in that, Determining the starting position of the third statement corresponding to the starting position of the first statement and the starting position of the fourth statement corresponding to the starting position of the second statement in the second document object model view includes: Each sentence in the source text data is assigned a sentence number; Get the set of first statements corresponding to the starting position of the first statement and the set of second statements corresponding to the starting position of the second statement; Based on the number of each statement, determine the third statement set corresponding to the first statement set and the fourth statement set corresponding to the second statement set in the second document object model view; Determine the starting position of the third statement corresponding to the third statement set and the starting position of the fourth statement corresponding to the fourth statement set.

6. The method according to claim 1, characterized in that, The calculation of the first sentence spacing based on the starting positions of the first and second sentences includes: Construct a coordinate system with the bottom edge of the first document object model view as the x-coordinate and the side edge as the y-coordinate; Based on the coordinate system, determine the first ordinate corresponding to the starting position of the first statement and the second ordinate corresponding to the starting position of the second statement; The spacing between the first and second vertical coordinates is calculated.

7. The method according to claim 1, characterized in that, The step of calculating the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing includes: Extract the first adjustment distance information and adjustment direction information contained in the first adjustment parameter; Calculate the ratio of the first adjustment distance information to the first sentence spacing; Calculate the product of the ratio and the second sentence spacing to obtain the second adjustment distance information; The second adjustment parameter is determined based on the second adjustment distance information and the adjustment direction information.

8. A page processing apparatus, characterized in that, The device includes: A first display unit is configured to display a translation comparison page, the translation comparison page including a first display area and a second display area, the first display area including first text data in a first language, and the second display area including second text data in a second language corresponding to the first text data; the first display unit includes: a generation subunit, configured to receive source text data in the first language to be translated, and generate a first document object model view corresponding to the source text data; a translation subunit, configured to extract subtext data from each text node in the first document object model view, and translate the subtext data into translated data in the second language; a replacement subunit, configured to replace the subtext data in the corresponding text node with the translated data to obtain a second document object model view; a third determination subunit, configured to determine the first text data in the first document object model view according to the parameter information of the initial display area, and to determine the second text data in the second document object model view according to the parameter information of the initial display area; a fourth display subunit, configured to display the translation comparison page, display the first text data in the first display area of ​​the translation comparison page, and display the second text data in the second display area of ​​the translation comparison page; A second display unit is configured to respond to an adjustment operation received from the first display area by displaying third text data in the first display area and fourth text data in the second display area. The third text data is data obtained by adjusting the first text data according to a first adjustment parameter corresponding to the adjustment operation. The fourth text data is data obtained by adjusting the second text data according to a second adjustment parameter. The second adjustment parameter is obtained by correcting the first adjustment parameter based on the text size difference between the first language and the second language. The second display unit includes: The first determining subunit is used to determine the first adjustment parameter corresponding to the adjustment operation; A calculation subunit is configured to calculate a second adjustment parameter based on the first adjustment parameter, a first sentence spacing corresponding to a first edge of a first display area, and a second sentence spacing corresponding to the first sentence spacing; specifically, the calculation subunit is configured to: determine, in the first document object model view, the first sentence start position and the second sentence start position closest to the first edge of the display area; calculate the first sentence spacing based on the first sentence start position and the second sentence start position; determine, in the second document object model view, a third sentence start position corresponding to the first sentence start position and a fourth sentence start position corresponding to the second sentence start position; calculate the second sentence spacing based on the third sentence start position and the fourth sentence start position; and calculate the second adjustment parameter based on the first adjustment parameter, the first sentence spacing, and the second sentence spacing. The second determining subunit is used to determine the adjusted third text data based on the first adjustment parameter and the first text data, and to determine the adjusted fourth text data based on the second adjustment parameter and the second text data. The third display subunit is configured to display the third text data in the first display area and the fourth text data in the second display area.

9. The apparatus according to claim 8, characterized in that, The second display unit includes: The first display subunit is used to display a scroll bar in the first display area; A first determining subunit is configured to display third text data in the first display area and fourth text data in the second display area in response to a drag operation on the scroll bar.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the page processing method according to any one of claims 1 to 7.

11. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the page processing method according to any one of claims 1 to 7.

12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the page processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Bilingual contrast reading method, terminal and computer storage medium

    CN111753556A

  • Closed Caption Translation Apparatus and Method of Translating Closed Captioning

    US20100118189A1