Document generation method, device, electronic device and medium
By generating the second document data of the target document with the second layout and using graphic rendering, the problems of inaccurate search results and inconvenient document editing in the prior art are solved, and the security of the document is improved.
Patent Information
- Application Number
- CN202410526207.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2044-04-28
AI Technical Summary
When generating search results, it is difficult for the prior art to provide accurate search results and easy-to-edit document formats, and the security of the document is insufficient.
By generating the second document data of the target document with the second layout based on the search terms entered by the user, the page components of the target document are respectively defined by corresponding parts in the second document data, and graphic rendering is used to improve the security of the document.
It realizes user convenient secondary editing and rewriting of the target document, improves the security of the document, and prevents text content from being directly copied.
Smart Images

Figure CN118278361B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to the fields of information retrieval and computer front-end technologies. Specifically, the present disclosure relates to a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating a document. Background Art
[0002] During the retrieval process, a user expresses their search intent by entering a search term. How to provide accurate retrieval results and clear and well-organized format layout for the user based on the entered search term poses new challenges to the fields of information retrieval and front-end display.
[0003] The methods described in this section are not necessarily methods that have been previously conceived or adopted. Unless otherwise specified, any method described in this section should not be considered prior art merely because it is included in this section. Similarly, unless otherwise specified, the problems mentioned in this section should not be considered to have been recognized in any prior art. Summary of the Invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating a document.
[0005] According to one aspect of the present disclosure, there is provided a method for generating a document, including: obtaining first document data based on a search term from a user, where the first document data is used to describe an initial document with a first layout; generating second document data having at least one part based on the first document data, where the second document data is used to describe a target document with a second layout, the target document includes the same text content as the initial document, where the target document includes at least one page component, and where each part of the at least one part of the second document data is used to describe a corresponding page component in the at least one page component; and performing graphic rendering based on the second document data to generate the target document displayed as an image.
[0006] According to another aspect of the present disclosure, there is provided a document generation apparatus, including: a first acquisition module configured to acquire first document data based on a search term from a user, where the first document data is used to describe an initial document with a first layout; a first generation module configured to generate second document data having at least one part based on the first document data, where the second document data is used to describe a target document with a second layout, the target document includes the same text content as the initial document, where the target document includes at least one page component, and where each part of the at least one part of the second document data is used to describe the corresponding page component in the at least one page component; and a second generation module configured to perform graphic rendering based on the second document data to generate the target document displayed as an image.
[0007] According to another aspect of the present disclosure, there is provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; where the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above method.
[0008] According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause the computer to execute the above method.
[0009] According to another aspect of the present disclosure, there is provided a computer program product including a computer program, where the computer program implements the above method when executed by a processor.
[0010] According to one or more embodiments of the present disclosure, there is provided a document generation method, which matches and generates a target document described by second document data based on a search term input by a user. In the second document data, the page components of the target document are respectively defined by the corresponding parts in the second document data. Compared with the way of describing a document using the first document data, the target document with the second layout described by the second document data facilitates the user to perform secondary editing and rewriting of the target document. In addition, the target document uses graphic rendering, so that the displayed text content cannot be directly copied, improving the security of the document.
[0011] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. Description of the Drawings
[0012] The accompanying drawings exemplarily illustrate embodiments and form a part of the specification, and are used together with the written description of the specification to explain the exemplary embodiments of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. In all the drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0013] Figure 1 is a schematic diagram illustrating an example system in which various methods described herein can be implemented according to an exemplary embodiment
[0014] Figure 2 shows a flowchart of a method for generating a document according to an embodiment of the present disclosure;
[0015] Figure 3 shows a flowchart of a partial process of a method for generating a document according to an embodiment of the present disclosure;
[0016] Figure 4 shows a block diagram of a device for generating a document according to an embodiment of the present disclosure; and
[0017] Figure 5 shows a block diagram of an exemplary electronic device that can be used to implement an embodiment of the present disclosure. Detailed Embodiments
[0018] The following describes exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0019] In the present disclosure, unless otherwise specified, the terms "first", "second", etc. are used to describe various elements and are not intended to limit the positional relationship, temporal relationship or importance relationship of these elements. Such terms are only used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of the element, and in certain cases, based on the description of the context, they may also refer to different instances.
[0020] In the description of various examples in the present disclosure, the terms used are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element may be one or more. In addition, the term "and / or" used in the present disclosure covers any one of the listed items and all possible combinations.
[0021] In the related art, based on the search terms input by a user, a document in xml format that matches the search terms is usually generated. The xml data defines the entire document through a tree structure. When the user needs to edit the document, the entire tree structure needs to be updated, which is not convenient for document update and typesetting.
[0022] To solve the above problems, the present disclosure provides a method for generating a document. A target document described by second document data is matched and generated based on the search terms input by a user. In the second document data, the page components of the target document are respectively defined by corresponding parts in the second document data. Compared with the way the first document data describes the document, the target document with a second typesetting described by the second document data is convenient for the user to perform secondary editing and rewriting on the target document. In addition, the target document uses graphic rendering, so that the displayed text content cannot be directly copied, improving the security of the document.
[0023] Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0024] Figure 1 FIG. shows a schematic diagram of an exemplary system 100 in which the various methods and apparatuses described herein can be implemented according to an embodiment of the present disclosure. Referring Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 that couple the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 can be configured to execute one or more application programs.
[0025] In an embodiment of the present disclosure, the server 120 can run one or more services or software applications that enable the execution of the method for generating a document.
[0026] In certain embodiments, the server 120 can also provide other services or software applications that can include non-virtual environments and virtual environments. In certain embodiments, these services can be provided as web-based services or cloud services, for example, provided to users of the client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.
[0027] In Figure 1In the configuration shown, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or combinations thereof that may be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from system 100. Thus, Figure 1 is an example of a system for implementing the methods described herein and is not intended to be limiting.
[0028] Users may use client devices 101, 102, 103, 104, 105, and / or 106 to perform the document generation method. The client device may provide an interface that enables the user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although Figure 1 only six client devices are depicted, those skilled in the art will be able to understand that the present disclosure may support any number of client devices.
[0029] Client devices 101, 102, 103, 104, 105, and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors, or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux, or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT WindowsMobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smartphones, tablets, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Gaming systems may include various handheld gaming devices, Internet-enabled gaming devices, etc. The client device is capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.
[0030] Network 110 can be any type of network well-known to those skilled in the art, which can support data communication using any one of a variety of available protocols (including but not limited to TCP / IP, SNA, IPX, etc.). By way of example only, one or more networks 110 can be a local area network (LAN), an Ethernet-based network, token ring, wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a public switched telephone network (PSTN), an infrared network, a wireless network (such as Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0031] Server 120 can include one or more general-purpose computers, dedicated server computers (such as PC (personal computer) servers, UNIX servers, midrange servers), blade servers, mainframes, server clusters, or any other suitable arrangement and / or combination. Server 120 can include one or more virtual machines running a virtual operating system, or other computing architectures involving virtualization (such as one or more flexible pools of logical storage devices that can be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 can run one or more services or software applications that provide the functions described below.
[0032] The computing units in server 120 can run one or more operating systems including any of the above operating systems and any commercially available server operating systems. Server 120 can also run any one of a variety of additional server applications and / or middleware applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0033] In some embodiments, server 120 can include one or more applications to analyze and merge data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 can also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
[0034] In some embodiments, server 120 can be a server of a distributed system, or a server combined with a blockchain. Server 120 can also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in the cloud computing service system, which solves the defects of difficult management and weak business scalability existing in traditional physical hosts and virtual private server (VPS) services.
[0035] System 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The databases 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the database used by the server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve data to and from the database in response to commands.
[0036] In some embodiments, one or more of the databases 130 may also be used by an application to store application data. The database used by the application may be a different type of database, such as a key-value store, an object store, or a conventional store supported by a file system.
[0037] Figure 1 The system 100 can be configured and operated in various ways to enable the application of the various methods and apparatuses described in this disclosure.
[0038] Figure 2 A flowchart of a method for generating a document according to an embodiment of the present disclosure is shown.
[0039] As Figure 2 shown, the method 200 for generating a document includes:
[0040] Step S201, obtaining first document data based on search terms from a user, where the first document data is used to describe an initial document having a first layout;
[0041] Step S202, generating second document data having at least one part based on the first document data, where the second document data is used to describe a target document having a second layout, the target document includes the same text content as the initial document, where the target document includes at least one page component, and where each part of the at least one part of the second document data is used to describe the corresponding page component in the at least one page component; and
[0042] Step S203, performing graphic rendering based on the second document data to generate the target document displayed as an image.
[0043] In some examples, the search terms input by the user include a first token representing the theme of the target document, so that in step S201, the text content matching the theme can be recalled according to the first token representing the theme of the target document in the search terms.
[0044] According to some embodiments, the first document data has a tree structure, and wherein, the tree structure is used to describe an initial document with a first layout, and wherein, step S202 includes: parsing the tree structure to generate second document data having at least one part.
[0045] In some examples, the first document data is XML data, which has a tree structure for describing an initial document with a first layout. The initial document is the text content displayed on the front end based on the description of the XML data. In some examples, the XML data is obtained by performing OCR recognition on the existing document data in the database.
[0046] It can be understood that the XML data defines all the content in the initial document with a first layout through each node on the tree structure, and the XML data contains an overall description of the page. When the user needs to rewrite and edit the document, the changes reflected in the XML data are relatively large, and it is necessary to re-render the document based on the updated XML data, which is not conducive to the user's editing and rewriting of the document.
[0047] Therefore, in step S202, by parsing the tree structure, second document data is generated to be used to describe the target document with a second layout. Exemplarily, the second document data is bdjson data, which includes structured information such as chapters, paragraphs, and tables. At least one part of it can segment and block each component in at least one page component included in the target document, and has a more flexible performance in describing the document compared to the XML data, facilitating the user to edit and rewrite the document. Correspondingly, the target document is the text content displayed on the front end based on the description of the bdjson data.
[0048] According to some embodiments, each page component in the at least one page component is at least one of a body title, a body paragraph, a body chapter, a header, a footer, a footnote, a page number, a figure caption, a table name, and table content.
[0049] In some examples, each part of at least one part of the second document data is respectively used to describe a paragraph or a chapter in the target document with a second layout. Thus, when editing and rewriting the paragraph or chapter, only the corresponding part in the second document data needs to be updated, which can effectively improve the editing efficiency of the document and enhance the user experience.
[0050] In some examples, in step S202, the variables included in the tree structure can be determined by traversing each node in the tree structure, and the variables in the tree structure can be mapped to the corresponding variables in the bdjson format according to the mapping rules, so as to convert the initial document with the first layout into the target document with the second layout.
[0051] In step S203, by performing graphic rendering on the second document data, the target document is displayed to the user in the form of an image, and the displayed text content cannot be directly copied by the user, improving the security of the document.
[0052] In some examples, the graphic rendering includes canvas rendering.
[0053] Thus, this method matches and generates the target document described by the second document data based on the search terms input by the user. In the second document data, the page components of the target document are respectively defined by the corresponding parts in the second document data. Compared with the way of describing the whole document by using a tree structure, for example, the description method of the second document data for the target document with the second layout is convenient for the user to perform secondary editing and rewriting on the target document. In addition, the target document adopts graphic rendering, so that the displayed text content cannot be directly copied, improving the security of the document.
[0054] Figure 3 The flowchart shows a partial process of the method for generating a document according to an embodiment of the present disclosure.
[0055] As Figure 3 shown, based on the method 200 for generating a document, the method 300 for generating a document further includes:
[0056] Step S301, after generating the target document to be displayed as an image, in response to the user selecting a first area in the target document, determining first text content corresponding to the first area based on the second document data;
[0057] Step S302, determining keywords in the first text content;
[0058] Step S303, recalling second text content matching the keywords based on the keywords; and
[0059] Step S304, updating and displaying the target document based on the second text content.
[0060] After rendering the second document data and generating the target document for display as an image, a function for further editing and rewriting the target document can also be provided to the user. Specifically, in response to the user selecting a first region in the target document, preprocessing can be performed on the first text content corresponding to the first region to extract keywords in the first text content for re-searching, so as to recall second text content matching the keywords, and based on the recalled second text content, rewrite the first text content selected by the user to achieve an updated display of the target document.
[0061] According to some embodiments, step S301 includes: in response to the user selecting a first region in the target document, determining the position coordinates corresponding to the first region in the target document; and based on the position coordinates, determining the first text content corresponding to the first region in the second document data.
[0062] Since the text content of the target document cannot be directly copied due to the use of graphic rendering for the second document data in step S203, the text content selected by the user can be confirmed by passing the position coordinates of the first region selected by the user, improving security.
[0063] Specifically, the position coordinates of the selected first region are used to query the specific text content selected by the user from the second document data as the first text content, and second text content matching the selected first text content is recalled, and the first text content is expanded or rewritten based on the second text content. After obtaining the expanded content or rewritten content, the target document is updated by updating the expanded content or rewritten content to the second document data for rendering. Thus, the quality of the retrieved target document is improved through rewriting and polishing of the target document.
[0064] According to some embodiments, step S304 includes: in response to determining that the first text content corresponds to a first page component in the target document, determining a target part of the at least one part of the second document data corresponding to the first page component; updating the target part of the second document data based on the second text content to obtain the updated second document data; and performing graphic rendering based on the updated second document data to update the display of the target document.
[0065] The structured information such as chapters or paragraphs of the target document is defined separately using the corresponding parts in the second document data, which is convenient for users to rewrite and edit. When performing an update, the part to be updated in the second document data can be determined by identifying the page component corresponding to the first text content selected by the user, that is, the paragraph or chapter where the first text content is located, and this part can be updated based on the recalled second text content to obtain updated second text data. Thus, graphic rendering can be performed based on the updated second document data to update and display the target document.
[0066] It can be seen that in the second document data with a streaming data structure such as bdjson, only the chapters or paragraphs for which the user has the intention to update can be updated accordingly, which can effectively improve the document update efficiency and enhance the user experience.
[0067] According to some embodiments, the target document includes multiple pages, and step S304 includes: in response to determining that the first area selected by the user is located on a target page among the multiple pages, based on the second text content, updating and displaying the target page and the next page of the target page among the multiple pages.
[0068] It can be understood that when the number of pages of the target document is large, only the currently selected page and the next page of the currently selected page can be rendered and updated to save network resources and storage resources.
[0069] In one example, the currently selected page and the adjacent pages of the currently selected page can be rendered and updated.
[0070] According to some embodiments, the method for generating a document further includes: segmenting the search term to determine at least one of the topic corresponding to the search term and the part of speech and tone. Step S201 includes: expanding the search term based on at least one of the topic corresponding to the search term and the part of speech and tone; and obtaining the first document data that matches the result of the expansion.
[0071] The search term input by the user is used to represent the user's retrieval requirement. In some cases, the user's retrieval term can reflect the user's tone, etc. Under some conditions, the user's retrieval requirement can be understood more accurately by analyzing the part of speech of the retrieval term input by the user. Therefore, by expanding the search term in different dimensions, the user's retrieval requirement can be analyzed and improved in multiple dimensions, so as to obtain text content that better meets the user's needs, improve the quality of the retrieved documents, and enhance the user experience.
[0072] According to another aspect of the present disclosure, there is provided a device for generating a document. As Figure 4As shown, the document generation device 400 includes: a first acquisition module 401 configured to acquire first document data based on a search term from a user, where the first document data is used to describe an initial document with a first layout; a first generation module 402 configured to generate second document data with at least one part based on the first document data, where the second document data is used to describe a target document with a second layout, the target document includes the same text content as the initial document, where the target document includes at least one page component, and where each part of the at least one part of the second document data is used to describe the corresponding page component in the at least one page component; and a second generation module 403 configured to perform graphic rendering based on the second document data to generate the target document displayed as an image.
[0073] In some examples, the search term input by the user includes a first word segment representing the theme of the target document, so that the first acquisition module 401 can recall the text content matching the theme according to the first word segment representing the theme of the target document in the search term.
[0074] According to some embodiments, the first document data has a tree structure, and where the tree structure is used to describe an initial document with a first layout, and where the first generation module 402 is further configured to: parse the tree structure to generate second document data with at least one part.
[0075] In some examples, the first document data is XML data, the XML data has a tree structure, and the tree structure is used to describe an initial document with a first layout. In some examples, the XML data is obtained by performing OCR recognition on the existing document data in the database.
[0076] It can be understood that the XML data defines all the content in the initial document with a first layout through each node on the tree structure, and the XML data contains an overall description of the page. When the user has a need to rewrite and edit the document, the changes reflected in the XML data are relatively large, and it is necessary to re-render the document based on the updated XML data, which is not conducive to the user's editing and rewriting of the document.
[0077] Therefore, the first generation module 402 generates second document data by parsing the tree structure for describing a target document with a second layout. Exemplarily, the second document data is bdjson data, which includes structured information such as chapters, paragraphs, and tables. At least one part of the second document data can segment and block each component in at least one page component included in the target document, and has a more flexible representation than the description of the document by XML data, facilitating users to edit and rewrite the document.
[0078] According to some embodiments, each page component in the at least one page component is at least one of a body title, a body paragraph, a body chapter, a header, a footer, a footnote, a page number, a figure caption, a table name, and table content.
[0079] In some examples, each part of at least one part of the second document data is respectively used to describe a paragraph or a chapter in the target document with a second layout. Thus, when editing and rewriting the paragraph or chapter, only the corresponding part in the second document data needs to be updated, which can effectively improve the editing efficiency of the document and enhance the user experience.
[0080] In some examples, the first generation module 402 can determine the variables included in the tree structure by traversing each node in the tree structure, and map the variables in the tree structure to the corresponding variables in the bdjson format according to the mapping rules, thereby converting the initial document with a first layout into a target document with a second layout.
[0081] The second generation module 403 performs graphic rendering on the second document data, so that the target document is displayed to the user in the form of an image, and the displayed text content cannot be directly copied by the user, improving the security of the document.
[0082] In some examples, the graphic rendering includes canvas rendering.
[0083] Thus, the document generation device 400 matches and generates the target document described by the second document data based on the search term input by the user. In the second document data, the page components of the target document are respectively defined by the corresponding parts in the second document data. Compared with the method of describing the whole document by using a tree structure, the description method of the second document data for the target document with a second layout facilitates users to perform secondary editing and rewriting on the target document. In addition, the target document adopts graphic rendering, so that the displayed text content cannot be directly copied, improving the security of the document.
[0084] According to some embodiments, the document generation device 400 further includes: a determination module configured to, after generating the target document to be displayed as an image, in response to the user selecting a first area in the target document, determine first text content corresponding to the first area based on the second document data; a preprocessing module configured to determine keywords in the first text content; a recall module configured to recall second text content matching the keywords based on the keywords; and an update module configured to update and display the target document based on the second text content.
[0085] After rendering the second document data and generating the target document to be displayed as an image, the document generation device 400 can also provide the user with the function of further editing and rewriting the target document. Specifically, the preprocessing module can, in response to the user selecting a first area in the target document, preprocess the first text content corresponding to the first area to extract keywords in the first text content for the recall module to perform a secondary retrieval, recall second text content matching the keywords, and rewrite the first text content selected by the user based on the recalled second text content to achieve an updated display of the target document.
[0086] According to some embodiments, the determination module includes: a first determination unit configured to, in response to the user selecting a first area in the target document, determine the position coordinates of the first area corresponding in the target document; and a second determination unit configured to determine the first text content corresponding to the first area in the second document data based on the position coordinates.
[0087] Since the second generation module 403 performs graphic rendering on the second document data, the text content of the target document cannot be directly copied. Therefore, the text content selected by the user can be confirmed by passing the position coordinates of the first area selected by the user, improving security.
[0088] Specifically, the position coordinates of the selected first area are used to query the specific text content selected by the user as the first text content from the second document data, recall the matching second text content according to the selected first text content, and expand or rewrite the first text content based on the second text content. After obtaining the expanded content or rewritten content, the expanded content or rewritten content is updated to the second document data to perform a rendering update of the target document. Thus, the quality of the retrieved target document is improved by rewriting and polishing the target document.
[0089] According to some embodiments, the update module includes: a third determination unit configured to determine a target portion in the at least one portion of the second document data corresponding to the first page component in response to determining that the first text content corresponds to the first page component in the target document; a first update unit configured to update the target portion of the second document data based on the second text content to obtain the updated second document data; and a second update unit configured to perform graphic rendering based on the updated second document data to update and display the target document.
[0090] Structured information such as chapters or paragraphs of the target document is defined separately using corresponding portions in the second document data, facilitating user rewriting and editing. When performing an update, the portion to be updated in the second document data can be determined by identifying the page component corresponding to the first text content selected by the user, i.e., the paragraph or chapter where the first text content is located, and this portion can be updated based on the recalled second text content to obtain the updated second text data. Thus, graphic rendering can be performed based on the updated second document data to update and display the target document.
[0091] It can be seen that in the second document data with a streaming data structure such as bdjson, only the chapters or paragraphs for which the user has an update intention can be updated for the corresponding portions, effectively improving the document update efficiency and enhancing the user experience.
[0092] According to some embodiments, the target document includes multiple pages, and the update module includes: a fourth determination unit configured to update and display the target page and the next page of the target page among the multiple pages based on the second text content in response to determining that the first area selected by the user is located on the target page among the multiple pages.
[0093] It can be understood that when the target document has a large number of pages, only the currently selected page by the user and the next page of the current page can be rendered and updated to save network resources and storage resources.
[0094] In one example, the currently selected page by the user and the adjacent pages of the current page can be rendered and updated.
[0095] According to some embodiments, the document generation device 400 further includes: a word segmentation module configured to perform word segmentation on the search term to determine at least one of the topic corresponding to the search term, the part of speech, and the tone. Wherein, the first acquisition module includes: an expansion unit configured to expand the search term based on at least one of the topic corresponding to the search term, the part of speech, and the tone; and an acquisition unit configured to acquire the first document data that matches the result of the expansion.
[0096] The search term input by the user is used to represent the user's retrieval requirement. In some cases, the user's search term can reflect the user's tone, etc. Under some conditions, the user's retrieval requirement can also be understood more accurately by analyzing the part of speech of the retrieval term input by the user. Therefore, by expanding the search term in different dimensions, the user's retrieval requirement can be analyzed and improved in multiple dimensions, so as to obtain text content that better meets the user's needs, improve the quality of the retrieved documents, and enhance the user experience.
[0097] According to another aspect of the present disclosure, there is also provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the document generation method.
[0098] According to another aspect of the present disclosure, there is also provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the document generation method.
[0099] According to another aspect of the present disclosure, there is also provided a computer program product including a computer program, wherein the computer program implements the document generation method when executed by a processor.
[0100] As Figure 5 shown, the electronic device 500 includes a computing unit 501, which can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 502 or the computer program loaded from the storage unit 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.
[0101] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, an output unit 507, a storage unit 508, and a communication unit 509. The input unit 506 can be any type of device capable of inputting information into the electronic device 500. The input unit 506 can receive input digital or character information, and generate key signal inputs related to user settings and / or function controls of the electronic device, and can include, but is not limited to, a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone, and / or a remote control. The output unit 507 can be any type of device capable of presenting information, and can include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 508 can include, but is not limited to, magnetic disks and optical discs. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth TM device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0102] The computing unit 501 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 executes the various methods and processes described above, such as the method for generating a document. For example, in some embodiments, the method for generating a document can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the method for generating a document described above can be executed. Alternatively, in other embodiments, the computing unit 501 can be configured to execute the method for generating a document in any other suitable manner (e.g., by means of firmware).
[0103] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0104] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowchart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0105] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0106] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball), by which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and the input received from the user can be in any form (including acoustic input, voice input, or tactile input).
[0107] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.
[0108] A computer system can include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, or a server of a distributed system, or a server incorporating a blockchain.
[0109] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitations are imposed herein.
[0110] Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above methods, systems, and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but is only defined by the authorized claims and their equivalent scope. Various elements in the embodiments or examples may be omitted or replaced by their equivalent elements. In addition, the steps may be executed in an order different from that described in the present disclosure. Further, various elements in the embodiments or examples may be combined in various ways. Importantly, with the evolution of technology, many of the elements described herein may be replaced by equivalent elements that emerge after the present disclosure.
Claims
1. A method for generating a document, comprising: Based on a search term from a user, obtaining first document data, wherein the first document data has a tree structure, and wherein the tree structure is used to describe an initial document having a first layout; Based on the first document data, generating second document data having at least one part, comprising: Parsing the tree structure to generate second document data having at least one part includes: Traversing each node in the tree structure to determine the variables contained in the tree structure; Mapping the variables in the tree structure to corresponding variables in the second document data according to a mapping rule, so as to convert the initial document having the first layout into a target document having a second layout; wherein the second document data is used to describe the target document having the second layout, the target document comprising the same text content as the initial document, wherein the target document comprises at least one page component, and wherein each of the at least one portion of the second document data is used to describe a corresponding page component of the at least one page component; Performing graphic rendering based on the second document data to generate the target document displayed as an image; After generating the target document displayed as an image, in response to the user selecting a first area in the target document, determining first text content corresponding to the first area based on the second document data; Determining keywords in the first text content; Based on the keyword, recalling second text content matching the keyword; and Based on the second text content, the target document is updated and displayed.
2. The method according to claim 1, wherein: In response to the user selecting a first area in the target document, determining first text content corresponding to the first area based on the second document data includes: In response to the user selecting a first area in the target document, determining position coordinates corresponding to the first area in the target document; and Based on the position coordinates, first text content corresponding to the first area is determined in the second document data.
3. The method according to claim 1 or 2, wherein: The updating and displaying of the target document based on the second text content includes: In response to determining that the first text content corresponds to a first page component in the target document, determining that the first page component corresponds to a target portion of the at least one portion of the second document data; Based on the second text content, updating the target portion of the second document data to obtain updated second document data; and Graphic rendering is performed based on the updated second document data to update and display the target document.
4. The method according to claim 1 or 2, wherein: The target document includes a plurality of pages, and updating and displaying the target document based on the second text content includes: In response to determining that the first area selected by the user is located at a target page among the multiple pages, the target page and a next page of the target page among the multiple pages are updated and displayed based on the second text content.
5. The method according to claim 1 or 2, further comprising: The search term is segmented to determine at least one of the subject and the part of speech and the tone corresponding to the search term, wherein The acquiring the first document data based on the search term from the user comprises: Expanding the search term from the user based on at least one of the topic and the part of speech and tone of the search term; and The first document data matching the expanded result is obtained.
6. The method according to claim 1 or 2, wherein: Each of the at least one page component is at least one of a text title, a text paragraph, a text section, a header, a footer, a footnote, a page number, a figure caption, a table name, and table content.
7. A document generation device, comprising: A first acquisition module is configured to acquire first document data based on a search term from a user, wherein the first document data has a tree structure, and wherein the tree structure is used to describe an initial document having a first layout; A first generating module is configured to generate second document data having at least one part based on the first document data, wherein the first generating module is further configured to: Parsing the tree structure to generate second document data having at least one part includes: Traversing each node in the tree structure to determine the variables contained in the tree structure; Mapping the variables in the tree structure to corresponding variables in the second document data according to a mapping rule, so as to convert the initial document having the first layout into a target document having a second layout; wherein the second document data is used to describe the target document having the second layout, the target document comprising the same text content as the initial document, wherein the target document comprises at least one page component, and wherein each of the at least one portion of the second document data is used to describe a corresponding page component of the at least one page component; A second generating module is configured to perform graphic rendering based on the second document data to generate the target document displayed as an image; a determination module configured to, after generating the target document displayed as an image, determine, in response to the user selecting a first area in the target document, first text content corresponding to the first area based on the second document data; A preprocessing module, configured to determine keywords in the first text content; a recall module configured to recall second text content matching the keyword based on the keyword; and The updating module is configured to update and display the target document based on the second text content.
8. The device according to claim 7, wherein: The determination module comprises: A first determining unit is configured to determine the position coordinates corresponding to the first area in the target document in response to the user selecting the first area in the target document; and The second determining unit is configured to determine, based on the position coordinates, first text content corresponding to the first area in the second document data.
9. The device according to claim 7 or 8, wherein: The update module includes: a third determining unit, configured to, in response to determining that the first text content corresponds to a first page component in the target document, determine that the first page component corresponds to a target portion of the at least one portion of the second document data; a first updating unit configured to update the target portion of the second document data based on the second text content to obtain updated second document data; and The second updating unit is configured to perform graphics rendering based on the updated second document data to update and display the target document.
10. The device according to claim 7 or 8, wherein: The target document includes multiple pages, and the update module includes: The fourth determining unit is configured to update and display the target page and the next page of the target page among the multiple pages based on the second text content in response to determining that the first area selected by the user is located at a target page among the multiple pages.
11. The device according to claim 7 or 8, further comprising: The word segmentation module is configured to segment the search words to determine at least one of the subject and the part of speech and the tone corresponding to the search words, wherein: The first acquisition module includes: An expansion unit configured to expand the search term based on at least one of a subject and a part of speech and a mood corresponding to the search term; and The acquiring unit is configured to acquire the first document data matching the expanded result.
12. The device according to claim 7 or 8, wherein: Each of the at least one page component is at least one of a text title, a text paragraph, a text section, a header, a footer, a footnote, a page number, a figure caption, a table name, and table content.
13. An electronic device, comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.
15. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
General DOC, DOCX and INDD document typesetting engine and method
CN113011129A
Document retrieval method and device, electronic equipment and medium
CN117056460A