Method and system for realizing front-end visualization based on rich text pre-annotation

Through the front-end visualization method of pre-labeling based on rich text and combined with the knowledge extraction model, the text is parsed and reconstructed, and the problems of time-consuming and labor-intensive manual labeling and format damage are solved, efficient and accurate labeling results are achieved and text styles are retained.

CN116244476BActive Publication Date: 2025-08-22INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310269508.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-20
Publication Date
2025-08-22
Estimated Expiration
2043-03-20

AI Technical Summary

Technical Problem

In the prior art, manual labeling of corpus is time-consuming and labor-intensive, the labeling in specific fields is high, and the results are inaccurate, and the pre-labeling method destroys the text format and cannot effectively retain the text style.

Method used

The front-end visualization method based on rich text is adopted, combined with the knowledge extraction model, and the hypertext markup language string is parsed and reconstructed, and automatic pre-labeling of entities and relationships is realized, retaining text format and improving labeling efficiency and accuracy.

Benefits of technology

It improves the labeling efficiency and accuracy, reduces manual interference, retains the original layout structure of the text, especially the style of pictures and tables, and improves the readability of the labeling results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244476B_ABST
    Figure CN116244476B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for realizing front-end visualization of pre-annotation based on rich text, which belongs to the field of knowledge graph technology. The knowledge of the input rich text content is automatically extracted, and a new virtual node syntax tree is constructed according to the knowledge extraction result and compared with the existing rich text, and then the hypertext markup language string is segmented, and different tags are constructed according to different segmentation types, and finally the text structure is replaced and redrawn for the rich text to realize pre-annotation of the rich text content. On the one hand, the present invention can solve the problems of high cost and inaccurate annotation results of pre-annotation algorithms for specific domain models; on the other hand, it can solve the problem that pre-annotation cannot retain text styles, especially the styles of pictures and tables, which helps to improve the readability of the annotated text and reduce the difficulty of manual secondary editing of the pre-annotation results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of knowledge graph technology and proposes a pre-annotation implementation method and system for entity relationship extraction based on rich text. Background Art

[0002] In the field of knowledge graph technology, in order to fully implement deep learning algorithm models, it is necessary to obtain large-scale corpora for entity extraction model training. In the actual corpus collection process, the labeled data is often collected through manual annotation. Manual annotation is time-consuming and labor-intensive. For an article of tens of thousands or even hundreds of thousands of words, manual annotation alone would consume a significant amount of time and be inefficient. Furthermore, in domain-specific knowledge extraction tasks, the highly specialized nature of domain data and the scarcity of domain experts make the annotation cost of domain corpora extremely high and the results inaccurate. Therefore, pre-annotating model algorithms for specific domains and combining this with manual secondary annotation can significantly improve annotation efficiency and accuracy.

[0003] Existing annotation and pre-annotation visualization methods mostly convert formatted text into plain text and then embed it into SVG or CANVAS canvas for display. Although this method can achieve the annotation effect, it seriously destroys the original layout format of the text. Summary of the Invention

[0004] The purpose of the present invention is to propose a pre-annotation front-end visualization implementation method and system based on rich text, combined with the knowledge extraction model algorithm interface call, to segment and reconstruct the rich text according to the algorithm extraction results, to achieve automatic pre-annotation based on rich text content entities and relationships, improve annotation efficiency, and improve the readability of annotation results.

[0005] To achieve the above object, the technical solution adopted by the present invention is as follows:

[0006] A method for implementing pre-annotation front-end visualization based on rich text includes the following steps:

[0007] 1) Convert the target document to be annotated into a hypertext markup language string and display it in rich text format on the front end;

[0008] 2) parsing the hypertext markup language string to obtain a plain text string, which is then input into a knowledge extraction algorithm model trained in the corresponding field to extract knowledge, and outputting an extraction result, which includes an entity result list and an association relationship list;

[0009] 3) comparing the entity types in the entity result list with the locally stored entity types, and comparing the association relationship types in the association relationship list with the locally stored association relationship types, and storing and displaying entity types and association relationship types that do not exist in the locally stored data;

[0010] 4) For the DOM node tree of the hypertext markup language string, an index range is set for each node; then, whether the index range of the entity item in the entity result list is within the index range of the current node is determined; if so, the entity item is added to the entity result list entityRangeList of the current node; if the current node is a leaf node, the entityRangeList is mounted on the leaf node as the annotation result of the current node, and the text of the current node is subjected to the following fragmentation processing;

[0011] 5) Divide the index range of the entity items in entityRangeList into different index intervals based on whether they contain intersection or inclusion relationships, and construct entityRangeList into a multidimensional array annotationList consisting of two annotation types: normal annotation and nested annotation, and mount it on the current node;

[0012] 6) Compare the index range of each item in annotationList with the index range of the current node. Based on the comparison result, divide the text of the current node into three types of segments: normal text, normal annotations, and nested annotations. Then construct the array segmentList and mount it on the current node.

[0013] 7) According to the three types of fragmentation, reconstruct the Dom structure of each segment of segmentList, replace the structure with a hypertext markup language string, and annotate the Dom structure with an annotation block. Splice the replaced hypertext markup language strings in sequence to obtain the spliced ​​Dom structure, replace the current node with this structure and display it visually.

[0014] Furthermore, in step 1), the Apache POI open source tool is first integrated using Java language to convert the target document to be annotated in doc, docx or txt format into a hypertext markup language string; then it is transmitted to the front end through the Http service to be displayed in rich text form on the web page.

[0015] Furthermore, the step of setting the index range for each node in step 4) includes: adding custom attributes startIndex and endIndex to each Dom node, where startIndex represents the starting index of the text content contained in the node relative to the full text content, and endIndex represents the ending index of the extracted text contained in the node relative to the full text.

[0016] Furthermore, the entity items in the entity result list include extracted text, entity type, startIndex and endIndex.

[0017] Furthermore, in step 4), the Dom node tree is traversed in reverse order to determine whether the index range of the current entity result list is within the index range of the current node.

[0018] Furthermore, in step 5), the index ranges of the entity items in entityRangeList are sorted from small to large, and then looped through to determine whether the index ranges of the entity items in entityRangeList contain an intersection or inclusion relationship.

[0019] Furthermore, in step 6), the annotationList is traversed in a loop.

[0020] Furthermore, each item in segmentList contains segment type type, text content text, value and index range range.

[0021] Furthermore, the annotation block in step 7) includes three parts: a label, an area bracket, and a selected text color block.

[0022] A pre-annotation front-end visualization implementation system based on rich text, including:

[0023] The document parsing module is used to convert the target document to be annotated into a hypertext markup language string and display it in rich text format on the front end;

[0024] The model algorithm module is used to parse the hypertext markup language string to obtain a plain text string, and then extract knowledge from the plain text string through the trained knowledge extraction algorithm model, and output the extraction result, which includes an entity result list and an association relationship list;

[0025] A text deconstruction module is used to compare the entity types in the entity result list with the locally stored entity types, compare the association relationship types in the association relationship list with the locally stored association relationship types, and store and display the entity types and association relationship types that do not exist in the locally stored entity types; for the Dom node tree of the hypertext markup language string, set an index range for each node; then determine whether the index range of the entity item in the entity result list is within the index range of the current node, and if so, add the entity item to the entity result list entityRangeList of the current node; if the current node is a leaf node, mount the entityRangeList as the annotation result of the current node on the leaf node, and perform the following fragmentation processing on the text of the current node; according to whether the index range of the entity item of the entityRangeList contains intersection or inclusion The inclusion relationship is divided into different index intervals, and entityRangeList is constructed into a multidimensional array annotationList consisting of two annotation types: ordinary annotation and nested annotation, and mounted on the current node; the index range of each item in annotationList is compared with the index range of the current node, and the text of the current node is divided into three types of fragments: ordinary text, ordinary annotation and nested annotation according to the comparison result, and an array segmentList is constructed and mounted on the current node; according to the three types of fragments, the Dom structure of each fragment of segmentList is reconstructed, and the structure is replaced with a hypertext markup language string, and the Dom structure is annotated with an annotation block, and the replaced hypertext markup language strings are spliced ​​in sequence to obtain the spliced ​​Dom structure, and the current node is replaced with the structure and displayed visually.

[0026] The beneficial effects of the present invention are as follows:

[0027] The method of the present invention is based on the rich text display format (document layout), and is used to carry out style-free destruction visualization display for the entity relationship extraction result and pre-marking result of the knowledge extraction model. Relative to the pre-marking of unformatted text, the pre-marking of the rich text format can better retain the layout structure of the original text, and under the premise of ensuring the original expression of the author as much as possible, the marked text is subjected to visual annotation. On the one hand, the readability of the marked text is improved, and on the other hand, the interference of pre-marking on secondary manual annotation is reduced. The method of the present invention can retain the format of the text, picture and table in the rich text, improve the readability of the entity relationship extraction result of various texts, can flexibly switch the domain model algorithm, and can assist in manual annotation, improve the efficiency of annotation and the accuracy of annotation result. It can solve the problem that the pre-marking cost of a specific domain model algorithm is high and the annotation result is inaccurate, and solve the problem that pre-marking cannot retain the text style, particularly the style of picture and table, help improve the readability of the marked text, and reduce the difficulty of manually editing the pre-marking result. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 The present invention is a flowchart of a rich text-based pre-annotation front-end visualization method according to an embodiment.

[0029] Figure 2 This is a block diagram of a rich text-based pre-annotation front-end visualization system according to an embodiment.

[0030] Figure 3 An example diagram of fragmentation processing of a hypertext markup language structure.

[0031] Figure 4 This is a schematic diagram of the labeled block structure.

[0032] Figures 5A-5B This is an example image of a label. DETAILED DESCRIPTION

[0033] The present invention is further described in detail below through specific embodiments and drawings.

[0034] This embodiment specifically proposes a method for realizing front-end visualization of pre-annotation based on rich text. The processing flow of the method is as follows: Figure 1 The method is implemented by a pre-annotated front-end visualization system based on rich text, which includes Figure 2 The document parsing module, model algorithm module and text deconstruction module are shown. The specific processing steps are as follows:

[0035] Step 1: The document parsing module realizes the hypertext markup language conversion of the target document to be annotated

[0036] In order to obtain the target text to be annotated in rich text format, the Apache POI open source tool is first integrated with the Java language, and documents in formats such as doc, docx, and txt are uploaded to the server. The Java service is called to convert the uploaded document into Hypertext Markup Language and return it to the front end in the form of a Hypertext Markup Language string through the Http service for rich text display.

[0037] Step 2: Implementing knowledge extraction algorithm entity extraction by the model algorithm module

[0038] Parse the HTML string converted in step 1 to obtain a plain text string, removing tags and spaces. Then, train knowledge extraction algorithm models for multiple different domains and provide knowledge extraction services. Based on the domain of the target text to be annotated, invoke the corresponding domain knowledge extraction algorithm model service, passing the plain text string as an input parameter. The interface returns the extraction results, primarily including a list of entity results and a list of relationships.

[0039] Step 3: Merge entity types and relationship types using the text deconstruction module

[0040] Compare the entity types in the entity result list with the entity types stored in the DB. If the entity type does not exist, it is necessary to store and display the entity type; compare the relationship type in the relationship list with the local relationship type. If the relationship type does not exist, it is necessary to store and display the relationship type.

[0041] Step 4: Implementing HTML structure fragmentation processing by the text deconstruction module

[0042] The Dom node tree of the Hypertext Markup Language string obtained in step 1 and the entity result list extracted in step 2 are processed as follows:

[0043] First, perform a breadth-first traversal of the DOM node tree and add custom attributes, startIndex and endIndex, to each DOM node. These attributes represent the start and end indices of the extracted text relative to the full text. The entity items in the entity result list are composed of the extracted text, the entity type, and the start and end indices of the extracted text relative to the full text.

[0044] Perform a reverse loop traversal on the Dom node tree with added custom attributes, and perform a reverse loop traversal on the extracted entity result list within the loop to determine whether the start index and end index of the entity item in the entity result list are within the range of the start index and end index of the node. If so, split the entity item from the entity result list and add it to the newly created entity result list belonging to the node. The entity result list of the node is specifically the entityRangeList array, and each item in the entityRangeList array is called an entity item of the entity result list.

[0045] Because the DOM node tree is hierarchical, it is necessary to determine whether the current DOM node is a leaf node. If not, the previous process is recursively called. If it is a leaf node, the entityRangeList array is attached to the leaf node as the annotation result of the current node. If the entityRangeList array of the current node contains a value, it means that the current node has pre-annotated results, and the following sharding process is performed on the current node.

[0046] Sort the start and end indexes of the entity items in the entityRangeList array from small to large, then loop through the sorted array and divide it into different index intervals based on whether the start and end indexes of the entity items in the entityRangeList array have an overlapping or inclusive relationship. The entityRangeList array is constructed into an annotationList multidimensional array consisting of two annotation types: ordinary annotations and nested annotations, and mounted on the current node.

[0047] The annotationList multidimensional array of the current node contains the normal annotation extraction results and nested annotation extraction results of the current node. The multidimensional array is traversed in a loop, and the starting index and ending index of each item are compared with the starting index and ending index of the current node. The node text content within the normal annotation result index range is classified as normal annotation type, and the node text content within the nested annotation extraction result index range is classified as nested annotation distinguish type. The remaining text of the current node is classified as normal text type. After comparison, the node text is divided into segment types such as normal text type, normal annotation type, and nested annotation distinguish type. A segmentList array is constructed. Each item of the segmentList array contains the current segment type type, text content text, current annotationList item value, and the index range of the current item range, and is mounted on the current node.

[0048] Figure 3 An example diagram of fragmentation processing of a hypertext markup language structure.

[0049] Step 5: Reconstruct the rich text tags of the text to be annotated by the text deconstruction module

[0050] According to the fragmentation results of step 4, i.e., three types of fragmentation, the Dom structure of each segment of different types in segmentList is reconstructed in turn, and different hypertext markup language string structure parsing and replacement are performed. At the same time, the Dom structure is annotated with the annotation block, and the reconstructed Dom structure, i.e., the newly replaced hypertext markup language string, is spliced ​​in order, and finally the current node is replaced with the spliced ​​Dom structure. At this point, the pre-annotated results can be echoed without destroying the tables, pictures, and text structure of the original text. After the page is re-rendered, the pre-annotated entity tags can retain the original document layout style display in the browser page.

[0051] In order to improve the display effect of annotation, the annotation block is divided into three parts: label, area bracket, and selected text color block. Figure 4 As shown. Annotation blocks are primarily implemented through a combination of various tags, with area brackets drawn using SVG. Its height layout relies on Flex layout, with the tag body automatically expanding to accommodate line height and adapting to the order of annotations. Horizontally, especially when nesting annotations, a horizontal offset is calculated based on the index of the annotated text within the currently nested text and the text's FontSize, shifting the color block and label block horizontally. Figures 5A-5B This is an example image of a label.

[0052] While the specific details, implementation algorithms, and drawings of the present invention are disclosed for illustrative purposes, intended to facilitate understanding and implementation of the present invention, those skilled in the art will appreciate that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. The present invention should not be limited to the preferred embodiments disclosed in this specification and the accompanying drawings; the scope of protection claimed by the present invention shall be determined by the scope defined in the claims.

Claims

1. A method for realizing front-end visualization of pre-annotation based on rich text, characterized in that: The following steps are involved: 1) Convert the target document to be annotated into a hypertext markup language string and display it in rich text format on the front end; 2) parsing the hypertext markup language string to obtain a plain text string, which is then input into a knowledge extraction algorithm model trained in the corresponding field to extract knowledge, and outputting an extraction result, which includes an entity result list and an association relationship list; 3) comparing the entity types in the entity result list with the locally stored entity types, and comparing the association relationship types in the association relationship list with the locally stored association relationship types, and storing and displaying entity types and association relationship types that do not exist in the locally stored data; 4) For the DOM node tree of the hypertext markup language string, set an index range for each node; then determine whether the index range of the entity item in the entity result list is within the index range of the current node; if so, add the entity item to the entity result list entityRangeList of the current node; If the current node is a leaf node, the entityRangeList is mounted on the leaf node as the annotation result of the current node, and the text of the current node is fragmented as follows; 5) Divide the index range of the entity items in entityRangeList into different index intervals based on whether they contain intersection or inclusion relationships, and construct entityRangeList into a multidimensional array annotationList consisting of two annotation types: normal annotation and nested annotation, and mount it on the current node; 6) Compare the index range of each item in annotationList with the index range of the current node. Based on the comparison result, divide the text of the current node into three types of segments: normal text, normal annotations, and nested annotations. Then construct the array segmentList and mount it on the current node. 7) According to the three types of fragmentation, reconstruct the Dom structure of each segment of segmentList, replace the structure with a hypertext markup language string, and annotate the Dom structure with an annotation block. Splice the replaced hypertext markup language strings in sequence to obtain the spliced ​​Dom structure, replace the current node with this structure and display it visually.

2. The method according to claim 1, wherein In step 1), the Apache POI open source tool is first integrated using the Java language to convert the target document to be annotated in doc, docx or txt format into a Hypertext Markup Language string; then it is transmitted to the front end through the Http service to be displayed in rich text form on the web page.

3. The method according to claim 1, wherein The step of setting the index range for each node in step 4) includes: adding custom attributes startIndex and endIndex to each Dom node, where startIndex represents the starting index of the text content contained in the node relative to the full text content, and endIndex represents the ending index of the extracted text contained in the node relative to the full text.

4. The method according to claim 3, wherein The entity items in the entity result list include extracted text, entity type, startIndex and endIndex.

5. The method according to claim 1, wherein In step 4), the Dom node tree is traversed in reverse order to determine whether the index range of the current entity result list is within the index range of the current node.

6. The method according to claim 1, wherein In step 5), the index ranges of the entity items in entityRangeList are sorted from small to large, and then looped through to determine whether the index ranges of the entity items in entityRangeList contain an intersection or inclusion relationship.

7. The method according to claim 1, wherein In step 6), the annotationList is traversed in a loop.

8. The method according to claim 1, wherein Each item in segmentList contains segment type type, text content text, value and index range range.

9. The method according to claim 1, wherein The annotation block in step 7) includes three parts: a label, an area bracket, and a selected text color block.

10. A pre-annotated front-end visualization implementation system based on rich text, characterized in that: include: The document parsing module is used to convert the target document to be annotated into a hypertext markup language string and display it in rich text format on the front end; The model algorithm module is used to parse the hypertext markup language string to obtain a plain text string, and then extract knowledge from the plain text string through the trained knowledge extraction algorithm model, and output the extraction result, which includes an entity result list and an association relationship list; A text deconstruction module is used to compare the entity types in the entity result list with the locally stored entity types, compare the association relationship types in the association relationship list with the locally stored association relationship types, and store and display the entity types and association relationship types that do not exist in the locally stored entity type and association relationship type; for the Dom node tree of the hypertext markup language string, set an index range for each node; then determine whether the index range of the entity item in the entity result list is within the index range of the current node; if so, add the entity item to the entity result list entityRangeList of the current node; If the current node is a leaf node, entityRangeList is mounted on the leaf node as the annotation result of the current node, and the text of the current node is segmented as follows; the index range of the entity item of entityRangeList is divided into different index intervals according to whether it contains an intersection or inclusion relationship, and entityRangeList is constructed into a multidimensional array annotationList consisting of two annotation types: ordinary annotation and nested annotation, and mounted on the current node; the index range of each item of annotationList is compared with the index range of the current node, and the text of the current node is divided into three segmentation types: ordinary text, ordinary annotation and nested annotation according to the comparison result, and an array segmentList is constructed and mounted on the current node; according to the three segmentation types, the Dom structure of each segment of segmentList is reconstructed, and the structure is replaced with a hypertext markup language string, and the Dom structure is annotated with an annotation block, and the replaced hypertext markup language strings are spliced ​​in sequence to obtain the spliced ​​Dom structure, which replaces the current node and is visually displayed.

Citation Information

Patent Citations

  • Rich text data processing method and device, electronic equipment and computer storage medium

    CN111274760A

  • Entity labeling method, module and device based on dictionary matching

    CN112347765A