Document classification method and device, computer device and storage medium

By using a document category knowledge graph trained with category sample data for matching, the problem of low accuracy in traditional document classification is solved, achieving higher classification accuracy and cost-effectiveness.

CN115329083BActive Publication Date: 2026-05-29SHENZHEN POWER SUPPLY BUREAU

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN POWER SUPPLY BUREAU
Filing Date
2022-08-25
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Traditional document classification methods that rely on manually constructed document features have low accuracy, resulting in insufficient classification accuracy.

Method used

By acquiring multiple document category knowledge graphs pre-trained with category sample data, the matching degree between the document to be classified and each document category knowledge graph is calculated using knowledge graph matching technology, and the classification result is determined.

Benefits of technology

It improves the accuracy of document classification, reduces human and material costs, and decreases the reliance on large amounts of correctly labeled data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115329083B_ABST
    Figure CN115329083B_ABST
Patent Text Reader

Abstract

The application relates to a document classification method and device, computer equipment and a storage medium. The method comprises the following steps: obtaining a document to be classified; obtaining a plurality of document category knowledge graphs which are trained in advance through category sample data; matching the document to be classified with each document category knowledge graph to obtain a document category matching graph between the document to be classified and each document category knowledge graph; calculating a matching degree between the document to be classified and each document category knowledge graph according to the document category matching graph; and determining a classification result corresponding to the document to be classified according to the matching degree. The method can improve the accuracy of grading classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a document classification method, apparatus, computer device, storage medium, and computer program. Background Technology

[0002] As more and more companies undergo digital and paperless transformation, the number and types of documents in enterprises are also increasing, making document classification one of the most basic needs of enterprises.

[0003] In the traditional approach, features for each document category are constructed based on human experience, and document classification is achieved by matching the features of the document to be classified with the pre-constructed features.

[0004] However, the accuracy of document features built based on human experience is low, which leads to low accuracy in document classification. Summary of the Invention

[0005] Therefore, it is necessary to provide a document classification method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the accuracy of document classification in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a document classification method. The method includes:

[0007] Get the documents to be categorized;

[0008] Obtain multiple document category knowledge graphs pre-trained using category sample data;

[0009] The document to be classified is matched with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0010] Calculate the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph;

[0011] The classification result for the document to be classified is determined based on the matching degree.

[0012] In one embodiment, the method further includes, before obtaining the document to be classified:

[0013] Obtain category sample data for multiple document categories;

[0014] Extract key entities from the category sample data of each document category to obtain the key entities corresponding to each document category;

[0015] The knowledge graphs to be trained are trained according to the key entities corresponding to each document category and the preset domain knowledge base until the training stops, resulting in multiple document category knowledge graphs.

[0016] In one embodiment, the document to be classified is matched with a knowledge graph of various document categories, including:

[0017] Perform word segmentation on the document to be categorized to obtain a list of words corresponding to the document to be categorized.

[0018] The word segmentation list is matched with the knowledge graph of each document category.

[0019] In one embodiment, calculating the matching degree between the document to be classified and the knowledge graphs of each document category based on the document category matching graph includes:

[0020] In the document category matching graph, obtain the co-existing entities of the document to be classified and the knowledge graphs of each document category, as well as the relationship paths between the co-existing entities;

[0021] The matching degree between the document to be classified and the knowledge graph of each document category is calculated based on the co-entities and the relationship paths between them.

[0022] In one embodiment, calculating the matching degree between the document to be classified and the knowledge graphs of each document category based on the co-entities and the relationship paths between co-entities includes:

[0023] Calculate the distance of the co-entities on the corresponding document category knowledge graph based on the relationship paths between co-entities;

[0024] The matching degree between the document to be classified and each document category knowledge graph is calculated based on the number of co-entities and the distance of the co-entities on the corresponding document category knowledge graph.

[0025] In one embodiment, determining the classification result corresponding to the document to be classified based on the matching degree includes:

[0026] Select the document category knowledge graph with the highest matching degree, and determine the document category corresponding to the selected document category knowledge graph as the classification result for the document to be classified.

[0027] Secondly, this application also provides a document classification device. The device includes:

[0028] The document acquisition module is used to acquire documents to be categorized.

[0029] The graph acquisition module is used to acquire multiple document category knowledge graphs that have been pre-trained using category sample data;

[0030] The category matching module is used to match the document to be classified with the knowledge graphs of various document categories to obtain a document category matching graph between the document to be classified and the knowledge graphs of various document categories.

[0031] The matching degree calculation module calculates the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph.

[0032] The document classification module is used to determine the classification result of the document to be classified based on the matching degree.

[0033] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0034] Get the documents to be categorized;

[0035] Obtain multiple document category knowledge graphs pre-trained using category sample data;

[0036] The document to be classified is matched with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0037] Calculate the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph;

[0038] The classification result for the document to be classified is determined based on the matching degree.

[0039] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0040] Get the documents to be categorized;

[0041] Obtain multiple document category knowledge graphs pre-trained using category sample data;

[0042] The document to be classified is matched with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0043] Calculate the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph;

[0044] The classification result for the document to be classified is determined based on the matching degree.

[0045] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0046] Get the documents to be categorized;

[0047] Obtain multiple document category knowledge graphs pre-trained using category sample data;

[0048] The document to be classified is matched with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0049] Calculate the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph;

[0050] The classification result for the document to be classified is determined based on the matching degree.

[0051] The aforementioned document classification method, apparatus, computer device, storage medium, and computer program product, because the document category knowledge graph is trained based on category sample data, can obtain an accurate document category knowledge graph. Then, by matching the document to be classified with each document category knowledge graph, the matching degree between the document to be classified and each document category knowledge graph is calculated based on the obtained matching document category matching graph, thereby determining the classification result corresponding to the document to be classified. This eliminates the need to rely on human experience to pre-construct document features, greatly improving the accuracy of document classification. Furthermore, the category sample data is existing category data that can be directly obtained. Compared with document classification methods based on deep learning algorithms, it does not require a large amount of correctly labeled data as a foundation, thus saving manpower and resources while improving document classification accuracy, thereby reducing document classification costs. Attached Figure Description

[0052] Figure 1 This is a diagram illustrating the application environment of a document classification method in one embodiment.

[0053] Figure 2 This is a flowchart illustrating a document classification method in one embodiment;

[0054] Figure 3 This is a flowchart illustrating the document classification method in another embodiment;

[0055] Figure 4 This is a flowchart illustrating the steps of training a knowledge graph for multiple document categories in one embodiment.

[0056] Figure 5 This is a detailed flowchart of the classification method in another embodiment;

[0057] Figure 6 This is a structural block diagram of a document classification device in one embodiment;

[0058] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0060] The document classification method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Terminal 102 sends a document classification request to server 104. Server 104 parses the document classification request to obtain the document to be classified carried in the request. Server 104 acquires multiple document category knowledge graphs pre-trained with category sample data. Server 104 then matches the document to be classified with each document category knowledge graph to obtain a document category matching graph between the document to be classified and each document category knowledge graph. Server 104 then calculates the matching degree between the document to be classified and each document category knowledge graph based on the document category matching graph. Finally, server 104 determines the classification result corresponding to the document to be classified based on the matching degree. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0061] In one embodiment, such as Figure 2 As shown, a document classification method is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:

[0062] Step 202: Obtain the documents to be categorized.

[0063] Among them, unclassified documents refer to documents that need to be classified in the company's work and business operations.

[0064] Specifically, the server can receive document classification requests sent by terminals. These requests carry the documents to be classified. The server parses the classification requests to obtain the documents to be classified. For example, the documents to be classified could be contracts, invoices, meeting minutes, planning proposals, etc.

[0065] Step 204: Obtain multiple document category knowledge graphs that have been pre-trained using category sample data.

[0066] Here, category sample data refers to the data selected as samples from each category of data. A knowledge graph is a knowledge base with a directed graph structure, where the nodes represent entities or concepts, and the edges represent the semantic relationships between entities or concepts. A document category knowledge graph is the knowledge graph corresponding to a specific document category, where the nodes represent entities related to the corresponding document category, and the edges represent the relationships between entities.

[0067] Specifically, the server pre-stores multiple pre-trained document category knowledge graphs. These knowledge graphs are used to match documents to be classified, thus classifying them. After obtaining a document to be classified, the server can retrieve multiple document category knowledge graphs based on the document classification request. Each document category knowledge graph contains entities related to the corresponding document category and the relationships between those entities.

[0068] Document category knowledge graphs can be pre-trained by a server using category sample data from multiple document categories. Specifically, during the training process, the server can acquire category sample data from multiple document categories and train the knowledge graph to be trained based on the category sample data of each document category. This results in the construction of document category knowledge graphs for each document category, allowing the server to directly access the pre-trained document category knowledge graphs during document classification.

[0069] Step 206: Match the document to be classified with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0070] Among them, the document category matching graph refers to the matching graph generated by matching entities between the document to be classified and the knowledge graphs of various document categories, as well as the relationships between the matching entities.

[0071] Specifically, the server can perform word segmentation on the documents to be classified, and then match the resulting word segmentation list with the knowledge graphs of various document categories to obtain a document category matching graph between the documents to be classified and the knowledge graphs of various document categories. The word segmentation list can include keywords from the document title, table headers, etc.

[0072] Alternatively, the server can use existing word segmentation algorithms to segment the documents to be categorized. For example, existing word segmentation algorithms can be MM (Maximum Matching Method), RMM (Reverse Maximum Matching Method), minimum segmentation method, and bidirectional matching method, etc.

[0073] Step 208: Calculate the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph.

[0074] The matching degree refers to the similarity between the document to be classified and the knowledge graphs of each document category.

[0075] Specifically, the server obtains the co-existing entities and relationships between the document to be classified and the knowledge graphs of each document category from the document category matching graph. Then, the server calculates the matching degree between the document to be classified and the knowledge graphs of each document category based on the co-existing entities and their relationships.

[0076] Step 210: Determine the classification result corresponding to the document to be classified based on the matching degree.

[0077] The classification result refers to the document category corresponding to the document to be classified.

[0078] Specifically, the server can determine the classification result of a document based on its matching degree in several ways. One method is to select the document category knowledge graph with the highest matching degree and determine the document category corresponding to that graph as the classification result. Another method is to compare the highest matching degree with a matching degree threshold. If the highest matching degree is less than the threshold, it indicates that the number of entities matching the document category knowledge graph is too small. In this case, the server can send the document to the terminal, instructing the logged-in staff to classify it. The server then receives the classification result corresponding to the document sent by the terminal.

[0079] Optionally, the server can input the matching scores into a pre-trained classification model. The classification model then selects the document category knowledge graph with the highest matching score from the matching scores, and determines the document category corresponding to the selected document category knowledge graph as the classification result for the document to be classified. The classification model can be CRF (Conditional Random Field), Seq2Seq (Sequence to Sequence), Boosting model, etc.

[0080] For example, Figure 3A flowchart illustrating a document classification method in another embodiment is shown. Here, "document" represents the document to be classified; Category 1 knowledge graph, Category 2 knowledge graph, and Category 3 knowledge graph represent multiple document category knowledge graphs pre-trained using category sample data; and "document-Category 1 matching graph," "document-Category 2 matching graph," and "document-Category 3 matching graph" represent the document category matching graphs obtained after matching the document to be classified with the Category 1, Category 2, and Category 3 knowledge graphs, respectively. The "document-Category 1 evaluation result," "document-Category 2 evaluation result," and "document-Category 3 evaluation result" represent the matching degree between the document to be classified and the Category 1 knowledge graph, the matching degree between the document to be classified and the Category 2 knowledge graph, and the matching degree between the document to be classified and the Category 3 knowledge graph. "Classifier" represents the classification model.

[0081] Specifically, after obtaining the document and the knowledge graphs for Category 1, Category 2, and Category 3, the server matches the document with each of these knowledge graphs to obtain document-Category 1 matching graphs, document-Category 2 matching graphs, and document-Category 3 matching graphs. In these graphs, solid dots represent entities related to each document category, and the lines connecting the solid dots correspond to the relationships between entities.

[0082] The matching degree between the document to be classified and the knowledge graphs of each document category is calculated based on the document-category 1 matching graph, document-category 2 matching graph, and document-category 3 matching graph, yielding the document-category 1 evaluation result, document-category 2 evaluation result, and document-category 3 evaluation result. In the document-category 1, document-category 2, and document-category 3 matching graphs, solid dots represent co-existing entities of the document to be classified and the document category knowledge graphs, while non-solid dots represent non-co-existing entities. Lines represent the relationships between entities in the document-category matching graphs.

[0083] The document-category 1 evaluation results, document-category 2 evaluation results, and document-category 3 evaluation results are respectively input into the classifier. The classifier processes the multiple evaluation results and finally outputs the classification result corresponding to the document.

[0084] In the document classification method described above, the document category knowledge graph is trained based on category sample data, resulting in an accurate document category knowledge graph. Then, by matching the document to be classified against each document category knowledge graph, the matching degree between the document to be classified and each document category knowledge graph is calculated based on the resulting document category matching graph. The classification result is then determined based on the matching degree. This eliminates the need to rely on human experience to pre-construct document features, significantly improving the accuracy of document classification. Furthermore, the category sample data is existing category data that can be directly obtained. Compared to document classification methods based on deep learning algorithms, it does not require a large amount of correctly labeled data as a foundation, thus saving manpower and resources while improving document classification accuracy, thereby reducing the cost of document classification.

[0085] In one embodiment, such as Figure 4 As shown, before obtaining the documents to be classified, the above method also includes a training step for a knowledge graph of multiple document categories, which may include:

[0086] Step 402: Obtain category sample data for multiple document categories.

[0087] Step 404: Extract key entities from the category sample data of each document category to obtain the key entities corresponding to each document category.

[0088] Step 406: Train the knowledge graph to be trained according to the key entities corresponding to each document category and the preset domain knowledge base until the training stopping condition is met, and obtain multiple document category knowledge graphs.

[0089] Here, key entities refer to the core entities in the category sample data that are related to that category. The pre-defined domain knowledge base refers to a knowledge base related to the domain of the document category.

[0090] Specifically, the server can first obtain category data for multiple existing document categories. Document categories can include invoices, contracts, and announcements, etc. Category data refers to the documents corresponding to multiple document categories. Then, category sample data is selected from the category data of each document category to obtain category sample data for multiple document categories.

[0091] Optionally, the server can manually select a preset number of data points from the category data of each document category as category sample data, or it can randomly select a preset number of data points from the category data of each document category as category sample data. For example, the preset number can be 10% to 15% of the sample size.

[0092] The server can employ various entity extraction methods to extract key entities from categorized sample data. These methods can include manual extraction and a combination of manual and model-based extraction. Specifically, the server can determine the entity extraction method based on the length and format of the categorized sample data. For example, when the categorized sample data is short, i.e., a short text document, or a fixed-format document, manual extraction can be used. For example, a fixed-format document could be a receipt. Manual extraction of key entities from the categorized sample data can involve manually selecting key entities such as document names, feature field values, feature field contexts, and the position of the feature field within the document.

[0093] When the category sample data is lengthy, i.e., it consists of long text documents, a combination of manual and model extraction methods can be used. For example, a long text document could be a contract. This combination could involve using the BERT model (Bidirectional Encoder Representations from Transformer, a pre-trained natural language model) to extract the key entities corresponding to each document category from the category sample data of each document.

[0094] The preset domain knowledge base can include knowledge bases for multiple domains, such as finance, supply chain, and OA. Each domain knowledge base can include documents corresponding to all document categories covered in that domain.

[0095] The server extracts key entities as the core entities of the knowledge graph to be trained. These key entities are also the core entities of the document category knowledge graph obtained through training. When each document category corresponds to multiple core entities, the core entities corresponding to each document category are treated as a keyword set. Based on each keyword in the keyword set, relevant knowledge from a predefined domain knowledge base is crawled or retrieved. Relevant knowledge refers to documents in the predefined domain knowledge base related to the core entity. Entities related to the core entity are retrieved from the relevant knowledge to determine the relationships between the retrieved entities. Based on the relationships between the retrieved entities, the retrieved entities are inserted into the corresponding knowledge graph to be trained. Then, the retrieved entities are used as extended entities representing the direct relationships between the key entities of each document category knowledge graph that originally served as keywords. These extended entities are then used to update the corresponding keyword set, i.e., the extended entities are added to the keyword set. A new round of retrieval or crawling is then performed until the training stopping condition is met. For example, the training stopping condition could be reaching a predefined number of iterations or the graph loss value no longer decreasing.

[0096] In this embodiment, training the knowledge graph for each document category only requires a small amount of sample data from each category, without the need for a large amount of correctly labeled data as a foundation. This saves manpower, resources, and document classification costs. Furthermore, the graph can be constructed by combining it with a pre-defined domain knowledge base. When the number of category sample data is small, the number of sample data can be expanded by using the pre-defined domain knowledge base, further improving the comprehensiveness and accuracy of the document category knowledge graph.

[0097] In one embodiment, matching the document to be classified with the knowledge graphs of various document categories includes: performing word segmentation on the document to be classified to obtain a word segmentation list corresponding to the document to be classified; and matching the word segmentation list with the knowledge graphs of various document categories.

[0098] The word segmentation list refers to the data table containing multiple keywords from the document to be categorized, obtained after the document has been segmented into words.

[0099] Specifically, the server can perform word segmentation on the document to be categorized based on a word segmentation dictionary. Assuming the longest word in the dictionary has *i* Chinese characters, the first *i* characters of the current string in the document to be categorized are used as the matching field to search the dictionary. If such an *i*-character word exists in the dictionary, the match is successful, and the matching field is segmented as a word. If no such *i*-character word is found in the dictionary, the match fails, the last character in the matching field is removed, and the remaining string is re-matched. This process continues until a match is successful, i.e., a word is segmented or the length of the remaining string is zero. This completes one round of matching. Then, the next *i*-character string is taken and matched until the entire document to be categorized has been scanned, resulting in a word segmentation list.

[0100] Each keyword in the word segmentation list is matched with a knowledge graph of a document category. When a keyword in the word segmentation list of the document to be classified is successfully matched with an entity in a document category knowledge graph, the successfully matched entity is taken as an entity node in the document category matching graph. By querying the relationships between these successfully matched entities in the corresponding document category knowledge graph, the relationships between these entity nodes in the document category matching graph can be obtained. Thus, based on the entity nodes and the relationships between entity nodes, the document category matching graph between the document to be classified and the knowledge graphs of each document category is obtained.

[0101] For example, after segmenting a document to be classified, the resulting segmentation list includes entities such as "dishes," "amount," and "details." These entities can then be matched with entities in the document category knowledge graph for the document category "restaurant menu." The successfully matched entities in the segmentation list and the document category knowledge graph constitute the entity nodes of the document category matching graph between the document to be classified and the document category knowledge graph for "restaurant menu." By querying the relationships between the successfully matched entities in the document category knowledge graph for "restaurant menu," the relationships between these entity nodes in the document category matching graph can be obtained accordingly. Thus, a document category matching graph between a document to be classified and each document category knowledge graph can be obtained. Subsequently, the server can calculate the matching degree between the document to be classified and each document category knowledge graph based on the obtained matching graph.

[0102] In this embodiment, by performing word segmentation on the document to be classified, a word segmentation list is obtained. The word segmentation list contains multiple keywords of the document to be classified. These keywords correspond to the key features of the document to be classified. Then, the word segmentation list uses these keywords to match with the document category knowledge graph, which can improve the accuracy of the document classification results.

[0103] In one embodiment, calculating the matching degree between the document to be classified and the knowledge graphs of each document category based on the document category matching graph includes: obtaining the co-entities of the document to be classified and the relationship paths between the co-entities and the knowledge graphs of each document category in the document category matching graph; and calculating the matching degree between the document to be classified and the knowledge graphs of each document category based on the co-entities and the relationship paths between the co-entities.

[0104] In this context, co-existing entities refer to entities that successfully match between the document to be classified and the document category knowledge graph. Relationship paths refer to the paths corresponding to the direct relationships between co-existing entities.

[0105] Specifically, co-existing entities are those that successfully match during the matching process between the word segmentation list and the document category knowledge graph. Therefore, all entities in the document category matching graph are entities that appear in both the document to be classified and the document category knowledge graph. By querying the relationships between these entities in the document category matching graph and their corresponding document category knowledge graphs, the relationship paths between these entities in the document category matching graph can be obtained.

[0106] In this embodiment, the matching degree between the document to be classified and the knowledge graph of each document category is calculated by using co-entities and the relationship paths between co-entities, which can improve the accuracy of document classification results.

[0107] In one embodiment, calculating the matching degree between the document to be classified and each document category knowledge graph based on the co-entities and the relationship paths between them includes: calculating the distance between co-entities on the corresponding document category knowledge graph based on the relationship paths between them; and calculating the matching degree between the document to be classified and each document category knowledge graph based on the number of co-entities and the distance between them on the corresponding document category knowledge graph.

[0108] Specifically, the server can use existing graph theory to calculate the distance between co-existing entities on the corresponding document category knowledge graph. A graph has vertices and edges; the distance between two vertices is the minimum number of edges between them. Similarly, the distance between co-existing entities is the minimum number of relational paths between them. The more co-existing entities there are, and the closer their distances are on the corresponding document category knowledge graph, the higher the matching degree between the document to be classified and the corresponding document category knowledge graph.

[0109] The server can obtain the matching degree calculation relationship and calculate the matching degree between the document to be classified and each document category knowledge graph based on the number of co-entities, the distance of the co-entities on the corresponding document category knowledge graph, and the matching degree calculation relationship. For example, the matching degree calculation relationship can be a matching degree calculation formula, as shown below:

[0110] (1)

[0111] Among them, e t S represents the degree of matching between the document to be classified and the text category matching graph t. (t) Let i represent the entity set in the text category matching graph t, where i represents S. (t) One of the entities, O (t) S represents (t) The set of entities excluding entity i, where j represents O (t) An entity in the list, dis(i,j) -1 This represents the reciprocal of the shortest distance between co-existing entities i and j in the document category matching graph t.

[0112] Optionally, a preset scoring table can also be obtained. This table records multiple document category scores, the number of co-existing entities corresponding to each document category score, and the distance between these co-existing entities on the corresponding document category knowledge graph. The server can determine the corresponding document category score from the preset scoring table based on the obtained number of co-existing entities and the calculated distances between them on the corresponding document category knowledge graph, thus obtaining the matching degree. For example, if the number of co-existing entities is 5 and the distance between them is 1, the preset scoring table determines the corresponding document category score to be 60, meaning the matching degree is 60%.

[0113] In this embodiment, the matching degree between the document to be classified and the corresponding document category knowledge graph is calculated by the number of co-entities and the distance between co-entities. This allows us to obtain the document category knowledge graph corresponding to the closest document category, further improving the accuracy of the document classification results.

[0114] In one embodiment, determining the classification result corresponding to the document to be classified based on the matching degree includes: selecting the document category knowledge graph with the highest matching degree, and determining the document category corresponding to the selected document category knowledge graph as the classification result corresponding to the document to be classified.

[0115] Specifically, the matching degree between the document to be classified and each document category knowledge graph is obtained and compared. The document category corresponding to the knowledge graph with the highest matching degree is selected as the classification result for the document to be classified. The higher the matching degree, the stronger the probability that the document to be classified belongs to the corresponding document category. When there are multiple highest matching degrees, the number of entities in the corresponding document category knowledge graph can be used to determine the classification result, and the document category corresponding to the knowledge graph with fewer entities can be selected as the classification result for the document to be classified.

[0116] In this embodiment, by selecting the document category corresponding to the knowledge graph of the document category with the highest matching degree as the classification result corresponding to the document to be classified, the classification result can be obtained quickly and accurately, and the reliability of the classification result is higher.

[0117] In another embodiment, such as Figure 5 As shown, a document classification method is provided, which may include the following steps:

[0118] Step 502: Obtain category sample data for multiple document categories.

[0119] Step 504: Extract key entities from the category sample data of each document category to obtain the key entities corresponding to each document category.

[0120] Step 506: Train the knowledge graph to be trained according to the key entities corresponding to each document category and the preset domain knowledge base until the training stopping condition is met, and obtain multiple document category knowledge graphs.

[0121] Step 508: Obtain the documents to be categorized.

[0122] Step 510: Obtain multiple document category knowledge graphs that have been pre-trained using category sample data.

[0123] Step 512: Perform word segmentation on the document to be classified to obtain a word segmentation list corresponding to the document to be classified.

[0124] Step 514: Match the word segmentation list with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0125] Step 516: Obtain the co-existing entities of the document to be classified and the knowledge graphs of each document category, as well as the relationship paths between the co-existing entities, from the document category matching graph.

[0126] Step 518: Calculate the distance of the co-existing entities on the corresponding document category knowledge graph based on the relationship paths between co-existing entities.

[0127] Step 520: Calculate the matching degree between the document to be classified and each document category knowledge graph based on the number of co-entities and the distance of the co-entities on the corresponding document category knowledge graph.

[0128] Step 522: Determine the classification result corresponding to the document to be classified based on the matching degree.

[0129] In this embodiment, since the document category knowledge graph is trained based on category sample data, an accurate document category knowledge graph can be obtained. Then, by matching the document to be classified with each document category knowledge graph, the matching degree between the document to be classified and each document category knowledge graph is calculated based on the obtained document category matching graph. The classification result corresponding to the document to be classified is then determined based on the matching degree. This eliminates the need to rely on human experience to pre-construct document features, greatly improving the accuracy of document classification. Furthermore, the category sample data is existing category data that can be directly obtained. Compared with traditional document classification methods based on deep learning algorithms, it does not require a large amount of correctly labeled data as a foundation, thus improving document classification accuracy while saving manpower and resources, thereby reducing the cost of document classification.

[0130] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0131] Based on the same inventive concept, this application also provides a document classification apparatus for implementing the document classification method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, specific limitations in one embodiment of the classification apparatus provided below can be found in the limitations of the document classification method described above, and will not be repeated here.

[0132] In one embodiment, such as Figure 6 As shown, a document classification device is provided, including: a document acquisition module 602, a graph acquisition module 604, a category matching module 606, a matching degree calculation module 608, and a document classification module 610, wherein:

[0133] The document acquisition module 602 is used to acquire documents to be categorized.

[0134] The graph acquisition module 604 is used to acquire multiple document category knowledge graphs that have been pre-trained using category sample data.

[0135] The category matching module 606 is used to match the document to be classified with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0136] The matching degree calculation module 608 calculates the matching degree between the document to be classified and the knowledge graph of each document category based on the document category matching graph.

[0137] The document classification module 610 is used to determine the classification result of the document to be classified based on the matching degree.

[0138] In one embodiment, the above-mentioned apparatus further includes:

[0139] The knowledge graph training module is used to acquire category sample data for multiple document categories; extract key entities from the category sample data of each document category to obtain the key entities corresponding to each document category; and train the knowledge graph to be trained according to the key entities corresponding to each document category and the preset domain knowledge base until the training stopping condition is met, so as to obtain multiple document category knowledge graphs.

[0140] In one embodiment, the category matching module 606 is further configured to perform word segmentation on the document to be classified to obtain a word segmentation list corresponding to the document to be classified; and match the word segmentation list with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category.

[0141] In one embodiment, the matching degree calculation module 608 is further configured to obtain the co-entities of the document to be classified and the knowledge graphs of each document category, and the relationship paths between the co-entities, in the document category matching graph.

[0142] In one embodiment, the matching degree calculation module 608 is further configured to calculate the distance between co-entities on the corresponding document category knowledge graph based on the relationship path between co-entities; and calculate the matching degree between the document to be classified and each document category knowledge graph based on the number of co-entities and the distance between co-entities on the corresponding document category knowledge graph.

[0143] In one embodiment, the document classification module 610 is further configured to select the document category knowledge graph with the highest matching degree, and determine the document category corresponding to the selected document category knowledge graph as the classification result corresponding to the document to be classified.

[0144] Each module in the aforementioned document classification device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0145] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores document category knowledge graphs, etc. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a document classification method.

[0146] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0147] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0148] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0149] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0150] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0151] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0152] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0153] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A document classification method, characterized in that, The method includes: Get the documents to be categorized; Obtain multiple document category knowledge graphs pre-trained using category sample data; The document to be classified is matched with the knowledge graphs of each document category to obtain a document category matching graph between the document to be classified and the knowledge graphs of each document category. The document category matching graph is used to obtain the co-entities of the document to be classified and each document category knowledge graph, as well as the relationship paths between the co-entities. The distance of each co-entity on the corresponding document category knowledge graph is calculated based on the relationship paths between the co-entities. The matching degree between the document to be classified and each document category knowledge graph is calculated based on the number of co-entities and the distance of each co-entity on the corresponding document category knowledge graph. Here, a co-entity refers to an entity that is successfully matched between the document to be classified and the document category knowledge graph, and a relationship path refers to the path corresponding to the direct relationship between co-entities. The classification result corresponding to the document to be classified is determined based on the matching degree; Prior to obtaining the documents to be categorized, the method further includes: Obtain category sample data for multiple document categories; Based on the length and layout of the category sample data for each document category, determine the entity extraction method, and extract key entities from the category sample data for each document category according to the corresponding entity extraction method to obtain the key entities corresponding to each document category. The extracted key entities are used as the core entities of the knowledge graph to be trained. The core entities corresponding to each document category are used as a keyword set. Relevant knowledge in the preset domain knowledge base is retrieved according to each keyword in the keyword set. Entities related to the core entities are retrieved in the relevant knowledge, and the relationships between the retrieved entities are determined. Based on the relationships between the retrieved entities, the retrieved entities are inserted into the corresponding knowledge graph to be trained. The retrieved entities are used as extended entities that are direct relationships of the key entities. The corresponding keyword set is updated using the extended entities, and a new round of retrieval is performed until the training stopping condition is met, resulting in a knowledge graph of multiple document categories. The step of determining the entity extraction method based on the length and layout of the category sample data for each document category includes: When the category sample data is a short text document, or when the category sample data is a fixed-format document, the entity extraction method is determined to be a manual extraction method. The manual extraction method includes manually selecting the document name, feature field value, feature field context, and the position of the feature field in the document. When the category sample data is a long text document, the entity extraction method is determined to be a combination of manual and model extraction.

2. The method according to claim 1, characterized in that, The extraction method combining manual and model extraction is a natural language pre-trained model.

3. The method according to claim 1, characterized in that, The step of matching the document to be classified with the knowledge graph of each document category includes: The document to be classified is segmented into words to obtain a word segmentation list corresponding to the document to be classified. The word segmentation list is matched with the knowledge graphs of each document category.

4. The method according to claim 3, characterized in that, The step of matching the document to be classified with the knowledge graphs of various document categories to obtain a document category matching graph between the document to be classified and the knowledge graphs of various document categories includes: When the keywords in the word segmentation list of the document to be classified are successfully matched with the entities in the document category knowledge graph, the successfully matched entities are used as entity nodes in the document category matching graph. Based on the relationships of the successfully matched entities in the corresponding document category knowledge graph, the relationships between the entity nodes in the document category matching graph are obtained. Based on the relationships between the entity nodes, a document category matching graph is obtained between the document to be classified and the knowledge graphs of each document category.

5. The method according to claim 1, characterized in that, Determining the classification result corresponding to the document to be classified based on the matching degree includes: The document category knowledge graph with the highest matching degree is selected, and the document category corresponding to the selected document category knowledge graph is determined as the classification result corresponding to the document to be classified.

6. A document classification device, characterized in that, The device includes: The document acquisition module is used to acquire documents to be categorized. The graph acquisition module is used to acquire multiple document category knowledge graphs that have been pre-trained using category sample data; The category matching module is used to match the document to be classified with the knowledge graphs of various document categories to obtain a document category matching graph between the document to be classified and the knowledge graphs of various document categories. The matching degree calculation module is used to obtain the co-entities of the document to be classified and each document category knowledge graph, and the relationship paths between the co-entities, from the document category matching graph; calculate the distance of each co-entity on the corresponding document category knowledge graph based on the relationship paths between the co-entities; and calculate the matching degree between the document to be classified and each document category knowledge graph based on the number of co-entities and the distance of each co-entity on the corresponding document category knowledge graph. Here, a co-entity refers to an entity that is successfully matched between the document to be classified and the document category knowledge graph, and a relationship path refers to the path corresponding to the direct relationship between co-entities. The document classification module is used to determine the classification result corresponding to the document to be classified based on the matching degree. The document acquisition module is also used for: Obtain category sample data for multiple document categories; Based on the length and layout of the category sample data for each document category, determine the entity extraction method, and extract key entities from the category sample data for each document category according to the corresponding entity extraction method to obtain the key entities corresponding to each document category. The extracted key entities are used as the core entities of the knowledge graph to be trained. The core entities corresponding to each document category are used as a keyword set. Relevant knowledge in the preset domain knowledge base is retrieved according to each keyword in the keyword set. Entities related to the core entities are retrieved in the relevant knowledge, and the relationships between the retrieved entities are determined. Based on the relationships between the retrieved entities, the retrieved entities are inserted into the corresponding knowledge graph to be trained. The retrieved entities are used as extended entities that are direct relationships of the key entities. The corresponding keyword set is updated using the extended entities, and a new round of retrieval is performed until the training stopping condition is met, resulting in a knowledge graph of multiple document categories. The step of determining the entity extraction method based on the length and layout of the category sample data for each document category includes: When the category sample data is a short text document, or when the category sample data is a fixed-format document, the entity extraction method is determined to be a manual extraction method. The manual extraction method includes manually selecting the document name, feature field value, feature field context, and the position of the feature field in the document. When the category sample data is a long text document, the entity extraction method is determined to be a combination of manual and model extraction.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.