A method, device, storage medium and electronic device for automatic corpus annotation
By obtaining corpus annotation requirements and using pre-trained classification models and regular expressions to process the documents to be annotated, automatic annotation of corpus is achieved, solving the problems of low efficiency and high cost of manual annotation in the existing technology, and improving annotation quality and efficiency. .
Patent Information
- Application Number
- CN202311695823.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-12-11
AI Technical Summary
In the existing technology, high-quality corpus annotation requires a lot of manual participation, which is inefficient and costly, and the annotation results have inconsistency and quality problems.
By obtaining corpus annotation requirements, pre-trained classification models and regular expressions are used to identify the titles and content of the documents to be annotated, generate corpus annotation data that meets the requirements, and realize automatic annotation of corpus.
It improves the efficiency of corpus annotation, reduces annotation costs, ensures the consistency of annotation quality, and greatly improves the efficiency of full-text annotation.
Smart Images

Figure CN117743573B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data annotation, and in particular to a method, device, storage medium and electronic device for automatic corpus annotation. Background Art
[0002] In order to achieve the classification task of the model, it is necessary to prepare pre-labeled data. In addition to requiring a large amount of labeled data to train the model, the quality of the labeled data directly affects the recognition effect of the pre-trained model classification task. At present, high-quality labeled data usually needs to be done manually. The labeler obtains each piece of data according to the preset requirements and labels it accordingly to improve the recognition effect of the subsequent training model. However, the manual labeling method is inefficient and requires a lot of cost.
[0003] Therefore, how to provide a technical solution for an efficient method for automatic corpus annotation has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The purpose of some embodiments of the present application is to provide a method, device, storage medium and electronic device for automatic corpus annotation. The technical solutions of the embodiments of the present application can improve the efficiency of corpus annotation and reduce the annotation cost.
[0005] In a first aspect, some embodiments of the present application provide a method for automatic corpus annotation, comprising: obtaining corpus annotation requirements, wherein the corpus annotation requirements include: corpus type, number of corpus training classifications, corpus labels, corpus annotation range, and at least one of the ratio of positive and negative samples of the corpus; performing title recognition on documents to be annotated, and processing the content corresponding to the title to obtain files to be classified; and obtaining corpus annotation data corresponding to the corpus annotation requirements based on the files to be classified and a pre-trained classification model.
[0006] Some embodiments of the present application can obtain the corpus annotation requirements, identify and process the documents to be annotated to obtain the documents to be classified, and finally obtain the corpus annotation data through the pre-training classification model. The embodiments of the present application can realize the automatic annotation of corpus, improve the annotation efficiency and reduce the annotation cost.
[0007] In some embodiments, the title recognition of the document to be annotated includes: obtaining a pre-set regular expression related to document title recognition, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; using the regular expression to recognize the document to be annotated to obtain the title.
[0008] Some embodiments of the present application identify the document to be annotated through a set regular expression to obtain the title, thereby providing effective data support for subsequent automatic annotation.
[0009] In some embodiments, the processing of the content corresponding to the title to obtain the file to be classified includes: parsing the content corresponding to the title to obtain the parsed document text; determining the text content corresponding to the corpus annotation range from the parsed document text; and preprocessing the text content to obtain the file to be classified.
[0010] Some embodiments of the present application parse the content corresponding to the title and determine the text content corresponding to the corpus annotation range and then pre-process to obtain the file to be classified, which can meet the user's annotation needs and improve the annotation efficiency.
[0011] In some embodiments, the corpus annotation data corresponding to the corpus annotation requirements are obtained based on the file to be classified and the pre-trained classification model: the file to be classified is input into the pre-trained classification model, and a classification result matching the corpus type, the number of corpus training classifications and the corpus label is output; and the corpus annotation data corresponding to the ratio of positive and negative samples of the corpus is generated based on the classification result.
[0012] Some embodiments of the present application obtain corpus annotation data that meets the corpus annotation requirements through files to be classified and pre-trained classification models, with high efficiency.
[0013] In some embodiments, the pre-trained classification model adopts a time displacement mechanism.
[0014] In the second aspect, some embodiments of the present application provide an automatic annotation device, comprising: an acquisition module, used to obtain corpus annotation requirements, wherein the corpus annotation requirements include: corpus type, number of corpus training classifications, corpus labels, corpus annotation range, and at least one of the ratio of positive and negative samples of the corpus; an identification module, used to perform title recognition on the document to be annotated, and process the content corresponding to the title to obtain the file to be classified; and an annotation module, used to obtain corpus annotation data corresponding to the corpus annotation requirements based on the file to be classified and a pre-trained classification model.
[0015] In some embodiments, the recognition module is used to: obtain a pre-set regular expression related to document title recognition, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; use the regular expression to identify the document to be annotated to obtain the title.
[0016] In some embodiments, the recognition module is used to: parse the content corresponding to the title to obtain the parsed document text; determine the text content corresponding to the corpus annotation range from the parsed document text; and preprocess the text content to obtain the file to be classified.
[0017] In a third aspect, some embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the method described in any embodiment of the first aspect.
[0018] In a fourth aspect, some embodiments of the present application provide an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor can implement a method as described in any embodiment of the first aspect when executing the program.
[0019] In a fifth aspect, some embodiments of the present application provide a computer program product, wherein the computer program product comprises a computer program, wherein the computer program, when executed by a processor, can implement the method described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of some embodiments of the present application, the drawings required for use in some embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 A system diagram for automatic corpus annotation provided for some embodiments of the present application;
[0022] Figure 2 One of the flow charts of the method for automatic corpus annotation provided in some embodiments of the present application;
[0023] Figure 3 Flowchart 2 of the method for automatic annotation of corpus provided in some embodiments of the present application;
[0024] Figure 4 A block diagram of the apparatus for automatic corpus annotation provided in some embodiments of the present application;
[0025] Figure 5 A schematic diagram of an electronic device is provided for some embodiments of the present application. DETAILED DESCRIPTION
[0026] The technical solutions in some embodiments of the present application will be described below in conjunction with the drawings in some embodiments of the present application.
[0027] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0028] In the related technology, the classification task of the pre-trained model belongs to the research content of natural language processing, which usually refers to: fine-tuning specific tasks based on the pre-trained model (such as BERT, GPT-2, RoBERTa, etc.). For example, text classification from literature. The classification task is essentially a kind of recognition, for example, identifying sentences in the text that describe scientific value (in fact, it is to divide the sentences in the text into two categories, one is the scientific value sentence, and the other is not the scientific value sentence). Similarly, identify the sentences in the text that describe research problems (in fact, divide the sentences in the text into two categories, one is the research problem sentence, and the other is not the research problem sentence). Of course, there are also multiple classification situations. For example, each sentence in the abstract can be divided into multiple types such as research background, research content, research methods, research problems, and research conclusions.
[0029] In order to realize the classification task of the model, it is necessary to prepare labeled data. Each piece of data usually contains a text and a label. The text is the object that needs to be classified, which can be a sentence, a paragraph, or an article; the label is the category of the text. For example, {"text": The research method of this article can help alleviate traffic congestion and improve the operating efficiency of the entire fleet, "label": scientific value sentence}, {"text": This article mainly considers the impact of the driver's personality on the following behavior and constructs a following model, "label": not a scientific value sentence}. Among them, the text is the sentence following the text, which is the object to be judged; the label is the category after the label, whether it is a scientific value sentence or not. By constructing content similar to the above and inputting it into the pre-trained model, the model is allowed to learn the features in the sentence and finally achieve the classification effect.
[0030] However, high-quality data annotation usually requires manual work. The annotator obtains each piece of data and labels it accordingly according to the preset requirements. In addition to requiring a large amount of annotated data to train the model, the quality of the annotated data directly affects the recognition effect of the pre-trained model classification task. In particular, for large-scale full-text data annotation, it is usually necessary to manually read, understand and annotate the text sentence by sentence. On average, a foreign document with more than 10,000 words takes about 30-40 minutes to annotate manually, and the annotation efficiency is very low. Moreover, once a multi-classification task is encountered, dozens of documents often cannot obtain enough annotated data to improve the classification effect of the model. In addition, the format of the documents is mostly pdf. In addition to obtaining the annotated corpus they want, the annotator must also paste the obtained content into their own training set and give labels. A large number of repetitive operations also increase the workload and time of annotation.
[0031] As can be seen from the above-mentioned related technologies, large-scale data labeling requires a lot of manpower and time, with low efficiency and high labeling costs; and different labelers may have different understandings and interpretations of the same data, which may lead to inconsistent labeling results. In addition, due to human errors or negligence, the quality of labeling may also be affected.
[0032] In view of this, some embodiments of the present application provide a method for automatic annotation of corpus, which can automatically identify the title of the document to be annotated based on the acquired corpus annotation requirements, and then pre-process the content corresponding to the title to obtain the file to be classified. Finally, according to the file to be classified and the pre-trained classification model, the corpus annotation data corresponding to the corpus annotation requirements is output. Some embodiments of the present application can realize automatic annotation of corpus, and the annotation quality is consistent, the efficiency is high and the cost is low.
[0033] The following is combined with Figure 1 The overall structure of the system for automatic corpus annotation provided by some embodiments of the present application is exemplified.
[0034] like Figure 1 As shown, some embodiments of the present application provide a system for automatic corpus annotation, which includes: a terminal 100 and an annotation server 200. Among them, the user can set or select the corpus annotation requirements on the terminal 100, which is sent by the terminal 100 to the annotation server 200. After the annotation server 200 obtains the corpus annotation requirements, it can identify the uploaded documents to be annotated by title, and process the content under the title to obtain the files to be classified. Finally, the files to be classified are input into the pre-deployed pre-trained classification model, and the corpus annotation data is output and fed back to the terminal 100.
[0035] In some embodiments of the present application, the terminal 100 may be a mobile terminal or a non-portable computer terminal, which is not specifically limited in the embodiments of the present application.
[0036] In other embodiments of the present application, if the terminal 100 has the function of identifying and processing the document to be annotated to obtain the file to be classified, and deploying the pre-trained classification model and annotating the file to be classified, then the annotation server 200 may not be set. The specific setting can be flexibly made according to the actual situation, and the embodiments of the present application are not limited thereto.
[0037] The following is combined with Figure 2 The implementation process of automatic corpus annotation performed by the annotation server 200 provided in some embodiments of the present application is exemplified.
[0038] Please see attached Figure 2 , Figure 2 A flow chart of a method for automatic corpus annotation provided in some embodiments of the present application, the method for automatic corpus annotation includes:
[0039] S210, obtaining corpus annotation requirements, wherein the corpus annotation requirements include: at least one of: corpus type, number of corpus training categories, corpus labels, corpus annotation range, and ratio of corpus positive and negative samples.
[0040] For example, in some embodiments of the present application, first, the annotator (that is, the user) can select the corpus annotation requirements on the terminal 100. For example, select the corpus type, such as: research questions, research methods, research value, research limitations or future research directions. The annotator customizes the number of classifications according to the annotation requirements (as a specific example of the number of corpus training classifications), such as: binary, three-class, four-class, etc. The annotator can also define the name of the judgment label (as a specific example of the corpus label), for example: the binary classification annotation task can define the name of the label as: 0 or 1, or it can be defined as: yes or no, etc., to facilitate the annotation and download directly for model training. The annotator can also select the corpus annotation range by himself, for example: full text annotation or chapter annotation, where the chapter can choose the annotation for the abstract part, the introduction part, the conclusion part, etc. The annotator can also set the corpus positive and negative sample ratio, that is: the number of positive and negative samples required by the annotator in each annotation process, such as the positive and negative sample ratio of 5:1 or 10:1.
[0041] It is understandable that the corpus annotation requirements can be configured and modified according to the needs of the annotator, and the embodiments of the present application are not limited to this.
[0042] S220, performing title recognition on the document to be annotated, and processing the content corresponding to the title to obtain the document to be classified.
[0043] For example, in some embodiments of the present application, annotators can upload documents to be annotated in batches. After the annotation server 200 reads the documents to be annotated, it first needs to parse them to obtain files to be classified.
[0044] Since documents are generally in PDF format, in order to better conform to the data structure of scientific and technological documents, this application improves the PDF parsing algorithm, first identifying the titles of the abstract, introduction, data, methods, conclusions, discussion and other chapters in the document, and then parsing the corresponding content in the title to meet the user's needs for marking different chapters.
[0045] In some embodiments of the present application, S220 may include: obtaining a pre-set regular expression related to document title identification, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; using the regular expression to identify the document to be annotated to obtain the title.
[0046] For example, in some embodiments of the present application, the file to be annotated is identified by using a regular expression pre-added in the annotation server 200 to obtain a title.
[0047] It is understandable that the regular expression has been pre-generated before the corpus is annotated. Specifically, the regular expression generation method includes: pre-extracting the text in the document using PDFMiner in the Python library; then, by investigating a large number of documents, analyzing and summarizing the features in the documents, and generating regular expressions in different forms. For example, the titles of various chapters in a paper, such as "Abstract", "Introduction", "Data", "Methods", "Conclusions", and "Discussion", usually start with uppercase letters, some are all uppercase letters, some will bold the title, some will add Roman numerals, and some will use specific fonts or font sizes. Therefore, based on the results of the survey, a regular expression is generated and added to the annotation server 200 to improve the recognition ability of scientific and technological document titles in PDF parsing.
[0048] For example, the regular expression:
[0049] ^(Abstract|Introduction|Data|Method|Conclusions|Discussion|Summary|ABSTRAT|INTRODUCTION|DATA|METHOD|CONCLUSION|DISCUSION|SUMMARY|ⅠAbstract|ⅡIntroduction|ⅢData|ⅣMethod|ⅤConclusions|ⅥDiscussion).*$ is used to match lines that start with "Abstract", "Introduction", "Data", "Method", "Conclusions", or "Discussion". "^" indicates the beginning of a line, "." matches any character (except line break), "*" indicates that the preceding character can appear any number of times (including 0 times), and "$" indicates the end of a line; in addition, according to different document structures, regular expressions can be further expanded and supplemented to ensure the accuracy of title recognition during PDF parsing. It should be understood that the embodiments of the present application are not limited to this.
[0050] In some embodiments of the present application, S220 may include: parsing the content corresponding to the title to obtain the parsed document text; determining the text content corresponding to the corpus annotation range from the parsed document text; and preprocessing the text content to obtain the file to be classified.
[0051] For example, in some embodiments of the present application, after identifying the title, the content under each title is parsed to obtain the parsed file text. Afterwards, the text content corresponding to the corpus annotation range is screened out and preprocessed to obtain the processed text (as a specific example of the file to be classified). The preprocessing may include: removing stop words, special characters, etc., which are not specifically limited in the embodiments of the present application.
[0052] S230, acquiring corpus annotation data corresponding to the corpus annotation requirement according to the to-be-classified file and the pre-trained classification model.
[0053] For example, in some embodiments of the present application, the pre-trained classification model may be automatically selected by the annotation server 200, or may be actively uploaded by an annotator, and the present application does not make any specific limitation thereto.
[0054] In some embodiments of the present application, S230 may include: inputting the file to be classified into the pre-trained classification model, outputting a classification result that matches the corpus type, the number of corpus training classifications and the corpus label; and generating the corpus annotation data corresponding to the ratio of positive and negative samples of the corpus based on the classification result.
[0055] For example, in some embodiments of the present application, the processed text is input into a pre-trained classification model for classification and identification, and the output results are displayed in the form of sentences and labels (as a specific example of the classification results). Among them, the form of the label is to match the number of corpus training classifications set by the annotator and the corpus label. Finally, the pre-trained classification model can also automatically generate the annotated corpus annotation data according to the positive and negative sample ratio of the corpus customized by the annotator, and download it for direct use by the annotator. Alternatively, the annotator can choose the corpus annotation data that meets the positive and negative sample ratio of the corpus according to the output results, and the embodiments of the present application are not specifically limited here. Through the corpus annotation data, the user can train the required classification model. By automatically generating corpus annotation data, it is avoided that the user finds sentences of the corpus one by one, and also pastes and copies them into a specific training set, and finally adjusts the format and other cumbersome processes, thereby improving the annotation efficiency.
[0056] In addition, in some embodiments of the present application, the pre-trained classification model adopts a time displacement mechanism.
[0057] For example, the pre-trained classification model used in some embodiments of the present application is an improved model based on RoBERTa (Robustly optimized BERT approach). First, compared with the BERT (Bidirectional Encoder Representations from Transformers) model, RoBERTa uses a dynamic masking mechanism to randomly mask words in each training instance, that is, each time the input sequence (that is, the file to be classified) is seen, a different part will be randomly selected for masking. Therefore, the model can see multiple masked versions of the input sequence, which is conducive to learning from more contexts, thereby reducing prediction bias and increasing the generalization ability of the model.
[0058] In order to better adapt to the corpus annotation requirements of the classified files in this application, this application improves the self-attention mechanism of the RoBERTa model: by introducing time shifting, the model is allowed to introduce the information of the previous step when processing each sequence element (that is, the text in the file to be classified). Specifically, assume that the size of the input hidden state x is (B, T, C), where B is the batch size, T is the sequence length, and C is the size of the hidden state. Then, first move the first half of x (that is, the first C / 2 channels) backward one step, then truncate the result to maintain the original size, and then splice it with the second half of x. In this way, the model will introduce the information of the previous step when processing each sequence element, thereby helping the model to better capture the dynamic characteristics of the sequence data and improve the annotation accuracy. It should be noted that the type of pre-trained classification model can be adjusted according to actual conditions, and the embodiments of the present application are not limited to this.
[0059] The following is combined with Figure 3 The specific process of automatic corpus annotation provided by some embodiments of the present application is exemplified.
[0060] Please see attached Figure 3 , Figure 3 A flow chart of a method for automatic corpus annotation provided in some embodiments of the present application.
[0061] The above process is explained below as an example.
[0062] S310, obtaining corpus annotation requirements, which include: corpus type, number of corpus training categories, corpus labels, corpus annotation range, and corpus positive and negative sample ratios.
[0063] S320, upload the document to be annotated.
[0064] S330, obtaining a pre-set regular expression related to document title recognition.
[0065] S340, using regular expressions to identify the document to be annotated to obtain the title.
[0066] S350, parsing the content corresponding to the title to obtain the parsed document text.
[0067] S360, determining text content corresponding to the corpus annotation range from the parsed document text.
[0068] S370, preprocessing the text content to obtain a file to be classified.
[0069] S380, inputting the file to be classified into the pre-trained classification model to generate corpus annotation data.
[0070] S390, downloading corpus annotation data, wherein the corpus annotation data is used for model training.
[0071] It should be noted that the specific implementation process of S310 to S380 can refer to the method embodiment provided above, and in order to avoid repetition, the detailed description is appropriately omitted here.
[0072] Through some of the above embodiments of the present application, it can be seen that for the full-text single annotation type task, the average time for obtaining the final annotation result is 2-3 minutes per article, which greatly improves the efficiency of full-text annotation; in addition, a pre-trained classification model is used to first judge the corpus to be annotated, and the results after judgment are then displayed to the annotator, which effectively solves the problem of inconsistent annotation quality, thereby improving the annotation quality of the corpus.
[0073] Please refer to Figure 4 , Figure 4 The block diagram of the composition of the apparatus for automatic corpus annotation provided by some embodiments of the present application is shown. It should be understood that the apparatus for automatic corpus annotation corresponds to the above method embodiment and can execute each step involved in the above method embodiment. The specific functions of the apparatus for automatic corpus annotation can be found in the description above. To avoid repetition, the detailed description is appropriately omitted here.
[0074] Figure 4 The device for automatic corpus annotation includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the device for automatic corpus annotation, and the device for automatic corpus annotation includes: an acquisition module 410, used to obtain corpus annotation requirements, wherein the corpus annotation requirements include: corpus type, number of corpus training classifications, corpus labels, corpus annotation range, and at least one of the ratio of positive and negative samples of the corpus; an identification module 420, used to identify the title of the document to be annotated, and process the content corresponding to the title to obtain the file to be classified; a labeling module 430, used to obtain corpus annotation data corresponding to the corpus annotation requirements according to the file to be classified and the pre-trained classification model.
[0075] In some embodiments of the present application, the identification module 420 is used to obtain a pre-set regular expression related to document title identification, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; the document to be annotated is identified using the regular expression to obtain the title.
[0076] In some embodiments of the present application, the identification module 420 is used to parse the content corresponding to the title to obtain the parsed document text; determine the text content corresponding to the corpus annotation range from the parsed document text; and preprocess the text content to obtain the file to be classified.
[0077] In some embodiments of the present application, the labeling module 430 is used to input the file to be classified into the pre-trained classification model, output a classification result that matches the corpus type, the number of corpus training classifications and the corpus label; and generate the corpus labeling data corresponding to the ratio of positive and negative samples of the corpus based on the classification result.
[0078] In some embodiments of the present application, the pre-trained classification model adopts a time displacement mechanism.
[0079] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.
[0080] Some embodiments of the present application further provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the operations of the method corresponding to any of the above methods provided in the above embodiments.
[0081] Some embodiments of the present application further provide a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operations corresponding to any of the above methods provided in the above embodiments.
[0082] like Figure 5 As shown, some embodiments of the present application provide an electronic device 500, which includes: a memory 510, a processor 520, and a computer program stored in the memory 510 and executable on the processor 520, wherein the processor 520 can implement a method as described in any of the above embodiments when reading the program from the memory 510 through a bus 530 and executing the program.
[0083] Processor 520 can process digital signals and can include various computing structures, such as complex instruction set computer structure, reduced instruction set computer structure, or a structure that implements a combination of multiple instruction sets. In some examples, processor 520 can be a microprocessor.
[0084] The memory 510 may be used to store instructions executed by the processor 520 or data related to the execution of instructions. These instructions and / or data may include codes for implementing some or all functions of one or more modules described in the embodiments of the present application. The processor 520 of the disclosed embodiment may be used to execute instructions in the memory 510 to implement the method shown above. The memory 510 includes a dynamic random access memory, a static random access memory, a flash memory, an optical memory, or other memory known to those skilled in the art.
[0085] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0086] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0087] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for automatic corpus annotation, characterized in that: include: Obtaining corpus annotation requirements, wherein the corpus annotation requirements include: at least one of: corpus type, number of corpus training categories, corpus labels, corpus annotation range, and ratio of positive and negative samples of the corpus; Perform title recognition on the document to be annotated, and then process the content corresponding to the title to obtain the document to be classified; According to the to-be-classified file and the pre-trained classification model, corpus annotation data corresponding to the corpus annotation requirement is obtained; the number of the corpus training classifications in the corpus annotation data matches the number of the corpus labels; The pre-trained classification model adopts a time displacement mechanism. When the pre-trained classification model processes each sequence in the file to be classified, the corresponding corpus annotation data is output after the previous step information of each sequence is moved and spliced; the pre-trained classification model is automatically selected based on the corpus annotation requirements; The step of processing the content corresponding to the title to obtain the file to be classified includes: Parse the content corresponding to the title to obtain the parsed document text; determine the text content corresponding to the corpus annotation range from the parsed document text; pre-process the text content to obtain the file to be classified.
2. The method according to claim 1, characterized in that The title recognition of the document to be annotated includes: Obtaining a pre-set regular expression related to document title recognition, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; The document to be annotated is identified using the regular expression to obtain the title.
3. The method according to claim 1 or 2, characterized in that The step of obtaining corpus annotation data corresponding to the corpus annotation requirement according to the to-be-classified file and the pre-trained classification model: Inputting the to-be-classified file into the pre-trained classification model, and outputting a classification result that matches the corpus type, the number of corpus training classifications, and the corpus label; The corpus annotation data corresponding to the ratio of positive and negative samples of the corpus is generated based on the classification result.
4. A device for automatically annotating corpus, characterized in that: The device is used to perform the method according to claim 1, comprising: An acquisition module, used to acquire corpus annotation requirements, wherein the corpus annotation requirements include: at least one of corpus type, number of corpus training categories, corpus labels, corpus annotation range, and ratio of positive and negative samples of the corpus; The recognition module is used to identify the title of the document to be annotated and process the content corresponding to the title to obtain the document to be classified; The annotation module is used to obtain corpus annotation data corresponding to the corpus annotation requirements according to the file to be classified and the pre-trained classification model; the number of corpus training classifications in the corpus annotation data matches the number of corpus labels; wherein the pre-trained classification model adopts a time displacement mechanism, and when the pre-trained classification model processes each sequence in the file to be classified, the corresponding corpus annotation data is outputted by moving and splicing the previous step information of each sequence.
5. The device according to claim 4, characterized in that The identification module is used to: Obtaining a pre-set regular expression related to document title recognition, wherein the regular expression is pre-generated by analyzing multiple document chapter titles; The document to be annotated is identified using the regular expression to obtain the title.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program executes the method according to any one of claims 1 to 3 when executed by a processor.
7. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the computer program executes the method according to any one of claims 1 to 3 when being run by the processor.
Citation Information
Patent Citations
Material corpus generation method and device, computer equipment and storage medium
CN110866107A
