CN117252160A - Document editing method, device, equipment and medium - Google Patents

Document editing method, device, equipment and medium Download PDF

Info

Publication number
CN117252160A
CN117252160A CN202311237195.7A CN202311237195A CN117252160A CN 117252160 A CN117252160 A CN 117252160A CN 202311237195 A CN202311237195 A CN 202311237195A CN 117252160 A CN117252160 A CN 117252160A
Authority
CN
China
Prior art keywords
character
editing
document
target
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311237195.7A
Other languages
Chinese (zh)
Inventor
黄元
李尼科
万重桂
张锐敏
易润泽
黄长海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Changyin May 8th Consumer Finance Co ltd
Original Assignee
Hunan Changyin May 8th Consumer Finance Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Changyin May 8th Consumer Finance Co ltd filed Critical Hunan Changyin May 8th Consumer Finance Co ltd
Priority to CN202311237195.7A priority Critical patent/CN117252160A/en
Publication of CN117252160A publication Critical patent/CN117252160A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting

Abstract

The application discloses a document editing method, a device, equipment and a medium, which relate to the technical field of document editing and comprise the following steps: determining metadata of a document to be edited based on the attribute editing information, editing attribute node coordinates where the metadata are located according to a red-black tree structure rule, and obtaining edited metadata; determining a target original text file in which the character to be edited is positioned from a storage memory based on deleting and/or inserting character information, storing target character information after character editing operation is executed into a newly added character editing file, and recording target initial position information and target character length information of the target character information; determining a spliced character string generated after the character editing operation is executed from the target original text file and the character editing file according to the target initial position information and the target character length information; and performing attribute editing on the spliced character strings by using the edited metadata to obtain an edited target document. The time complexity of editing the document is reduced.

Description

Document editing method, device, equipment and medium
Technical Field
The present invention relates to the field of document editing technologies, and in particular, to a method, an apparatus, a device, and a medium for editing a document.
Background
It is often necessary to set corresponding attributes for the text when writing a document, such as bolded and blackened titles, red key important text, etc. Existing text editors mostly use array-like intuitive data structures to store text attribute data and naturally use std: string: -to process text stream data. The advantages are that: is simple and easy to understand and is relatively visual. However, modifying the attribute data includes, in addition to the temporal complexity of looking up log, the remaining operations including adding and deleting nodes and adding and deleting spatial temporal complexity are both O (N), and the temporal complexity of inserting and deleting text to the text data is also O (N). That may cause problems in the user experience when adding or deleting text when the amount of text is large.
In summary, how to reduce the complexity of space time during editing attribute data and text stream data when editing a document with a huge text volume, so that even if various operations are performed in the document with a huge text volume, the quick response can not affect the user experience, and the technical problem to be solved in the field is solved.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, apparatus, device, and medium for editing a document, which can reduce the complexity of space time during editing attribute data and editing text stream data when editing a document with a huge text volume, so that even if various operations are performed in the document with a huge text volume, the response is fast, and the user experience is not affected. The specific scheme is as follows:
In a first aspect, the present application discloses a document editing method, including:
determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule to obtain edited metadata;
determining a target original text file in which a character to be edited is located from a storage memory based on deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information;
determining a spliced character string generated after performing character editing operation from the target original text file and the character editing file according to the target initial position information and the target character length information;
and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document.
Optionally, before determining the metadata of the document to be edited based on the attribute editing information in the document editing request, the method further includes:
And receiving a document editing request, determining a document to be edited based on the document editing request, and loading character string information and metadata in the document to be edited into a storage memory.
Optionally, the editing the attribute node coordinates where the metadata is located according to the red-black tree structure rule to obtain edited metadata includes:
determining metadata of a red-black tree structure of a document to be edited based on attribute editing information in the document editing request;
determining attribute node coordinates of a red-black tree structure where the metadata to be edited are currently located;
and editing the attribute node coordinates of the corresponding metadata according to the red-black tree structural rule of subtracting the attribute node coordinate value of the first father attribute node smaller than the current node coordinate value from the current node coordinate value of the attribute node coordinates, so as to obtain the metadata after the attribute node coordinates are edited.
Optionally, before determining the target original text file where the character to be edited is located from the storage memory based on the deleted and/or inserted character information in the document editing request, the method further includes:
splitting the document content of the document to be edited according to the character number sequence of characters in the document content of the document to be edited so as to obtain a plurality of document fragments, and respectively storing the document fragments in the corresponding original text files.
Optionally, the determining, from a storage memory, the target original text file in which the character to be edited is located based on the deleted and/or inserted character information in the document editing request includes:
and determining an original text file in which the character to be edited is positioned from all original text files in a storage memory based on the character number in the deleting and/or inserting character information of the document editing request so as to obtain a target original text file.
Optionally, the storing the target character information after the character editing operation performed based on the deleting and/or inserting character information in the newly added character editing file, and recording the target start position information and the target character length information of the target character information includes:
executing character deleting operation of the character to be edited based on the character deleting information, storing blank character information after executing the character deleting operation to a newly added character editing file, and recording target initial position information and target character length information of the blank character information;
and executing character insertion operation of the character to be edited based on the inserted character information, storing new inserted character information after executing the character insertion operation into a newly added character editing file, and recording target initial position information and target character length information of the new inserted character information.
Optionally, the determining, according to the target starting position information and the target character length information, a post-concatenation character string generated after performing a character editing operation from the target original text file and the character editing file includes:
acquiring unedited characters, initial position information and character length information corresponding to each unedited character from the target original text file;
and according to the target initial position information, the target character length information, the initial position information corresponding to the unedited character and the character length information, performing character string splicing on the target character information and the unedited character in the character editing file to obtain a spliced character string generated after the character editing operation is performed.
In a second aspect, the present application discloses a document editing apparatus comprising:
the metadata editing module is used for determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule so as to obtain edited metadata;
the character editing module is used for determining a target original text file in which a character to be edited is located from a storage memory based on the deleting and/or inserting character information in the document editing request, storing target character information after character editing operation executed based on the deleting and/or inserting character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information;
The character splicing module is used for determining a spliced character string generated after the character editing operation is executed from the target original text file and the character editing file according to the target initial position information and the target character length information;
and the document editing module is used for performing attribute editing on the spliced character strings by using the edited metadata so as to obtain an edited target document.
In a third aspect, the present application discloses an electronic device comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the previously disclosed document editing method.
In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the previously disclosed document editing method.
It can be seen that the present application discloses a document editing method, comprising: determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule to obtain edited metadata; determining a target original text file in which a character to be edited is located from a storage memory based on deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information; determining a spliced character string generated after performing character editing operation from the target original text file and the character editing file according to the target initial position information and the target character length information; and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document. It can be seen that, by using the red-black tree structure to replace the array structure, the attribute node coordinates where the metadata are located are edited by using the red-black tree structure rule, so that the time complexity of adding and deleting the space is lower than that of the attribute node coordinates processed by the array structure, then, aiming at the editing request of deleting or inserting character information into the document character content in the document editing request, the target character information after the character editing operation of deleting or inserting the character information is additionally stored into the newly added character editing file, and then, the final character searching and splicing operation is replaced by the character editing file and the original text file to move the characters in the document editing, thereby reducing the time complexity of editing the document stream.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a document editing method disclosed in the present application;
FIG. 2 is a diagram of a prior document editing page display disclosed herein;
FIG. 3 is a diagram of a structure of data structures of a red-black tree structure according to the present disclosure;
FIG. 4 is a schematic diagram of obtaining a coordinate position of an attribute node based on a red-black tree structure;
FIG. 5 is a schematic diagram of a structural definition code of an attribute node disclosed in the present application;
FIG. 6 is a flowchart of a specific document editing method disclosed herein;
FIG. 7 is a diagram of a process of deleting characters using the Piece table disclosed in the present application;
FIG. 8 is a diagram of a process of inserting characters using a Piece table disclosed herein;
FIG. 9 is a schematic diagram of mapping document content from storage locations to logical locations as disclosed herein;
Fig. 10 is a schematic diagram of implementing text flow fast mapping based on a memory data structure mirrortree mapping tree;
FIG. 11 is a schematic diagram of a document editing apparatus disclosed in the present application;
fig. 12 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It is often necessary to set corresponding attributes for the text when writing a document, such as bolded and blackened titles, red key important text, etc. Existing text editors mostly use array-like intuitive data structures to store text attribute data and naturally use std: string: -to process text stream data. The advantages are that: is simple and easy to understand and is relatively visual. However, modifying the attribute data includes, in addition to the temporal complexity of looking up log, the remaining operations including adding and deleting nodes and adding and deleting spatial temporal complexity are both O (N), and the temporal complexity of inserting and deleting text to the text data is also O (N). That may cause problems in the user experience when adding or deleting text when the amount of text is large.
Therefore, the document editing scheme can reduce the space time complexity during attribute data editing and text stream data editing when the document with huge text quantity is edited, so that even if various operations are performed in the document with huge text quantity, the quick response can not influence the user experience.
Referring to fig. 1, an embodiment of the present invention discloses a document editing method, including:
step S11: and determining metadata of the document to be edited based on the attribute editing information in the document editing request, and editing the attribute node coordinates where the metadata are located according to the red-black tree structure rule so as to obtain edited metadata.
In the prior art, in the process of editing a document, a commonly used attribute data structure is an array-like structure, as shown in fig. 2, a "nailed document is an online document which can be written by multiple persons", the storage content of the document to be edited, where the text is located, in the background is text and attribute properties, and attribute nodes adopt a form of coordinates and content. Such as: the coordinate 3 attribute is blue bolded, indicating that the text is blue bolded from the last coordinate to the middle of coordinate 3. The whole attribute properties are stored in the memory in a mode similar to an array, and the lookup can achieve the time complexity of log N through a dichotomy, but because the array is continuously stored in the memory, when nodes (adding deletion attributes) and spaces (adding deletion characters) are added and deleted, the time complexity is O (N) level, the average complexity is N/2, and the speed is not fast enough. And std is used for processing text, the bottom layer is also a char array, characters are inserted and deleted during editing, and the time complexity is also O (N) level. The time complexity is high.
In the embodiment, metadata of a red-black tree structure of a document to be edited is determined based on attribute editing information in the document editing request; determining attribute node coordinates of a red-black tree structure where the metadata to be edited are currently located; and editing the attribute node coordinates of the corresponding metadata according to the red-black tree structural rule of subtracting the attribute node coordinate value of the first father attribute node smaller than the current node coordinate value from the current node coordinate value of the attribute node coordinates, so as to obtain the metadata after the attribute node coordinates are edited. It may be appreciated that, based on the attribute editing information in the received document editing request, metadata of the red-black tree structure in the document to be edited is determined, where the metadata is text attribute data in the document to be edited, for example: the title text is thickened and blackened, the important text is displayed in red, underlined and the like. And determining the attribute node coordinates of the red-black tree structure where the metadata to be edited of the document to be edited is located based on the attribute editing information, and then editing the attribute node coordinates of the corresponding metadata according to the red-black tree structure rule of subtracting the attribute node coordinate value of the first father attribute node smaller than the current node coordinate value from the current node coordinate value of the attribute node coordinates to obtain the metadata after the attribute node coordinates are edited. As shown in fig. 3, for the attribute data of the document to be edited, the method uses a red-black tree-like structure to replace a class array structure, and uses the rotation operation of the adding and deleting nodes of the red black tree to reduce the time complexity of the adding and deleting nodes to log n, and the coordinates of the nodes do not adopt absolute coordinates in the document any more, so that the time complexity of the adding and deleting space is reduced to log n. This data structure is referred to herein as a position tree. By utilizing the characteristics of the red black tree, the speed of adding and deleting nodes is also improved to log N, but if adding and deleting space is carried out, the average complexity is N/2. Such as a text "pinned document" being a multi-person collaborative online document. The "changed" nail file is an online file which can be liked by me and can be cooperated by multiple persons. "five characters corresponding to the text are inserted between the original node 7 and the original node 11, but no attribute node is added, that is, no newly added attribute appears, and the modification results in that all node coordinates of the right subtree of the mangrove root node are added by 5, so that the speed of adding and deleting the space is not fast enough. Therefore, the coordinates of the node are not using the absolute coordinates of the document to be edited, and the difference between the absolute position and the absolute position of the parent node smaller than itself is used as the coordinates, as shown in fig. 4 below. By adopting the tree structure, the complexity of searching and adding and deleting nodes is log N, and the efficiency of adding and deleting space is improved to log N. For example, in the above document editing request, under the updated red-black tree structure, only the right son of the root node needs to be modified, and the tree is traversed from the right son to the left son until the leaf node, and the passing node coordinates are increased by 5. The other nodes of the right subtree do not need to be modified because the coordinates of the nodes are the relative positions of the first small father node, the positions of the first small father nodes of the other nodes are already adjusted, the relative positions are not changed, and modification is not needed. Thus, the adding and deleting space only needs to modify the nodes on one link from the root node to the leaf node at most, and the maximum time complexity is log N. In the code, the structure of the node may be defined as shown in fig. 5 below.
In this embodiment, before determining metadata of a document to be edited based on attribute editing information in a document editing request, the method further includes: and receiving a document editing request, determining a document to be edited based on the document editing request, and loading character string information and metadata in the document to be edited into a storage memory. It can be understood that, a document editing request is received, a document to be edited is determined based on the document editing request, then the document type of the document to be edited is judged, and if the document type of the document to be edited is an editable document type, character string information and metadata in the document to be edited are loaded into a storage memory. If the document type of the document to be edited is a read-only document type, the fact that the user has no editing authority on the document to be edited is indicated, character string information and metadata can be loaded into a storage memory without using a position tree (position tree), an original array structure is used, and an array space is occupied when character nodes without attributes exist, namely, an array index is equal to a text index. The efficiency of such a lookup reaches the O (1) level. That is, a judgment is added at the beginning of the document opening interface to judge the authority of the user on the document, and two sets of text viewing logics are realized according to whether the editing authority exists or not and the mode of loading the data into the memory is selected. For the situation that the user does not have editing authority, the read-only scene still applies the original traditional and visual data structure, so that the document can be viewed more quickly.
Step S12: determining a target original text file in which a character to be edited is located from a storage memory based on the deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information.
In this embodiment, an original text file in which a character to be edited is located is determined as a target original text file from original text parent files corresponding to a document to be edited in a storage memory based on deletion and/or insertion character information in a document editing request. Then, based on the target character information generated after the character editing operation of deleting or inserting the character is performed, storing the target character information into the newly added character editing file, and then recording the target start position information and the target character length information of the target character information.
In the embodiment, a piece table is used for replacing std:string to process characters to be edited of a document to be edited, wherein as the bottom layer uses the words Fu Shuzu, the character array is inserted and deleted in the middle to move all characters after the modification position, so that the time complexity is close to O (N), and the std:string time complexity is O (N) when the characters are added and deleted. Specifically, by determining the target original text file in which the character to be edited is located from the storage memory based on the deletion and/or insertion character information in the document editing request, the target original file is of a read-only type, that is, the character cannot be edited and modified in the target original file, the target character information after the character editing operation performed based on the deletion and/or insertion character information is stored in the newly added character editing file, that is, the target character information after the character editing operation is stored in the newly added character editing file, it is noted that the newly added character editing file is a blank file before the target character information is not written, only the operation of adding at the end is performed, and then the target start position information, the target character length information, and the like of the target character information generated after the specific character editing operation need to be additionally stored in the entry in the piece table.
In this embodiment, before determining, from the storage memory, the target original text file in which the character to be edited is located based on the deleted and/or inserted character information in the document editing request, the method further includes: splitting the document content of the document to be edited according to the character number sequence of characters in the document content of the document to be edited so as to obtain a plurality of document fragments, and respectively storing the document fragments in the corresponding original text files. In this embodiment, splitting document content of a document to be edited, splitting document content according to a character numbering sequence, and obtaining a plurality of document segments, where the length of each document segment may be set according to practical situations, without specific limitation, after obtaining a plurality of document segments, storing each document segment into an original text file, and then uniformly merging each original text file as a sub-file into an original text parent folder as an original text parent file corresponding to the document to be edited.
Step S13: and determining a spliced character string generated after the character editing operation is executed from the target original text file and the character editing file according to the target initial position information and the target character length information.
In this embodiment, the position of the deleted character in the target original text file, the deleted character length, and the like after the character editing operation is performed are determined from the target original text file and the character editing file according to the target starting position information and the target character length information, so that other characters which do not generate the character editing operation are read from the target original file, and are sequenced according to the sequence of character numbers, and are spliced again to generate the spliced character string. And respectively determining the position of the newly added character in the target original text file after the character editing operation is executed, the length of the newly added character and the like from the target original text file and the character editing file according to the target initial position information and the target character length information, further reading other characters which do not generate the character editing operation from the target original file, sequencing the characters in the character editing file according to the sequence of the character numbers, and re-splicing the characters with the other characters which do not generate the character editing operation to generate a spliced character string.
Step S14: and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document.
In this embodiment, attribute editing is performed on the spliced character string by using the edited metadata, so as to complete the editing operation of the document to be edited, so as to obtain the edited target document.
It can be seen that the present application discloses a document editing method, comprising: determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule to obtain edited metadata; determining a target original text file in which a character to be edited is located from a storage memory based on deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information; determining a spliced character string generated after performing character editing operation from the target original text file and the character editing file according to the target initial position information and the target character length information; and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document. It can be seen that, by using the red-black tree structure to replace the array structure, the attribute node coordinates where the metadata are located are edited by using the red-black tree structure rule, so that the time complexity of adding and deleting the space is lower than that of the attribute node coordinates processed by the array structure, then, aiming at the editing request of deleting or inserting character information into the document character content in the document editing request, the target character information after the character editing operation of deleting or inserting the character information is additionally stored into the newly added character editing file, and then, the final character searching and splicing operation is replaced by the character editing file and the original text file to move the characters in the document editing, thereby reducing the time complexity of editing the document stream.
Referring to fig. 6, an embodiment of the present invention discloses a specific document editing method, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution. Specific:
step S21: and determining metadata of the document to be edited based on the attribute editing information in the document editing request, and editing the attribute node coordinates where the metadata are located according to the red-black tree structure rule so as to obtain edited metadata.
Step S22: and determining an original text file in which the character to be edited is positioned from all original text files in a storage memory based on the character number in the deleting and/or inserting character information of the document editing request so as to obtain a target original text file.
Step S23: executing character deleting operation of the character to be edited based on the character deleting information, storing blank character information after executing the character deleting operation to a newly added character editing file, and recording target initial position information and target character length information of the blank character information; and executing character insertion operation of the character to be edited based on the inserted character information, storing new inserted character information after executing the character insertion operation into a newly added character editing file, and recording target initial position information and target character length information of the new inserted character information.
In this embodiment, as shown in fig. 7, a character deleting operation of a character to be edited is performed based on deleted character information, where, when a piece table performs an operation demonstration of deleting all characters in a document content of the document to be edited, the piece table can be seen to have an initial text original file, that is, an original text parent file, which is not modified after being determined, that is, a mode of the original file is changed to a read-only mode, the blank character information after performing the character deleting operation is stored in an add file, that is, the blank character information is stored in the newly added character editing file, and only an operation of adding the blank character information at the end of the application-only is performed, and at the same time, newly inserted character information after performing the character inserting operation is stored in the newly added character editing file, and the target character information of the newly inserted character information and the target character information are recorded in the piece table. For example: when the character to be edited is A large span of text, the character number of the character to be edited in the original text parent file is acquired, the character number 0 corresponding to the initial character A of the character to be edited and the character length 19 of the whole character to be edited are acquired from the piece table entry, after the character deleting operation is executed, the generated blank information of the deleted character is written into the add file, meanwhile, the initial position information and the character length information of the deleted character are recorded, when the character operation for deleting the large is executed, the initial character number 2 where the large is located and the information with the character length of 5 are written into the piece table entry, and the operation for deleting the large is completed.
In this embodiment, as shown in fig. 8, a character insertion operation of a character to be edited is performed based on newly added character information, where, when the piece table performs an operation demonstration of deleting all characters in the document content of the document to be edited, it can be seen that the piece table has an initial text original file, that is, an original text parent file, which is not modified after being determined, that is, the mode of the original file is changed to a read-only mode, the newly inserted character information after the character insertion operation is performed is stored in an add file, that is, the add file is also a character editing file, and only an operation of adding blank character information at the end is performed, and at the same time, the newly inserted character information after the character insertion operation is performed is stored in the newly added character editing file, and the target character information of the target character information are recorded in the piece table. And finally determining what the existing edited text content is, and reading the items in the piece table to spell the existing character string. Thus, all character shifting operations at the O (N) level are converted into operations of reading the piece table entries and searching in two files, and the time complexity of inserting and deleting characters is optimized to the log N level.
Step S24: acquiring unedited characters, initial position information and character length information corresponding to each unedited character from the target original text file; and according to the target initial position information, the target character length information, the initial position information corresponding to the unedited character and the character length information, performing character string splicing on the target character information and the unedited character in the character editing file to obtain a spliced character string generated after the character editing operation is performed.
In this embodiment, it is determined what the existing edited text content is, and the entries in the piece table are to be read, so that the existing character string is spelled. Thus, all character shifting operations at the O (N) level are converted into operations of reading the piece table entries and searching in two files, and the time complexity of inserting and deleting characters is optimized to the log N level.
The above-mentioned piece table is actually applied to the memory model through the mapping relation of fig. 9, and the text sequences in the document need to be mapped into the original file and the add file rapidly, so as to achieve the purpose of rapid response editing. Specifically, the logical position and the storage position of the document content after being divided according to the attribute information of the character are mapped rapidly, for example: the divided logic positions are: the storage positions corresponding to [0-6], [7-12], [13-14], [15-17] are as follows: [0-6], [14-19], [11-13], [9-10]. Then, still adopt red black tree as basic data structure, set up a tree structure for logical position and storage position separately, and associate each other, this is the memory data structure minor tree mapping tree that this method is used for text flow finally, as shown in figure 10. In code, the structure of a node may be defined as follows:
struct MirrorNode{
RBNode*parent;
RBNode*left;
RBNode*right;
Color color;
T data;
int position;
int length;
MirrorNode*mapping;
}
Step S25: and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document.
The more detailed processing procedures in steps S21, S22 and S25 refer to the above disclosed embodiments, and are not described herein.
Therefore, the new data structure is used, the time complexity of all editing operations of the text attribute and the text stream can be reduced, the response time of the large text is greatly reduced, and the user experience is improved. The tree structure is different from the continuous storage of the array in the memory, and the flexibility of the memory is improved. The specific implementation scheme of the data structure and the algorithm in the memory is provided, namely, an existing available memory model is provided and can be directly used for the actual development of doc documents.
Referring to FIG. 11, the present invention also discloses a document editing apparatus comprising:
the metadata editing module 11 is configured to determine metadata of a document to be edited based on attribute editing information in a document editing request, and edit coordinates of attribute nodes where the metadata is located according to a red-black tree structure rule, so as to obtain edited metadata;
a character editing module 12, configured to determine, from a storage memory, a target original text file in which a character to be edited is located based on deletion and/or insertion character information in the document editing request, store target character information after a character editing operation performed based on the deletion and/or insertion character information to a newly added character editing file, and record target start position information and target character length information of the target character information;
The character splicing module 13 is configured to determine a post-splice character string generated after performing a character editing operation from the target original text file and the character editing file according to the target starting position information and the target character length information;
and the document editing module 14 is used for performing attribute editing on the spliced character strings by using the edited metadata so as to obtain an edited target document.
Therefore, the application discloses that metadata of a document to be edited is determined based on attribute editing information in a document editing request, and attribute node coordinates where the metadata are located are edited according to a red-black tree structure rule so as to obtain edited metadata; determining a target original text file in which a character to be edited is located from a storage memory based on deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information; determining a spliced character string generated after performing character editing operation from the target original text file and the character editing file according to the target initial position information and the target character length information; and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document. It can be seen that, by using the red-black tree structure to replace the array structure, the attribute node coordinates where the metadata are located are edited by using the red-black tree structure rule, so that the time complexity of adding and deleting the space is lower than that of the attribute node coordinates processed by the array structure, then, aiming at the editing request of deleting or inserting character information into the document character content in the document editing request, the target character information after the character editing operation of deleting or inserting the character information is additionally stored into the newly added character editing file, and then, the final character searching and splicing operation is replaced by the character editing file and the original text file to move the characters in the document editing, thereby reducing the time complexity of editing the document stream.
Further, the embodiment of the present application further discloses an electronic device, and fig. 12 is a block diagram of the electronic device 20 according to an exemplary embodiment, where the content of the figure is not to be considered as any limitation on the scope of use of the present application.
Fig. 12 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is used for storing a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the document editing method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
Processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing ), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array ). The processor 21 may also comprise a main processor, which is a processor for processing data in an awake state, also called CPU (Central Processing Unit ); a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit, image processor) for rendering and drawing of content required to be displayed by the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence ) processor for processing computing operations related to machine learning.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon may include an operating system 221, a computer program 222, and the like, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and the computer program 222, so as to implement the operation and processing of the processor 21 on the mass data 223 in the memory 22, which may be Windows Server, netware, unix, linux, etc. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the document editing method performed by the electronic device 20 as disclosed in any of the previous embodiments. The data 223 may include, in addition to data received by the electronic device and transmitted by the external device, data collected by the input/output interface 25 itself, and so on.
Further, the application also discloses a computer readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the document editing method disclosed previously. For specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application. The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in random access Memory RAM (Random Access Memory), memory, read-Only Memory ROM (Read Only Memory), electrically programmable EPROM (Electrically Programmable Read Only Memory), electrically erasable programmable EEPROM (Electric Erasable Programmable Read Only Memory), registers, hard disk, a removable disk, a CD-ROM (Compact Disc-Read Only Memory), or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description of the document editing method, apparatus, device and medium provided by the present invention applies specific examples to illustrate the principles and embodiments of the present invention, and the above examples are only used to help understand the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (10)

1. A document editing method, comprising:
determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule to obtain edited metadata;
determining a target original text file in which a character to be edited is located from a storage memory based on deleted and/or inserted character information in the document editing request, storing target character information after character editing operation executed based on the deleted and/or inserted character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information;
determining a spliced character string generated after performing character editing operation from the target original text file and the character editing file according to the target initial position information and the target character length information;
and performing attribute editing on the spliced character string by using the edited metadata so as to obtain an edited target document.
2. The document editing method according to claim 1, wherein before determining metadata of the document to be edited based on the property editing information in the document editing request, further comprising:
And receiving a document editing request, determining a document to be edited based on the document editing request, and loading character string information and metadata in the document to be edited into a storage memory.
3. The document editing method according to claim 1, wherein editing the attribute node coordinates where the metadata is located according to the red-black tree structure rule to obtain edited metadata includes:
determining metadata of a red-black tree structure of a document to be edited based on attribute editing information in the document editing request;
determining attribute node coordinates of a red-black tree structure where the metadata to be edited are currently located;
and editing the attribute node coordinates of the corresponding metadata according to the red-black tree structural rule of subtracting the attribute node coordinate value of the first father attribute node smaller than the current node coordinate value from the current node coordinate value of the attribute node coordinates, so as to obtain the metadata after the attribute node coordinates are edited.
4. The method for editing a document according to claim 1, wherein before determining a target original text file in which a character to be edited is located from a storage memory based on the deleted and/or inserted character information in the document editing request, the method further comprises:
Splitting the document content of the document to be edited according to the character number sequence of characters in the document content of the document to be edited so as to obtain a plurality of document fragments, and respectively storing the document fragments in the corresponding original text files.
5. The document editing method according to claim 4, wherein the determining the target original text file in which the character to be edited is located from the storage memory based on the deleted and/or inserted character information in the document editing request includes:
and determining an original text file in which the character to be edited is positioned from all original text files in a storage memory based on the character number in the deleting and/or inserting character information of the document editing request so as to obtain a target original text file.
6. The document editing method according to claim 1, wherein storing the target character information after the character editing operation performed based on the deletion and/or insertion character information to the newly added character editing file, and recording the target start position information and the target character length information of the target character information, comprises:
executing character deleting operation of the character to be edited based on the character deleting information, storing blank character information after executing the character deleting operation to a newly added character editing file, and recording target initial position information and target character length information of the blank character information;
And executing character insertion operation of the character to be edited based on the inserted character information, storing new inserted character information after executing the character insertion operation into a newly added character editing file, and recording target initial position information and target character length information of the new inserted character information.
7. The document editing method according to any one of claims 1 to 6, wherein the determining, from the target original text file and the character editing file, a post-splice character string generated after performing a character editing operation based on the target start position information and the target character length information, comprises:
acquiring unedited characters, initial position information and character length information corresponding to each unedited character from the target original text file;
and according to the target initial position information, the target character length information, the initial position information corresponding to the unedited character and the character length information, performing character string splicing on the target character information and the unedited character in the character editing file to obtain a spliced character string generated after the character editing operation is performed.
8. A document editing apparatus, comprising:
the metadata editing module is used for determining metadata of a document to be edited based on attribute editing information in a document editing request, and editing attribute node coordinates where the metadata are located according to a red-black tree structure rule so as to obtain edited metadata;
the character editing module is used for determining a target original text file in which a character to be edited is located from a storage memory based on the deleting and/or inserting character information in the document editing request, storing target character information after character editing operation executed based on the deleting and/or inserting character information into a newly added character editing file, and recording target starting position information and target character length information of the target character information;
the character splicing module is used for determining a spliced character string generated after the character editing operation is executed from the target original text file and the character editing file according to the target initial position information and the target character length information;
and the document editing module is used for performing attribute editing on the spliced character strings by using the edited metadata so as to obtain an edited target document.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the document editing method as claimed in any of claims 1 to 7.
10. A computer-readable storage medium storing a computer program; wherein the computer program when executed by a processor implements the steps of the document editing method of any of claims 1 to 7.
CN202311237195.7A 2023-09-22 2023-09-22 Document editing method, device, equipment and medium Pending CN117252160A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311237195.7A CN117252160A (en) 2023-09-22 2023-09-22 Document editing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311237195.7A CN117252160A (en) 2023-09-22 2023-09-22 Document editing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN117252160A true CN117252160A (en) 2023-12-19

Family

ID=89130873

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311237195.7A Pending CN117252160A (en) 2023-09-22 2023-09-22 Document editing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117252160A (en)

Similar Documents

Publication Publication Date Title
CN109254733B (en) Method, device and system for storing data
JP3178475B2 (en) Data processing device
CN108647305B (en) Document format conversion method and device
CN108647244B (en) Theme teaching resource integration method in form of thinking guide graph and network storage system
KR20160003682A (en) Hydration and dehydration with placeholders
US8458231B1 (en) Word processor data organization
EP2336898A1 (en) Method and system for processing electronic data
CN107203574A (en) Data management and the polymerization of data analysis
JP2009520284A (en) Access method of XML file data
US20200067860A1 (en) File sending in instant messaging application
CN107977357A (en) Error correction method, device and its equipment based on user feedback
CN110390082A (en) A kind of communication matrix control methods and system
US9063949B2 (en) Inferring a sequence of editing operations to facilitate merging versions of a shared document
CN117252160A (en) Document editing method, device, equipment and medium
US20170161522A1 (en) Organizing key-value information sets into hierarchical representations for efficient signature computation given change information
CN116028062A (en) Target code generation method, NPU instruction display method and device
WO2021012499A1 (en) File comparison method and apparatus, computer device and storage medium
CN115017161A (en) Method, device and application for updating tree data structure by combining virtual DOM
CN107408104B (en) Declarative cascading reordering of styles
CN114329720A (en) UI data synchronization method and device, electronic equipment and storage medium
KR101259911B1 (en) A rule-based ontology converting device for converting from relational database to an ontology instance and the method thereof
CN113282776B (en) Data processing system for graphics engine resource file compression
US8655929B2 (en) Modification of data within a file
JP2009294950A (en) Device and method for structuring and processing document
CN114691935A (en) Thinking guide graph structured data management method and system and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination