A text review front-end interactive method and system

By establishing a positional index relationship between plain text and rich text and using Ajax technology, the compatibility and performance issues of existing text review technologies have been resolved, achieving efficient rich text review and improving user experience and development efficiency.

CN118798141BActive Publication Date: 2024-11-19CHENGDU RADIO & TELEVISION MEDIA CULTRUAL DIFFUSION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411287717.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-11-19
Estimated Expiration
2044-09-14

AI Technical Summary

Technical Problem

Existing text review technologies have limitations in terms of compatibility, performance, and format preservation. In particular, they consume a lot of computational resources when processing rich text, resulting in a degraded user experience and low efficiency.

Method used

By using JavaScript to calculate and establish the position index relationship of plain text in rich text, errors in the rich text can be displayed and easily modified. The mapping between plain text and rich text index arrays is used, combined with Ajax technology for text proofreading, and style changes can be made in the rich text editor.

Benefits of technology

It improves text review efficiency, reduces system resource requirements, ensures stable operation in different browser environments and applicability to multiple editors, maintains consistency of original format and style, and simplifies the development cycle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118798141B_ABST
    Figure CN118798141B_ABST
Patent Text Reader

Abstract

The present invention provides a text review front-end interaction method and system, which relates to the technical field of computer front-end software, and solves the limitations of existing text review technologies in terms of compatibility, performance and format retention. The method comprises: the front-end extracts a rich text index array and a plain text corresponding to the rich text based on a rich text editor and its rich text; the plain text is reviewed and processed to obtain the index position of an abnormal phrase in the plain text and the corresponding error correction information and then returned; the front-end changes the style of the corresponding phrase in the rich text based on the rich text editor according to the rich text index array, the index position and the error correction information; after the style of the corresponding phrase is changed, JavaScript is used to monitor whether an interactive operation occurs in the rich text in the rich text editor, and the text is reviewed again after the interactive operation. The present invention can be applied to any scenario where content positioning of the rich text is required, and the text review efficiency is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer front-end software, and is applied to a text proofreading process, and in particular to a text proofreading front-end interaction method and system. Background Art

[0002] With the rapid development of Internet technology and the widespread use of social media platforms, the content creation industry has ushered in a new era of rapid development. Both individuals and enterprises are using various forms of content (such as text, pictures, videos, etc.) to express themselves, convey information, and shape brand image. In this process, high-quality content has become a key factor in attracting user attention and enhancing interactivity.

[0003] In order to ensure the professionalism and compliance of the published content, text review has become an indispensable part. Text review not only includes basic text proofreading (such as spelling errors, grammatical errors, etc.), but also covers deeper content review (such as the accuracy of leaders' names and positions, the screening of pornographic, evidence-related, and terrorist-related information, the rationality of text logic, and the information check of celebrities, etc.). The accuracy of these aspects is crucial to maintaining the professional image and legal compliance of the published content.

[0004] Although there are many text review tools and services on the market, they still have certain limitations in terms of functionality and user experience. The specific methods and limitations are as follows:

[0005] Masking method: This proofreading method usually adds a mask layer on the basis of the original document to highlight or mark incorrect content. Although this method can better maintain the format of the original document, when processing rich text, it is necessary to consider compatibility with existing editors, because the masking method usually needs to be compatible with specific rich text editors. In addition, the dynamic generation and update of the mask layer requires a lot of computing resources, especially when processing large amounts of text, which may lead to significant performance degradation, which will cause delays in the proofreading process, thus affecting the user experience.

[0006] Plain text presentation: This is another common practice, which converts the document into a plain text format for review. Although this method simplifies the process, the style information of the original document is lost. This means that users need to take additional steps to restore the original formatting after completing the review, which increases the workload, and the process is cumbersome and error-prone. In addition, because the process loses the visual cues of the original document, the reviewer may need to spend more time to understand the text structure and context, which also leads to low review efficiency.

[0007] In summary, existing proofreading methods have limitations in meeting the growing demand for proofreading. Therefore, how to develop a new technology to be applied to the proofreading process is particularly important and has become a research focus for technical personnel in this field. Summary of the invention

[0008] Based on the current status of the background technology, the purpose of the present invention is to solve the limitations of existing text review technologies in terms of compatibility, performance, and format retention, and therefore proposes a text review front-end interactive method and system. The present invention uses a one-time calculation method of JavaScript to establish a one-to-one position index relationship between plain text and rich text, thereby realizing the display of error positions in rich text and the interaction of various convenient modification requirements. The present invention can be applied to any scenario where content positioning of rich text is required, effectively improving the efficiency of text review.

[0009] The present invention adopts the following technical solutions to achieve the purpose:

[0010] A text review front-end interactive method, the method comprising the following steps:

[0011] S1. The front end calls the text extraction function based on the rich text editor and the rich text therein to extract the rich text index array and the plain text corresponding to the rich text;

[0012] S2, reviewing the plain text, obtaining the index position of the abnormal phrase in the plain text and the corresponding error correction information, and returning it to the front end;

[0013] S3. The front end changes the style of the corresponding phrases in the rich text based on the extracted rich text index array and the returned index position and error correction information and the rich text editor;

[0014] S4. After the corresponding phrase style is changed, JavaScript is used to monitor whether the rich text in the rich text editor undergoes any interactive operation, and the text is reviewed again after the interactive operation.

[0015] Specifically, in step S1, the front end calls the text extraction function, traverses the rich text and clears all tags in the rich text to obtain the corresponding plain text; at the same time, an array of the index position corresponding to each character in the plain text in the rich text is obtained, and the rich text index array is obtained after recording.

[0016] Preferably, in step S2, the extracted plain text is submitted to the text review interface through Ajax technology, and the text review interface parses the plain text by calling the text error correction model in the background to determine the abnormal phrases in the plain text; the index start and end positions of the abnormal phrases in the plain text and the corresponding error prompt information are combined into Json information and then returned to the front end.

[0017] Preferably, in step S3, the front end traverses the abnormal phrases contained in the Json information through the Json information returned during the review process, and performs index query in the rich text index array extracted in step S1 according to the index start and end positions corresponding to the abnormal phrases, to obtain the index position of the corresponding phrase in the rich text;

[0018] Subsequently, the front-end, based on the rich text editor, indexes the characters of the corresponding phrase in the rich text, adds a custom Span tag and Class attribute to it, implements the style change of the corresponding phrase in the rich text, and replaces the rich text with the style change in the rich text editor to locate the corresponding phrase.

[0019] The present invention also provides a text review front-end interaction system, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the aforementioned text review front-end interaction method.

[0020] In summary, due to the adoption of this technical solution, the beneficial effects of the present invention are as follows:

[0021] The present invention reduces the technical threshold and is easy to understand and implement by creating a specific class attribute and copy monitoring mechanism, and establishing a concise text index correspondence. The present invention also optimizes the algorithm and re-renders the style only when necessary (such as when submitting a text for review), avoiding performance loss caused by frequent calculation of text offsets during the editing process, improving the user experience while reducing the demand for system resources.

[0022] The present invention does not rely on a specific browser or its version, ensuring stable operation in different browser environments. In addition, since the present invention only deals with the problem at the HTML level, there is no need to consider the impact of changes in browser window size. The method itself is applicable to a variety of rich text editors and is not limited by the specific implementation details or version updates of the editor, ensuring wide applicability and long-term stability.

[0023] The implementation process of the present invention is simple and clear, which helps to shorten the development cycle and speed up product iteration. At the same time, the present invention can retain the original format and style from the Word document or other editing tools, ensure the consistency and integrity of the content when it is transmitted between different platforms, and meet the user's demand for high-fidelity rich text review and processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a diagram briefly describing the overall steps of the method of the present invention;

[0025] Figure 2 The present invention is a detailed schematic diagram of the process of the method. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the parts of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0027] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0028] Example

[0029] A text review front-end interactive method, Figure 1 The steps of the method are briefly described as follows:

[0030] S1. The front end calls the text extraction function based on the rich text editor and the rich text therein to extract the rich text index array and the plain text corresponding to the rich text;

[0031] S2, reviewing the plain text, obtaining the index position of the abnormal phrase in the plain text and the corresponding error correction information, and returning it to the front end;

[0032] S3. The front end changes the style of the corresponding phrases in the rich text based on the extracted rich text index array and the returned index position and error correction information and the rich text editor;

[0033] S4. After the corresponding phrase style is changed, JavaScript is used to monitor whether the rich text in the rich text editor undergoes any interactive operation, and the text is reviewed again after the interactive operation.

[0034] This embodiment will introduce the details of each step in detail according to the above step sequence, and the detailed execution process of the method can be simultaneously compared with Figure 2 's hint.

[0035] In step S1 of this embodiment, the front end obtains rich text from the rich text editor through the global object document of the jQuery library of JavaScript (JS for short). The rich text editor is a common component in front-end development, which allows users to enter text with formatting styles, such as bold, italic, list, etc. When the jQuery library of JavaScript is used to process the content of the rich text editor, this embodiment is implemented by operating the document global object.

[0036] The front end calls the text extraction function, traverses the rich text and clears all the tags in the rich text to obtain the corresponding plain text; at the same time, an array of the index position corresponding to each character in the plain text in the rich text is obtained, and the rich text index array is obtained after recording. This extraction method of the present embodiment can accurately record the position of each character in the original rich text, so it is very useful for application scenarios that require precise matching and positioning, such as text review, etc. It can effectively process rich text data, extract plain text content, and maintain the original position information, which facilitates subsequent data processing and display.

[0037] In this embodiment, the specific operations of extracting the plain text and rich text index arrays are as follows:

[0038] For the obtained rich text, determine the number of left angle brackets "<" and right angle brackets ">" in the rich text, select the value of the larger one as the number of for loop traversals, and traverse the rich text;

[0039] Through JavaScript's indexOf and slice methods, determine whether the current character is an HTML tag and the position of the HTML tag; if the current character is not an HTML tag, add it to the extracted plain text; if the current character is an HTML tag, determine whether it is a line break attribute tag; if it is a line break attribute tag, add a line break character to the corresponding position in the extracted plain text to complete the extraction of the plain text;

[0040] After extracting the plain text between HTML tags, traverse the plain text to obtain the index position relationship corresponding to each character in the plain text in the rich text, and at the same time clear multiple consecutive line breaks and their corresponding positions in the plain text and index position relationship, so that only one line break is retained between words and sentences in the plain text, thereby completing the extraction of the plain text and rich text index arrays.

[0041] The reason why this embodiment adopts the solution of step S1 above is as follows: this embodiment selects the front-end processing method, which can reduce the concurrency and processing pressure of the back-end and improve the review efficiency; this method does not rely on the type and function of the rich text editor, which reduces the research and testing work of the rich text editor. You can directly select a rich text editor such as UEditor that has a high degree of style restoration for file types such as Word, thereby avoiding the style change problem caused by the rich text editor. In addition, this method has no restrictions on browser versions, and there is no need to consider the impact of browser types on text review projects.

[0042] In step S2 of this embodiment, the extracted plain text is submitted to the text review interface through Ajax technology. The text review interface parses the plain text by calling the text error correction model in the background to determine the abnormal phrases in the plain text. The index start and end positions of the abnormal phrases in the plain text and the corresponding error prompt information are combined into Json information and then returned to the front end.

[0043] Ajax technology can send asynchronous requests to the server to submit plain text that needs to be reviewed; on the server side, the text review interface can further call a pre-trained text correction model to analyze and process the plain text; the text correction model checks the grammar and spelling of the plain text, and finds out the abnormal phrases in it. The abnormal phrases also include sensitive words, political, pornographic, terrorist and other types of errors. The model can also support the determination of the specific location of the abnormal phrases in the plain text in terms of business functions, and obtain the index start and end positions; the multiple fields in the Json information can include the start position, end position and error description of each abnormal phrase.

[0044] In step S3 of this embodiment, the front end traverses the abnormal phrases contained in the Json information through the Json information returned during the review process, and performs index query in the rich text index array extracted in step S1 according to the index start and end positions corresponding to the abnormal phrases, to obtain the index position of the corresponding phrase in the rich text.

[0045] Subsequently, the front end, based on the rich text editor, indexes the characters of the corresponding phrase in the rich text, adds a custom Span tag and Class attribute to it, realizes the style change of the corresponding phrase in the rich text, and replaces the rich text after the style change into the rich text editor to locate the corresponding phrase. In this embodiment, the custom Class attribute is underlined and has a red background, etc., to mark the corresponding phrase through the cascading style sheet CSS method, which is a preferred method for locating the mark.

[0046] Regarding the specific content of the above step S3, this embodiment has some preferred or important points to note:

[0047] 1. Traverse the abnormal phrases in the Json information in reverse order, from back to front, which will facilitate the subsequent addition of custom tags;

[0048] 2. The custom Class attribute should have the same special character segment and be placed in the first position of the Span tag. This will facilitate the subsequent clearing of custom Span tags by regular matching without affecting the original style.

[0049] 3. For the corresponding phrases in the rich text, add a custom Span tag and Class attribute to each character to prevent abnormal phrases in the plain text from being discontinuous in the rich text.

[0050] In step S4 of this embodiment, the content in the rich text editor is monitored through JavaScript to detect whether the style of the rich text has changed; if the style of the rich text has changed, the custom Class attribute is modified through JavaScript to perform style interaction operations of the rich text, such as style clearing.

[0051] As a preferred embodiment of this embodiment, when JavaScript is used to monitor the rich text editor, JavaScript will continue to monitor the copy operation; when the copy operation of the rich text is monitored, the copied HTML content is first obtained, and then the custom style clearing operation is performed. According to the custom Class attribute, the custom Span tag is cleared by regular matching, and the text in the Span tag is retained. Finally, the processed HTML content is written to the clipboard to complete the custom style clearing of the corresponding rich text. This method ensures that the copied content only contains plain text or preset styles with better compatibility, avoiding unnecessary formatting problems.

[0052] The above method can effectively manage the content of the rich text editor, and is particularly useful when the present embodiment is applied to the text review process and consistency and simplicity need to be maintained. For example, when collaboratively editing documents or sharing content across platforms for review, this method can help reduce processing problems caused by incompatible styles or redundant styles.

[0053] The entire method logic of this embodiment realizes the front-end function of text review by separating plain text, establishing the index position relationship between plain text and rich text, and monitoring replication. The combination of these main technical points realizes the front-end function of text review. The establishment of the index position relationship between plain text and rich text can be applied to any technical scenario that requires the positioning of rich text content. The development efficiency is improved, providing users with a more friendly and efficient text editing and review environment.

[0054] The method of this embodiment can also be effectively deployed in a computer to become a text review front-end interactive system, which includes a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the text review front-end interactive method.

[0055] Furthermore, these computer programs / instructions may be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that can implement the functions specified by one or more steps in the method of this embodiment.

Claims

1. A text review front-end interactive method, characterized in that: The method comprises the following steps: S1. The front end calls the text extraction function based on the rich text editor and the rich text therein to extract the rich text index array and the plain text corresponding to the rich text; S2, reviewing the plain text, obtaining the index position of the abnormal phrase in the plain text and the corresponding error correction information, and returning it to the front end; S3. The front end changes the style of the corresponding phrases in the rich text based on the extracted rich text index array and the returned index position and error correction information and the rich text editor; S4. After the corresponding phrase style is changed, JavaScript is used to monitor whether the rich text in the rich text editor has any interactive operation, and the text is reviewed again after the interactive operation; In step S1, the front end calls the text extraction function, traverses the rich text and clears all tags in the rich text to obtain the corresponding plain text; at the same time, an array of the index position corresponding to each character in the plain text in the rich text is obtained, and the rich text index array is obtained after recording; For the obtained rich text, determine the number of left angle brackets "<" and right angle brackets ">" in the rich text, select the value of the larger one as the number of for loop traversals, and traverse the rich text; Through JavaScript's indexOf and slice methods, determine whether the current character is an HTML tag and the position of the HTML tag; if the current character is not an HTML tag, add it to the extracted plain text; if the current character is an HTML tag, determine whether it is a line break attribute tag; if it is a line break attribute tag, add a line break character to the corresponding position in the extracted plain text to complete the extraction of the plain text; After extracting the plain text between HTML tags, traverse the plain text to obtain the index position relationship corresponding to each character in the plain text in the rich text, and at the same time clear multiple consecutive line breaks and their corresponding positions in the plain text and index position relationship, so that only one line break is retained between words and sentences in the plain text, thereby completing the extraction of the plain text and rich text index arrays.

2. The text review front-end interactive method according to claim 1, characterized in that: In step S1, the front end obtains rich text from the rich text editor through the global object document of the jQuery library of JavaScript.

3. The text review front-end interactive method according to claim 1, characterized in that: In step S2, the extracted plain text is submitted to the text review interface through Ajax technology. The text review interface parses the plain text by calling the text error correction model in the background to determine the abnormal phrases in the plain text; the index start and end positions of the abnormal phrases in the plain text and the corresponding error prompt information are combined into Json information and returned to the front end.

4. The text review front-end interactive method according to claim 1, characterized in that: In step S3, the front end traverses the abnormal phrases contained in the Json information through the Json information returned during the review process, and performs index query in the rich text index array extracted in step S1 according to the index start and end positions corresponding to the abnormal phrases, to obtain the index position of the corresponding phrase in the rich text; Subsequently, the front-end, based on the rich text editor, indexes the characters of the corresponding phrase in the rich text, adds a custom Span tag and Class attribute to it, implements the style change of the corresponding phrase in the rich text, and replaces the rich text with the style change in the rich text editor to locate the corresponding phrase.

5. The text review front-end interactive method according to claim 4, characterized in that: The Json information is traversed in reverse order, from back to front; for the custom Class attribute, it is made to have the same special character segment and is arranged in the first position of the Span tag; for the corresponding phrases in the rich text, a custom Span tag and Class attribute are added to each character.

6. The text review front-end interactive method according to claim 5, characterized in that: In step S4, the content in the rich text editor is monitored through JavaScript to detect whether the style of the rich text has changed; if the style of the rich text has changed, the custom Class attribute is modified through JavaScript to perform style interaction operations on the rich text.

7. The text review front-end interactive method according to claim 6, characterized in that: When monitoring the rich text editor through JavaScript, JavaScript continuously listens for copy operations; when a copy operation on the rich text is monitored, the copied HTML content is first obtained, and then a custom style clearing operation is performed. According to the custom Class attribute, the custom Span tag is cleared through regular matching, and the text in the Span tag is retained. Finally, the processed HTML content is written to the clipboard to complete the custom style clearing of the corresponding rich text.

8. A text review front-end interactive system, comprising a memory, a processor, and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the text review front-end interaction method described in claim 1.