Text processing methods, apparatus, storage media, and processors

By dynamically adjusting the file page conversion order and using multi-threaded processing, the problem of low text conversion efficiency in the file preview system was solved, achieving faster response speed and higher conversion efficiency.

CN116187272BActive Publication Date: 2025-12-02GUANGZHOU SHIZHEN INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111434660.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2025-12-02
Estimated Expiration
2041-11-29

AI Technical Summary

Technical Problem

In file preview systems, after a terminal initiates a preview request, the terminal may not necessarily view the files sequentially starting from the homepage. This results in an inability to respond to user requests in a timely manner during the file conversion process, leading to low text conversion efficiency in existing technologies.

Method used

By acquiring the client's query request, the conversion order of file pages is dynamically adjusted, prioritizing the conversion of the page range queried by the user, and a multi-threaded processing method is used to distribute the conversion workload and improve file conversion efficiency.

Benefits of technology

It enables timely responses to user requests during file conversion, reducing user waiting time and improving the overall speed and efficiency of file conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116187272B_ABST
    Figure CN116187272B_ABST
Patent Text Reader

Abstract

This invention discloses a text processing method, apparatus, storage medium, and processor. The method includes: during the conversion of target text according to the original text page order, acquiring a query request sent by a client, wherein the query request requests the target text pages to be converted; responding to the query request, adjusting the original text page order to the target text page order; converting the target text pages according to the target text page order to obtain a conversion result, and sending the conversion result to the client, wherein the conversion result is used to display the text content of the target text pages on the client. This invention solves the technical problem of low efficiency in text conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of control, and more specifically, to a text processing method, apparatus, storage medium, and processor. Background Technology

[0002] Currently, in file preview systems, after a terminal initiates a preview request, the relevant technology converts the file page by page in order. This method always starts from the beginning of the file. However, the terminal may not necessarily start viewing the file from the first page in order. During the file conversion process, the terminal may also request to query the file content of a specified page range. If the starting position of this page range is relatively late, the terminal will continuously poll for query results, thus failing to respond to user requests in a timely manner. This results in a technical problem of low efficiency in text conversion.

[0003] There is currently no effective solution to the aforementioned technical problem of low efficiency in text conversion. Summary of the Invention

[0004] This invention provides a text processing method, apparatus, storage medium, and processor to at least solve the technical problem of low efficiency in text conversion.

[0005] According to one aspect of the present invention, a text processing method is provided. The method may include: during the process of converting target text according to the original text page order of the target text, obtaining a query request sent by a client, wherein the query request is used to request a query for the target text page to be converted; responding to the query request, adjusting the original text page order to the target text page order based on the target text page; converting the target text page according to the target text page order to obtain a conversion result, and sending the conversion result to the client, wherein the conversion result is used to display the text content of the target text page on the client.

[0006] Optionally, the method further includes: obtaining query rule information from the client, wherein the query rule information is used to represent the query rules by which the client queries the target text page; adjusting the original text page order to the target text page order based on the target text page, including: adjusting the original text page order to the target text page order based on the target text page and the query rule information.

[0007] Optionally, the method further includes: query rule information including the query time and / or number of queries performed by the client on the target text page.

[0008] Optionally, the method further includes: obtaining record information of the target text, wherein the record information includes at least one of the following: the page number of the text page of the target text, the number of queries of the text page of the target text, and the query time of the text page of the target text; adjusting the original text page order to the target text page order based on the target text page, including: modifying the record information based on the target text page, and adjusting the original text page order to the target text page order based on the modified record information.

[0009] Optionally, the method further includes: obtaining container information of the target text, wherein the container information includes a queue of page objects of text pages of the target text, the queue corresponding to the original text page order; adjusting the original text page order to the target text page order based on the target text page, including: obtaining the page object of the target text page corresponding to the page number of the target text page in the container information, and adjusting the original text page order to the target text page order based on the page object of the target text page.

[0010] Optionally, obtaining the container information of the target text includes: initializing the page objects of the text pages of the target text; and storing the corresponding initialized page objects into the target container according to the page numbers of the text pages of the target text to obtain the container information.

[0011] Optionally, the method further includes: inserting the page object of the target text page into the head of the queue; adjusting the original text page order to the target text page order based on the page object of the target text page, including: adjusting the original text page order to the target text page order based on the page object of the target text page located at the head of the queue.

[0012] Optionally, obtaining the query request sent by the client includes: obtaining the query request through a first thread; responding to the query request and adjusting the original text page order to the target text page order based on the target text page includes: responding to the query request through a second thread and adjusting the original text page order to the target text page order based on the target text page.

[0013] Optionally, responding to the query request via a second thread and adjusting the original text page order to the target text page order based on the target text page includes: obtaining the page number of the target text page; submitting a second thread with the same number of pages to the thread pool; and responding to the query request via the second thread and adjusting the original text page order to the target text page order based on the target text page, including: responding to the query request via a first thread in the thread pool that is in an idle state and adjusting the original text page order to the target text page order based on the target text page.

[0014] Optionally, the target text pages are converted according to their order to obtain the conversion result, including: acquiring task data based on the first thread in an idle state; and converting the target text at the beginning of the target text page order based on the task data to obtain the conversion result.

[0015] According to another aspect of the present invention, a text processing apparatus is also provided. The text processing apparatus includes: an acquisition unit, configured to acquire a query request sent by a client during the conversion of target text according to the original text page order of the target text, wherein the query request is used to request a query for the target text page to be converted; an adjustment unit, configured to respond to the query request and adjust the original text page order to the target text page order based on the target text page; and a processing unit, configured to convert the target text page according to the target text page order, obtain a conversion result, and send the conversion result to the client, wherein the conversion result is used to display the text content of the target text page on the client.

[0016] According to another aspect of the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform the text processing method of the present invention.

[0017] According to another aspect of the present invention, a processor is also provided. The processor is used to run a program, wherein the program, when running, performs the text processing method of the present invention.

[0018] In this embodiment of the invention, during the conversion of target text according to the original text page order, a query request sent by the client is obtained. This query request requests the target text pages to be converted. In response to the query request, the original text page order is adjusted to the target text page order. The target text pages are then converted according to this order to obtain a conversion result, which is sent to the client. This conversion result is used to display the text content of the target text pages on the client. In other words, this application determines the target text page order based on the query request, converts the target text pages according to this order, obtains a conversion result, and displays the result on the terminal. This solves the technical problem of low efficiency in text conversion and achieves the technical effect of improving text conversion efficiency. Attached Figure Description

[0019] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0020] Figure 1 This is a flowchart of a text processing method according to an embodiment of the present invention;

[0021] Figure 2 It is an interactive flowchart based on a text processing method in related technologies;

[0022] Figure 3 It is an interactive flowchart based on another text processing method in related technologies;

[0023] Figure 4 This is a schematic diagram based on a multi-threaded text processing method in related technologies;

[0024] Figure 5 This is a schematic diagram illustrating a method for implementing page-turning queries based on related technologies;

[0025] Figure 6 This is a schematic diagram of a multi-threaded model according to an embodiment of the present invention;

[0026] Figure 7 This is a flowchart of a multithreading method according to an embodiment of the present invention;

[0027] Figure 8 This is a flowchart of a multi-threaded model according to an embodiment of the present invention;

[0028] Figure 9 This is a schematic diagram illustrating the verification of a text processing method according to an embodiment of the present invention;

[0029] Figure 10 This is a schematic diagram illustrating the verification result of a text processing method according to an embodiment of the present invention;

[0030] Figure 11 This is a schematic diagram of a text processing device according to an embodiment of the present invention. Detailed Implementation

[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0033] Example 1

[0034] According to an embodiment of the present invention, an embodiment of a text processing method is provided.

[0035] The steps shown in the flowchart in the accompanying drawings can be performed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in a different order than that shown here.

[0036] Figure 1 This is a flowchart of a text processing method according to an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:

[0037] Step S102: During the process of converting the target text according to the original text page order of the target text, a query request sent by the client is obtained, wherein the query request is used to request the target text page to be converted.

[0038] In the technical solution provided in step S102 of the present invention, the target text can be a file uploaded to the internet by a user or a file stored locally. For example, it can be any of the following: a file in a cloud drive, an email in an email account, a file in a reader, etc. The content of the target text can be one or more combinations of text, images, videos, etc. The target text can be any of the following formats: doc, xls, ppt, pdf, etc. This application can be applied to files of different formats, locations, and types, and is not limited here. The target text may contain the original text page order.

[0039] In this embodiment, the query request can be a query request for the target text page issued by the user after performing the operation of previewing the target text online on the smart terminal.

[0040] Step S104: In response to the query request, adjust the original text page order to the target text page order based on the target text page.

[0041] In the technical solution provided by step S104 of the present invention, the target text page order can be obtained by sorting the original text page order according to the query request.

[0042] In this embodiment, the client's query request for the target text page is obtained, and based on the query request, the order of the original text pages is dynamically adjusted in real time to obtain the order of the target text pages to be converted.

[0043] Step S106: Convert the target text pages according to their order to obtain conversion results, and send the conversion results to the client. The conversion results are used to display the text content of the target text pages on the client.

[0044] In the technical solution provided by step S106 of the present invention, the target text pages are converted according to the order of the target text pages to obtain the conversion result, and the conversion result is sent to the corresponding client so that the user can directly preview the converted file online.

[0045] Through steps S102 to S106 of this application, the order of the target text pages to be converted is determined based on the query request, the target text pages are converted based on the order of the target text pages, the conversion result is obtained, and the conversion result is displayed on the terminal, thereby solving the technical problem of low efficiency in text conversion and achieving the technical effect of improving text conversion efficiency.

[0046] The method described in this embodiment will be further described below.

[0047] As an optional implementation, step S104 involves obtaining the client's query rule information, wherein the query rule information is used to represent the query rules by which the client queries the target text page; step S104 involves adjusting the original text page order to the target text page order based on the target text page, including: adjusting the original text page order to the target text page order based on the target text page and the query rule information.

[0048] In this embodiment, the query rule information is used to represent the query rules for the client to query the target text page. It can be the pagination query method selected by the client according to actual needs. Based on the target text page and the query rule information selected by the client, the original text page order is adjusted to the target text page order.

[0049] As an optional implementation, the method further includes: query rule information including the query time and / or number of queries performed by the client on the target text page.

[0050] In this embodiment, the query time can be the latest query time of the target file page by the client. A higher latest query time for the target file page indicates a higher priority for conversion. Optionally, the client can provide a page-turning function, allowing users to continuously scroll forward and backward in their queries. When scrolling back, users can select the latest query time of the target file page as the query rule information, prioritizing the conversion of the most recently queried target text page.

[0051] In this embodiment, the number of queries can be the number of times the client queries the target text page, or it can be that the target file pages are sorted according to the number of queries. Optionally, the client can initiate a query request to a specified range of the target text and then switch the query range, prioritizing the conversion based on the number of queries.

[0052] As an optional implementation, the method further includes: obtaining record information of the target text, wherein the record information includes at least one of the following: the page number of the text page of the target text, the number of queries of the text page of the target text, and the query time of the text page of the target text; step S104, adjusting the original text page order to the target text page order based on the target text page, including: modifying the record information based on the target text page, and adjusting the original text page order to the target text page order based on the modified record information.

[0053] Optionally, in this embodiment, the record information of the target text can be information such as the page number of the target text page, the number of queries of the target text page, and the query time of the target text page when the target text is initially changed.

[0054] In this embodiment, modifying the record information can be done by modifying the order of the target text pages. Optionally, when a text page is queried, the order of the target text pages is modified, and the original text page order is adjusted to the target text page order based on the modified record information.

[0055] As an optional implementation, the method further includes: obtaining container information of the target text, wherein the container information includes a queue of page objects of the text pages of the target text, the queue corresponding to the original text page order; step S104, adjusting the original text page order to the target text page order based on the target text page, including: obtaining the page object of the target text page corresponding to the page number of the target text page in the container information, and adjusting the original text page order to the target text page order based on the page object of the target text page.

[0056] In this embodiment, the container can be used to store page objects of the target text page. The container information includes a queue of page objects of the target text page. The page object of the target text page corresponding to the page number of the target text page is obtained from the container information, and the original text page order is adjusted to the target text page order based on the page object of the target text page.

[0057] Optionally, first obtain the total number of pages in the file, globally save the correspondence between the file and the container, initialize the page objects of the text pages of the target text, and put them into the container in sequence. By default, the page objects are linked according to the original page number order. When a query request is received, the container information is updated according to the query information. The page object of the target text page corresponding to the page number of the target text page is obtained from the container information, and the original text page order is adjusted to the target text page order based on the page object of the target text page.

[0058] As an optional implementation, the method further includes: initializing the page objects of the text pages of the target text; and storing the corresponding initialized page objects into the target container in sequence according to the page numbers of the text pages of the target text to obtain container information.

[0059] In this embodiment, the page objects of the text pages of the target text are initialized, and the corresponding initialized page objects are stored sequentially into the target container according to the page numbers of the text pages of the target text. By default, they are placed in the original text page order to obtain container information.

[0060] For example, the total number of pages in the file is obtained, file page objects are initialized, and information such as file page number, number of queries, and query time is recorded. At the same time, a conversion priority container is initialized, the correspondence between the file and the conversion priority container is globally stored, and all file page objects of the initialized file are put into the container in sequence. By default, the conversion is performed in page number order.

[0061] As an optional implementation, the method further includes: inserting the page object of the target text page into the head of the queue; adjusting the original text page order to the target text page order based on the page object of the target text page, including: adjusting the original text page order to the target text page order based on the page object of the target text page located at the head of the queue.

[0062] In this embodiment, the system receives a file query request, determines the target text page to be converted first based on the query request, obtains the page object of the target text page to be converted first, removes the page object from the queue, updates the attribute values ​​of the page object removed from the queue, and reinserts the page object removed from the queue head, thereby adjusting the original text page order to the target text page order.

[0063] As an optional implementation, the method further includes: obtaining a query request through a first thread; responding to the query request and adjusting the original text page order to the target text page order based on the target text page, including: responding to the query request through a second thread and adjusting the original text page order to the target text page order based on the target text page.

[0064] In this embodiment, a multi-threaded mode is adopted. After receiving a file conversion request, the system obtains the total number of pages in the file to be converted, and then submits a number of thread tasks equal to the total number of pages to the thread pool. Idle threads in the thread pool continuously obtain file page conversion tasks. Specifically, the first thread obtains a query request and responds to the query request by adjusting the original text page order to the target text page order based on the target text page. The second thread responds to the query request and adjusts the original text page order to the target text page order based on the target text page.

[0065] As an optional implementation, the method further includes: responding to the query request through a second thread and adjusting the original text page order to the target text page order based on the target text page, including: obtaining the page number of the target text page; submitting a second thread with the same number of pages to a thread pool; and responding to the query request through the second thread and adjusting the original text page order to the target text page order based on the target text page, including: responding to the query request through a first thread in an idle state in the thread pool and adjusting the original text page order to the target text page order based on the target text page.

[0066] In this embodiment, after receiving a file conversion request, the system obtains the page number of the target text, submits a second thread with the same number of pages to the thread pool, and the first thread in the thread pool, which is in an idle state, responds to the query request and adjusts the original text page order to the target text page order based on the target text page.

[0067] As an optional implementation, step S106, converting the target text pages according to the target text page order to obtain the conversion result, includes: obtaining task data based on the first thread in an idle state; converting the target text located at the beginning of the target text page order based on the task data to obtain the conversion result.

[0068] In this embodiment, the idle thread continuously acquires file page conversion tasks, retrieves the head page object to be converted from the conversion priority container, and obtains the conversion result.

[0069] Optionally, in this embodiment, a counter can be used, which is incremented by one when each thread task is completed. The counter is polled in the main thread until the count value equals the total number of tasks, thereby ensuring that the conversion of all target text pages is completed in the first thread.

[0070] Optionally, in this embodiment, a server (Future) can be used to obtain the server set returned by the thread pool from the task submission, and the server set can be traversed in the main thread, synchronously blocking until all tasks are completed, thereby ensuring that the conversion of all target text pages is completed in the first thread.

[0071] In this embodiment of the invention, during the conversion of target text according to the original text page order, a query request sent by the client is obtained. This query request requests the target text pages to be converted. In response to the query request, the original text page order is adjusted to the target text page order. The target text pages are then converted according to this order to obtain a conversion result, which is sent to the client. This conversion result is used to display the text content of the target text pages on the client. In other words, this application determines the target text page order based on the query request, converts the target text pages according to this order, obtains a conversion result, and displays the result on the terminal. This solves the technical problem of low efficiency in text conversion and achieves the technical effect of improving text conversion efficiency.

[0072] Example 2

[0073] The method described in this embodiment will be further described below.

[0074] Currently, in file preview systems, after a terminal initiates a preview request, the backend logic converts the file page by page in order, always starting from the beginning. However, terminals may not necessarily view the file sequentially from the first page. During the file conversion process, another terminal might simultaneously request to query the file content for a specific page range. If this page range starts relatively late, the corresponding page range may not have been converted yet, causing continuous polling of query results and preventing timely responses to terminal requests. Figure 2 As shown, Figure 2 It is an interactive flowchart based on a text processing method in related technologies.

[0075] In step S201, the client corresponding to user A sends a preview request.

[0076] User A sends a preview request, and the backend starts the conversion from scratch.

[0077] Step S202: Request successful.

[0078] If user A sends a preview request and the request is successful, then the request to the client is successfully sent.

[0079] Step S203: User B queries the conversion results on pages 10-15.

[0080] User B sends a preview request to the preview system to view pages 10-15.

[0081] Step S204: Preview the system query data.

[0082] After receiving a preview request from user B to query pages 10-15, the preview system queries the conversion results from the backend.

[0083] Step S205: Return empty data.

[0084] Because the starting position of this page number range is relatively late, the corresponding page number range has not yet been converted, resulting in an empty result being returned. Unable to respond to terminal requests in a timely manner, the database returns empty data to the preview system.

[0085] Step S206: Return empty data.

[0086] Unable to respond to terminal requests in a timely manner, the preview system returns empty data to the client.

[0087] Step S207: Continue querying the conversion results on pages 10-15.

[0088] Since the page range has not yet been converted, the query results will continue to be polled.

[0089] Step S208: Preview the system query data.

[0090] The preview system continues to query the backend for conversion results.

[0091] Step S205: Return empty data.

[0092] The corresponding page number range has not yet been converted, resulting in an empty result being returned. This prevents timely response to terminal requests, and the database returns empty data to the preview system.

[0093] Step S206: Return empty data.

[0094] Unable to respond to terminal requests in a timely manner, the preview system returns empty data to the client.

[0095] With a large number of terminals, these polling operations increase the server load. Therefore, for scenarios where user query requests cannot be responded to in a timely manner, the optimization method used is to dynamically adjust the conversion order of file pages, such as... Figure 3 The diagram shown is an interactive flowchart based on another text processing method in related technologies.

[0096] Step S301: User A sends a preview request.

[0097] User A sent a preview request, the request was successful, and the backend started the conversion from scratch.

[0098] Step S302, request successful.

[0099] If user A sends a preview request and the request is successful, then the request to the client is successfully sent.

[0100] Step S303: User B queries the conversion results on pages 10-15.

[0101] User B sends a preview request to the preview system to view pages 10-15.

[0102] Step S304: Switch the conversion order.

[0103] During the file conversion process, while converting the original file pages in sequence, the conversion order of the file pages is dynamically adjusted in real time after receiving a user's query request, prioritizing the conversion of the page range queried by the user.

[0104] Step S305: Preview the system query data.

[0105] The preview system continues to query the backend for conversion results.

[0106] Step S306: Return empty data.

[0107] The corresponding page number range has not yet been converted, resulting in an empty result being returned. This prevents timely response to terminal requests, and the database returns empty data to the preview system.

[0108] Step S307: Return empty data.

[0109] Unable to respond to terminal requests in a timely manner, the preview system returns empty data to the client.

[0110] Step S308: Continue querying the conversion results on pages 10-15.

[0111] Since the page range has not yet been converted, the query results will continue to be polled.

[0112] Step S309: Preview the system query data.

[0113] The preview system continues to query the backend for conversion results.

[0114] Step S310: Return data.

[0115] The page number range conversion request is completed, and the database returns the data to the preview system.

[0116] Step S311: Return data.

[0117] The preview system retrieves the transformed data from the database and returns the preview data to the client.

[0118] This solution dynamically adjusts the conversion order of file pages in real time, prioritizing the conversion of the page range queried by the user, thereby reducing the user's polling waiting time and improving the system's response speed to some extent.

[0119] However, when the server performs file conversion, the entire file conversion task is executed by a single thread. When there are too many pages in the file, the overall processing time will be long. Therefore, in addition to the original single thread executing the conversion task, multiple threads are used to share the conversion workload. Figure 4 This is a schematic diagram based on a multi-threaded text processing method in related technologies, such as... Figure 4 As shown, this method breaks down the large task of converting the entire file by a single thread into multiple thread tasks that convert individual file pages. The tasks are then distributed to other idle threads to help with the conversion. The entire conversion process is changed from serial execution to parallel execution, thereby improving the overall conversion speed.

[0120] However, in this embodiment, a method for dynamically switching the file conversion range is provided to flexibly adjust the file conversion order and respond to user query requests in a timely manner. One of the core points of this embodiment is how to dynamically adjust the file page conversion order to respond to user requests faster, which requires different switching rules to be formulated according to the actual business scenario.

[0121] Typically, client-side pagination queries offer two methods: forward / backward pagination and page-range pagination. Forward / backward pagination prioritizes the most recent query time, with a higher time indicating higher priority. This is suitable for scenarios where the client provides forward / backward pagination and users continuously scroll forward and backward. Page-range pagination prioritizes the number of queries and the most recent query time, switching according to rule one only if the number of queries is equal. This is suitable for scenarios where a single client makes multiple requests to a specified range, then switches the query range and returns to the previously requested page range; or when multiple clients request the same file. By analyzing these two different business scenarios, the number of queries and the most recent query time are used as comparison criteria to formulate the switching rules.

[0122] Based on the business scenario requirements of the company's products, this application provides an implementation scheme for page-by-page query, specifically including: (1) File page record: When initializing the file page object, record information such as file page number, number of queries, and query time. When the file page is queried, modify the relevant information. This data will be used when adjusting the conversion order; (2) Conversion priority container: Scheme 1 (queue + index), such as Figure 5 As shown, Figure 5The first approach, based on a diagram illustrating the implementation of page-by-page lookup in related technologies, involves a queue that connects page objects in page number order by default. An index maintains the mapping between page numbers and page objects for fast page object lookup. The priority container provides the following main methods: removing the head element, updating an element, and adding an element. The second approach utilizes a sorted set type from a storage database (Redis) combined with a hash function (zset + hash). The sorted set structure uses the file's unique identifier as the key, each item's score is the latest query time of the page object, and the members are page objects. The hash function structure maintains the mapping between page numbers and page objects for fast page object lookup. The specific implementation process includes two parts: the first part involves dynamically updating the container upon receiving a file conversion request, adjusting the conversion order of the file pages. This is followed by initializing the container corresponding to the file. The second part involves the processing steps for receiving a file query request.

[0123] The first part describes the processing steps when the system receives a file conversion request: obtain the total number of pages in the file, initialize the conversion priority container; globally save the correspondence between the file and the conversion priority container: the key is the unique identifier of the file, the value is the conversion priority container, initialize all file page objects of the file, and put them into the container in sequence, converting according to page number order by default.

[0124] The second part describes the processing steps when the system receives a file query request: obtain the page object based on the page number, remove the page object from the linked list, update the attribute values ​​of the removed page object, and reinsert it at the head of the queue.

[0125] The second core aspect of this embodiment is the use of multi-threading for file conversion. Using only a single thread for file conversion doesn't fully utilize the capabilities of a multi-core processor. Therefore, by utilizing idle threads during the conversion process to assist in processing unconverted file pages, the overall conversion speed is improved. When using multi-threading, it's crucial to ensure that the conversion order of file pages can still be dynamically adjusted.

[0126] Figure 6 This is a schematic diagram of a multi-threaded model according to an embodiment of the present invention, such as... Figure 6 As shown, one set of threads receives file conversion requests, and another set of threads handles file page conversion and client interface. There are two design approaches to using a multi-threaded model for conversion: the first is for the main thread to obtain the file pages to be converted and assign the conversion tasks to idle threads; the second is for idle threads to actively obtain the file pages to be converted. This solution adopts the second design approach. Specifically, it includes...

[0127] Figure 7 This is a flowchart of a multithreaded method according to an embodiment of the present invention. Figure 7As shown, the method may include the following steps:

[0128] Step S701, file conversion request.

[0129] The system receives a file conversion request and determines the total number of pages in the file to be converted.

[0130] Step S702: Initialize the conversion priority container.

[0131] After receiving a file conversion request, initialize the conversion priority container.

[0132] Step S703: Construct a file page conversion task, put it into a thread pool, and encapsulate the server set.

[0133] Determine the total number of pages in the file to be converted, construct a file page conversion task, and then submit a thread task equal to the total number of pages to the thread pool, while encapsulating the server-side collection.

[0134] Step S704: Traverse the server set, blocking until all file pages have been converted.

[0135] The system retrieves the server-side collection returned by the thread pool from the task submission. When a thread executes a task, it retrieves the page object to be converted from the head of the queue from the conversion priority container. The main thread then iterates through the server-side collection, synchronously blocking until all tasks are completed, thus determining that all file pages have been converted.

[0136] Step S705: Insert the converted file data.

[0137] Construct file page conversion tasks and put them into a thread pool. Idle threads in the thread pool continuously acquire file page conversion tasks and insert the converted file data.

[0138] Step S706: Update the conversion record status.

[0139] Conversion complete. Update conversion record status.

[0140] In this scheme, all file page conversion tasks are assigned to multiple threads, and the entire execution process is asynchronous. To ensure that all file pages have been converted, two methods are provided. Figure 8 This is a flowchart of a multi-threaded model according to an embodiment of the present invention. Figure 8 As shown, the method may include the following steps:

[0141] Step S801, file conversion request.

[0142] The system receives a file conversion request and determines the total number of pages in the file to be converted.

[0143] Step S802: Submit the asynchronous conversion task.

[0144] Determine the total number of pages in the file to be converted, split the file into multiple parts, submit an asynchronous conversion task, and distribute the conversion tasks of the file pages to multiple threads.

[0145] Step S803: The main thread is blocked and waiting.

[0146] After submitting the asynchronous conversion task, the main thread is blocked and waits.

[0147] Step S804, Option 1: The count value equals the number of tasks.

[0148] Option 1 uses a counter. The counter is incremented by one when each thread completes its task. The counter is polled in the main thread until the count equals the total number of tasks, at which point the polling ends.

[0149] Step S806: Update the transition status.

[0150] When polling ends, confirm that all file pages have been converted. Once the conversion is complete, update the conversion status.

[0151] Step S805, Option 2, the server returns all results.

[0152] Option 2 uses a server-side approach. It retrieves the server-side collection returned by the thread pool from the task submissions, and iterates through the server-side collection in the main thread, synchronously blocking until all tasks are completed.

[0153] Step S806: Update the transition status.

[0154] Once all tasks are completed, confirm that all file pages have been converted. After confirming that all file pages have been converted, update the conversion status.

[0155] Figure 9 This is a schematic diagram illustrating the verification of a text processing method according to an embodiment of the present invention, as shown below. Figure 9 As shown, a file conversion request is initiated first, and then multiple different query requests are initiated during the file conversion process.

[0156] Figure 10 This is a schematic diagram illustrating the verification result of a text processing method according to an embodiment of the present invention, as shown below. Figure 10 As shown, after receiving a query request, the order of file page conversion has been adjusted according to the latest query time, without affecting the original order.

[0157] This solution dynamically adjusts the conversion order of file pages in real time during file conversion, prioritizing the conversion of the page range queried by the user, thereby reducing user waiting time. By distributing the conversion workload across multiple threads, the large task of converting the entire file by a single thread is broken down into multiple thread tasks that convert individual file pages, and the tasks are distributed to other idle threads to assist in the conversion. The entire conversion process is changed from serial execution to parallel execution, thereby improving the overall conversion speed and solving the technical problem of files not responding in a timely manner, achieving the technical effect of improving the low file response speed.

[0158] Example 3

[0159] This invention also provides a text processing apparatus. It should be noted that the text processing apparatus of this embodiment can be used to execute the text processing method of this invention.

[0160] Figure 11 This is a schematic diagram of a text processing device according to an embodiment of the present invention. Figure 11 As shown, the text processing device 110 may include: an acquisition unit 111, an adjustment unit 112, and a processing unit 113.

[0161] The acquisition unit 111 is used to acquire a query request sent by the client during the process of converting the target text according to the original text page order of the target text, wherein the query request is used to request the target text page to be converted.

[0162] Adjustment unit 112 is used to respond to query requests and adjust the original text page order to the target text page order based on the target text page.

[0163] The processing unit 113 is used to convert the target text pages according to the target text page order, obtain the conversion result, and send the conversion result to the client. The conversion result is used to display the text content of the target text pages on the client.

[0164] Optionally, the acquisition unit 111 includes: a first acquisition module, used to acquire query rule information of the client, wherein the query rule information is used to represent the query rules of the client for querying the target text page.

[0165] Optionally, the adjustment unit 112 includes: a first adjustment module, used to adjust the original text page order to the target text page order based on the target text page, including: adjusting the original text page order to the target text page order based on the target text page and query rule information.

[0166] Optionally, the device further includes a query unit for querying rule information including the query time and / or number of queries performed by the client on the target text page.

[0167] Optionally, the acquisition unit 111 includes: a second acquisition module, used to acquire record information of the target text, wherein the record information includes at least one of the following: the page number of the text page of the target text, the number of queries of the text page of the target text, and the query time of the text page of the target text.

[0168] Optionally, the adjustment unit 112 includes: a second adjustment module, used to adjust the original text page order to the target text page order based on the target text page, including: modifying record information based on the target text page, and adjusting the original text page order to the target text page order based on the modified record information.

[0169] Optionally, the acquisition unit 111 includes: a third acquisition module, used to acquire container information of the target text, wherein the container information includes a queue of page objects of the text pages of the target text, the queue corresponding to the original text page order.

[0170] Optionally, the adjustment unit 112 includes: a third adjustment module, used to adjust the original text page order to the target text page order based on the target text page, including: obtaining the page object of the target text page corresponding to the page number of the target text page from the container information, and adjusting the original text page order to the target text page order based on the page object of the target text page.

[0171] Optionally, the acquisition unit 111 includes: a fourth acquisition module, used to acquire container information of the target text, including: initializing the page objects of the text pages of the target text; and storing the corresponding initialized page objects into the target container according to the page numbers of the text pages of the target text to obtain container information.

[0172] Optionally, the third adjustment module includes: a first adjustment submodule, used to insert the page object of the target text page into the head of the queue; adjusting the original text page order to the target text page order based on the page object of the target text page, including: adjusting the original text page order to the target text page order based on the page object of the target text page located at the head of the queue.

[0173] Optionally, the adjustment unit 112 includes: a fourth adjustment module, used to obtain a query request sent by the client, including: obtaining the query request through a first thread; responding to the query request and adjusting the original text page order to the target text page order based on the target text page, including: responding to the query request through a second thread and adjusting the original text page order to the target text page order based on the target text page.

[0174] Optionally, the fourth adjustment module includes: a second adjustment submodule, used to respond to the query request through a second thread and adjust the original text page order to the target text page order based on the target text page, including: obtaining the page number of the target text page; submitting the same number of second threads as the page number to the thread pool; and responding to the query request through the second thread and adjusting the original text page order to the target text page order based on the target text page, including: responding to the query request through a first thread in the thread pool that is in an idle state and adjusting the original text page order to the target text page order based on the target text page.

[0175] Optionally, the processing unit 113 includes a first processing module, used to convert the target text pages according to the target text page order to obtain a conversion result, including: acquiring task data based on a first thread in an idle state; and converting the target text located at the beginning of the target text page order based on the task data to obtain a conversion result.

[0176] In this embodiment of the invention, the order of the target text pages to be converted is determined based on the query request, the target text pages are converted based on the order of the target text pages, the conversion result is obtained, and the conversion result is displayed on the terminal, thereby solving the technical problem of low efficiency in text conversion and achieving the technical effect of improving the efficiency of text conversion.

[0177] Example 4

[0178] According to embodiments of the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium includes a stored program, wherein, when the program is run by a processor, it controls the device where the computer-readable storage medium is located to execute the text processing method of the embodiments of the present invention.

[0179] Example 5

[0180] According to an embodiment of the present invention, a processor is also provided for running a program, wherein the program executes the text processing method of the present invention during runtime.

[0181] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0182] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0183] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be indirect couplings or communication connections through some interfaces, units, or models, and may be electrical or other forms.

[0184] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0185] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0186] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0187] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A text processing method, characterized in that, include: During the process of converting the target text according to the original text page order of the target text, a query request sent by the client is obtained, wherein the query request is used to request the query of the target text page to be converted; In response to the query request, the order of the original text pages is adjusted to the order of the target text pages based on the target text pages; The target text pages are converted according to the order of the target text pages to obtain the conversion result, and the conversion result is sent to the client. The conversion result is used to display the text content of the target text pages on the client. The method further includes: obtaining container information of the target text, wherein the container information includes a queue of page objects of the text pages of the target text, the queue corresponding to the order of the original text pages; In response to the query request, adjusting the original text page order to the target text page order based on the target text page includes: in response to receiving the query request, determining the target text page according to the query request, and obtaining the page object of the target text page; removing the page object of the target text page from the queue, and updating the attribute values ​​of the page object removed from the queue; inserting the page object of the removed target text page at the head of the queue; and adjusting the original text page order to the target text page order based on the page object of the target text page located at the head of the queue. The method further includes: using multiple threads to convert the target text page; employing a counter, incrementing the counter by one when each thread task of the multiple threads is completed, and polling the counter in the main thread of the multiple threads until the counter value equals the total number of tasks.

2. The method according to claim 1, characterized in that, Obtaining the container information of the target text includes: The page object of the text page of the target text is initialized; The initialized page objects are sequentially stored into the target container according to the page number of the target text page to obtain the container information.

3. The method according to claim 1, characterized in that, Obtaining the query request sent by the client includes: obtaining the query request through a first thread; Responding to the query request and adjusting the order of the original text pages to the target text page order based on the target text page includes: responding to the query request through a second thread and adjusting the order of the original text pages to the target text page order based on the target text page.

4. The method according to claim 3, characterized in that, Responding to the query request via a second thread, and adjusting the order of the original text pages to the order of the target text pages based on the target text pages, includes: The method further includes: obtaining the page number of the target text; and submitting the second thread, which has the same number of pages as the target text, to a thread pool. Responding to the query request via a second thread and adjusting the original text page order to the target text page order based on the target text page includes: responding to the query request via a first thread that is idle in the thread pool and adjusting the original text page order to the target text page order based on the target text page.

5. The method according to claim 4, characterized in that, The target text pages are converted according to their order to obtain the conversion results, including: Task data is obtained based on the first thread, which is in the idle state; Based on the task data, the target text located at the beginning of the target text page order is transformed to obtain the transformation result.

6. A text processing device, characterized in that, include: The acquisition unit is used to acquire a query request sent by the client during the process of converting the target text according to the original text page order of the target text, wherein the query request is used to request the query of the target text page to be converted; An adjustment unit is used to respond to the query request and adjust the order of the original text pages to the order of the target text pages based on the target text pages; A processing unit is configured to convert the target text pages according to the order of the target text pages, obtain a conversion result, and send the conversion result to the client, wherein the conversion result is used to display the text content of the target text pages on the client; The text processing device is further configured to perform the following steps: obtaining container information of the target text, wherein the container information includes a queue of page objects of the text pages of the target text, the queue corresponding to the order of the original text pages; The adjustment unit is further configured to perform the following steps: in response to receiving the query request, determining the target text page according to the query request, and obtaining the page object of the target text page; removing the page object of the target text page from the queue, and updating the attribute value of the page object removed from the queue; inserting the page object of the removed target text page into the head of the queue; and adjusting the original text page order to the target text page order based on the page object of the target text page located at the head of the queue. The text processing device is further configured to perform the following steps: using multiple threads to convert the target text page; employing a counter, incrementing the counter by one when each thread task of the multiple threads is completed, and polling the counter in the main thread of the multiple threads until the counter value equals the total number of tasks.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein when the program is run by a processor, it controls the device on which the computer-readable storage medium resides to perform the method of any one of claims 1 to 5.

8. A processor, characterized in that, The processor is used to run a program, wherein the program executes the method according to any one of claims 1 to 5 when it runs.

Citation Information

Patent Citations

  • Method and device for generating webpage

    CN104951287A

  • On-line previewing method and system for documents

    CN106777179A

  • File processing method and device

    CN111460348A