A document label determination method and device, electronic equipment and storage medium

By using an automated document tagging method and keyword recognition and extraction technology, the problem of slow manual tagging has been solved, improving the efficiency and accuracy of document query and recommendation services.

CN114706938BActive Publication Date: 2026-04-14BEIJING XUEZHITU NETWORK TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-28
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, manual tagging is slow and inefficient, making it difficult to improve the accuracy of document retrieval and recommendation services.

Method used

By acquiring keywords from documents to be tagged, tag identification is performed using a tag dictionary and target graph database. If this fails, tag extraction is performed, and temporary tags are determined by combining new word and topic extraction models. Finally, official tags are set according to the determination instructions.

Benefits of technology

It achieves high efficiency and accuracy in automatically determining document tags, improving the efficiency and accuracy of query and recommendation services, and enhancing the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114706938B_ABST
    Figure CN114706938B_ABST
Patent Text Reader

Abstract

The application relates to a document label determination method and device, electronic equipment and a storage medium. The method comprises the following steps: obtaining a keyword of a document to be determined, performing label identification on the document to be determined through the keyword, and determining the keyword according to text content and / or associated information of the document to be determined; when the label identification on the document to be determined through the keyword fails, extracting a label from the document to be determined to extract a temporary label corresponding to the document to be determined; and according to a determination instruction, taking at least one label in the temporary label as a formal label of the document to be determined. First, the label of the document to be determined is identified, then the label is extracted when the identification fails, and finally, the formal label of the document to be determined is determined according to the determination instruction, that is, the label of the document to be determined is automatically determined through multiple methods. Compared with manual label determination, the speed of determining the label is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly to a method, apparatus, electronic device, and storage medium for determining document tags. Background Technology

[0002] With the deepening development of the internet and mobile internet, and the rise and rapid development of knowledge engineering and artificial intelligence, text data has experienced explosive growth. Simultaneously, many enterprises possess vast amounts of document text data, such as highly specialized documents like business contracts, product manuals, solutions, and deployment and installation documents. To facilitate unified management and easier retrieval of required document data, it's necessary to centrally manage this document data and provide intelligent services such as querying and recommendation. While document names or titles are typically used to represent documents, the information in these names or titles is limited; many important documents are not reflected in them or are only partially represented, complicating the accuracy of query and recommendation services. Tagging documents allows for document labeling, making query and recommendation services more intelligent, improving accuracy, and ultimately increasing query efficiency. Currently, manual tagging of documents is slow and inefficient.

[0003] Therefore, determining the tags for a document has become an urgent problem to be solved. Summary of the Invention

[0004] This application provides a document tag determination method, apparatus, electronic device, and storage medium to solve the problems of slow speed and low efficiency in manual tagging in related technologies.

[0005] In a first aspect, this application provides a document tag determination method, the document tag determination method comprising: obtaining keywords of a document to be tagged; performing tag recognition on the document to be tagged using the keywords, wherein the keywords are determined based on the text content and / or related information of the document to be tagged; when tag recognition of the document using the keywords fails, performing tag extraction on the document to be tagged to extract temporary tags corresponding to the document to be tagged; and, according to a determination instruction, using at least one tag from the temporary tags as the official tag of the document to be tagged.

[0006] Optionally, obtaining keywords of the document to be tagged, and performing tag recognition on the document using the keywords, includes: obtaining the document content of the document to be tagged; segmenting the document content into words to obtain high-frequency words in the document content; using the high-frequency words as the keywords; searching for tags corresponding to the keywords in a tag dictionary, wherein the tag dictionary has a mapping relationship between keywords and tags; and determining that tag recognition of the document using the keywords has failed when no tag corresponding to the keywords is found in the tag dictionary.

[0007] Optionally, obtaining keywords of the document to be tagged, and performing tag recognition on the document using the keywords, includes: obtaining the associated information of the document to be tagged, the associated information including: document author information, document uploader information, and document downloader information, and using the associated information as the keywords; searching for target information corresponding to the associated information in a target graph database based on the keywords, the target information including: industry information and / or field information; when no target information corresponding to the associated information is found in the target graph database, it is determined that tag recognition of the document using the keywords has failed.

[0008] Optionally, tag extraction is performed on the document to be tagged to extract temporary tags corresponding to the document, including: obtaining the document content of the document to be tagged; identifying new words in the document content to determine a new word set for the document to be tagged, the new word set including multiple new words; extracting topics from the document to be tagged using a topic extraction model to determine a topic set for the document to be tagged, the topic set including multiple topics; determining the intersection of the new word set and the topic set; and determining the temporary tags corresponding to the document to be tagged based on the intersection of the new word set and the topic set.

[0009] Optionally, determining the temporary tag corresponding to the document to be tagged based on the intersection of the new vocabulary set and the topic set includes: when the intersection of the new vocabulary set and the topic set is not empty, using the words from the intersection of the new vocabulary set and the topic set as temporary tags for the document to be tagged.

[0010] Optionally, determining the temporary tag corresponding to the document to be tagged based on the intersection of the new word set and the topic set includes: when the intersection of the new word set and the topic set is empty, obtaining the target words corresponding to each topic in the topic set; and using the target words corresponding to each topic as the temporary tag of the document to be tagged.

[0011] Optionally, determining at least one of the temporary tags as the official tag of the document to be tagged according to the determining instruction includes: displaying the determined temporary tag on an interactive interface; receiving the determining instruction for determining the official tag; determining at least one of the temporary tags as the official tag of the document to be tagged according to the determining instruction; after determining at least one of the temporary tags as the official tag of the document to be tagged according to the determining instruction, the method further includes: adding the official tag and words related to the official tag to a tag dictionary.

[0012] Secondly, this application provides a document tag determining device, comprising: a tag recognition module, configured to acquire keywords of a document to be tagged, and to perform tag recognition on the document to be tagged using the keywords, wherein the keywords are determined based on the text content and / or related information of the document to be tagged; a tag extraction module, configured to extract tags from the document to be tagged when tag recognition of the document using the keywords fails, thereby extracting temporary tags corresponding to the document to be tagged; and a tag determining module, configured to use at least one of the temporary tags as the official tag of the document to be tagged according to a determining instruction.

[0013] Thirdly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0014] Memory, used to store computer programs;

[0015] When a processor executes a program stored in memory, it implements the steps of the document tag determination method according to any embodiment of the first aspect.

[0016] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the document tag determination method as described in any embodiment of the first aspect.

[0017] The technical solutions provided in this application have the following advantages compared with the prior art:

[0018] This solution can be applied to knowledge-enhanced retrieval in the field of information retrieval technology. The method provided in this application includes: obtaining keywords of a document to be tagged; performing tag recognition on the document to be tagged using the keywords, wherein the keywords are determined based on the text content and / or related information of the document to be tagged; when tag recognition of the document using the keywords fails, extracting tags from the document to be tagged to extract temporary tags corresponding to the document to be tagged; and using at least one tag from the temporary tags as the official tag of the document to be tagged according to a determination instruction. Specifically, tag recognition is performed on the tags to be tagged first, tag extraction is performed when the recognition fails, and finally, the official tag of the document to be tagged is determined according to the determination instruction. This means that the tags of the document to be tagged are automatically determined using multiple methods, avoiding the slow and inefficient manual tagging of the document to be tagged, thus improving the efficiency of tag determination. Furthermore, using multiple methods to determine the tags of the document to be tagged improves the accuracy of tag determination, thereby enhancing the user experience. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A flowchart illustrating a document tag determination method provided in an embodiment of this application;

[0022] Figure 2 A schematic diagram of the basic structure of a document tag determining device provided in an embodiment of this application;

[0023] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0025] Figure 1 This is a flowchart illustrating a document tag determination method provided in an embodiment of this application, such as... Figure 1 As shown, the document tag determination method includes, but is not limited to:

[0026] S101. Obtain keywords of the document to be tagged, and perform tag recognition on the document to be tagged using the keywords. The keywords are determined based on the text content and / or related information of the document to be tagged.

[0027] S102. When tag recognition of the document by the keyword fails, tag extraction is performed on the document whose tag is to be determined, so as to extract the temporary tag corresponding to the document whose tag is to be determined.

[0028] S103. According to the determination instruction, at least one of the temporary tags is used as the official tag of the document to be determined.

[0029] It should be understood that the document tag determination method provided in this embodiment can be applied to a terminal and / or a server. That is, each step in the document tag determination method can be executed by the terminal or the server alone, or it can be completed by a combination of the terminal and the server. The terminal can be implemented in various forms. For example, the terminal described in this invention may include mobile terminals such as mobile phones, tablets, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, etc., as well as fixed terminals such as digital TVs and desktop computers. The following description will use the example of a server executing the document tag determination method alone.

[0030] It should be understood that before obtaining the keywords of the tag document to be determined, the method further includes: obtaining the tag document to be determined; wherein, the methods of obtaining the tag document to be determined include, but are not limited to: receiving input instructions through an interactive interface, the input instructions being used to determine the tag document to be determined; or, obtaining the tag document to be determined transmitted by relevant personnel through any transmission method, wherein the transmission method includes, but is not limited to, at least one of: wireless network, wired network, storage medium, near field communication, for example, obtaining the tag document to be determined from the Internet through a wireless network.

[0031] In some examples of this embodiment, obtaining keywords of a document to be tagged and performing tag recognition on the document using the keywords includes: obtaining the document content of the document to be tagged; segmenting the document content into words to obtain high-frequency words in the document content; using the high-frequency words as the keywords; searching for tags corresponding to the keywords in a tag dictionary, where a mapping relationship between keywords and tags is set; and determining that tag recognition of the document using the keywords has failed when no tag corresponding to the keywords is found in the tag dictionary. It should be understood that after obtaining the documents to be tagged, a tag dictionary also needs to be obtained. After obtaining the tag dictionary, an inverted index is built on the obtained tag dictionary system. That is, the mapping of tag categories to keywords is converted into a mapping of keywords to tag categories. Each keyword corresponds to one or more document tags. The resulting inverted index structure is as follows: "keyword1": "document tag1", "document tag2", for example: the tags corresponding to the keyword {product introduction} are: platform introduction, system introduction, product document, product description, product introduction, product capability introduction, product function introduction, product manual, product specification, product white paper, etc. It can be understood that the purpose of building an inverted index is to speed up matching and retrieval, and to quickly find document tag examples based on keywords.

[0032] Continuing the previous example, the document content of the document to be tagged is obtained, and the document content is segmented to obtain high-frequency words, which are then used as keywords. Obtaining the document content of the document to be tagged includes, but is not limited to, obtaining the content of all documents of the document to be tagged, obtaining the content of the first page of the document to be tagged, obtaining the content of the last page of the document to be tagged, and obtaining the content of at least one of the following: obtaining the content of all documents of the document to be tagged, obtaining the content of the first page of the document to be tagged, obtaining the content of the last page of the document to be tagged, and obtaining the content of all documents of the document to be tagged except the first and last pages. It is understood that after obtaining the document to be tagged, the content information of the document to be tagged is processed by page number and content per page. In some examples, the content of the first page can summarize the entire text, so only the content of the first page of the document to be tagged can be obtained to obtain high-frequency words. If the first page is a table of contents, the table of contents pages need to be filtered, and only content not from the first page of the table of contents needs to be selected.

[0033] Understandably, taking the homepage content of a document with tags to be determined as an example, the homepage content is first segmented into sentences using '?','?','。','!','!',';',';',',',',','\n'. Then, a word segmentation tool is used to segment each sentence. After segmentation, a stop word dictionary is used for filtering, and word frequency statistics are performed. The words are sorted from highest to lowest frequency, and words with a frequency exceeding a threshold are considered high-frequency words. For example, words with a frequency in the top 20% are considered high-frequency words. It should be understood that the above threshold can also be determined based on the size of the document content to be tagged. Specifically, for example, taking the content of the first page of the document to be tagged as an example, and setting the document threshold to 50 characters, firstly, it is determined whether the number of characters in the first page content is greater than the threshold. If it is greater than the threshold, the top N words with the sorted word frequencies are taken as high-frequency words, and N can be flexibly configured according to the scenario requirements. If it is less than the threshold, the top M words with the sorted word frequencies are taken as high-frequency words, and M can also be flexibly configured according to the scenario requirements, where M is less than N. In some examples, if the number of characters in the first page content is greater than the threshold, but the number of words obtained is less than N, the top M words are taken according to word frequency. Finally, based on the selected top N or M keywords, a matching search is performed in the tag dictionary of the inverted index established above. It is understood that this embodiment does not restrict the sentence segmentation method, which can be flexibly determined by relevant personnel. At the same time, this embodiment does not restrict the word segmentation method, which can be flexibly set by relevant personnel. For example, the word segmentation toolkit jieba can be used for word segmentation. jieba is a Chinese word segmentation library for Python, which has the characteristics of high performance, accuracy, and scalability.

[0034] Continuing with the previous example, when searching for a tag corresponding to the keyword in the tag dictionary, if the keyword exists in the tag dictionary and corresponds to at least one tag, it is determined that the tag corresponding to the keyword has been found in the tag dictionary, and the tag recognition of the document using the keyword is successful; if the keyword does not exist in the tag dictionary, or the keyword does not have a corresponding tag, it is determined that the tag corresponding to the keyword has not been found in the tag dictionary, and the tag recognition of the document using the keyword has failed.

[0035] In some examples of this embodiment, obtaining keywords for a document to be tagged and then performing tag recognition on the document using these keywords includes: obtaining the associated information of the document to be tagged, the associated information including: document author information, document uploader information, and document downloader information; using the associated information as the keywords; searching for target information corresponding to the associated information in a target graph database based on the keywords, the target information including: industry information and / or field information; and determining that tag recognition of the document using the keywords has failed when no target information corresponding to the associated information is found in the target graph database. It is understood that the target graph database is an enterprise graph database, which allows viewing the tags and attribute information of the personnel corresponding to the associated information.

[0036] It should be understood that after obtaining the document to be tagged, the document is stored in a pre-defined search engine. This search engine contains all uploaded documents, as well as the filename, title, content, page number, author, uploader, download count, and downloader information for each document. That is, the search engine can directly obtain the document's {document author information, document uploader information, document downloader information}, and then at least one of the following steps is performed:

[0037] Use the document author information to search for the author's industry information tags or other tags in the target graph database;

[0038] Use the document uploader information to search the target graph database for industry information tags or other tags belonging to the uploader;

[0039] Use the document downloader information to search the target graph database for industry information tags or other tags belonging to the downloader;

[0040] Continuing the previous example, if the search is successful, the document is tagged with relevant industry information tags or other tags found. In some examples, besides directly using the document downloader information to search the target graph database for the downloader's industry information tags or other tags, a threshold can be set for the number of document downloads. Only when the number of downloads exceeds the threshold is the downloader's information used to search the enterprise graph database for the downloader's industry information and other key information. If the search is successful, the document is tagged with the downloader's industry tag and other key tags, and the document tag information is updated.

[0041] It is understood that this embodiment does not limit the search engine used. In some examples, the Elasticsearch search engine can be used, which includes all uploaded documents, as well as the file name, title, content, page number, author, uploader, download count, and downloader information for each document.

[0042] It should be understood that, as described above, obtaining keywords of a document to be tagged and performing tag recognition on the document using these keywords includes at least two methods. The first method involves: obtaining the document content of the document to be tagged, segmenting the document content into words to obtain high-frequency words, and using these high-frequency words as keywords; searching for tags corresponding to the keywords in a tag dictionary, where a mapping relationship between keywords and tags is established; and determining that tag recognition of the document using the keywords has failed when no tag corresponding to the keywords is found in the tag dictionary. The second method involves: obtaining the associated information of the document to be tagged, including document author information, document uploader information, and document downloader information, and using this associated information as keywords; searching for target information corresponding to the associated information in a target graph database based on the keywords, where the target information includes industry information and / or field information; and determining that tag recognition of the document using the keywords has failed when no target information corresponding to the associated information is found in the target graph database. It is understandable that the two label recognition methods mentioned above can be implemented individually or together, and the order of implementation is not important.

[0043] It can be understood that when the corresponding tags cannot be assigned to the document by means of tag recognition, it means that the document tag dictionary system does not cover all documents or the document is a relatively cutting-edge or new type of document. At this time, tag extraction needs to be performed to obtain the tags of the document. In some examples of this embodiment, tag extraction is performed on the document with undetermined tags to extract the temporary tags corresponding to the document with undetermined tags, including: obtaining the document content of the document with undetermined tags, performing new word recognition on the document content to determine the new word set of the document with undetermined tags, where the new word set includes multiple new words; performing topic extraction on the document with undetermined tags through a topic extraction model to determine the topic set of the document with undetermined tags, where the topic set includes multiple topics; determining the intersection of the new word set and the topic set, and determining the temporary tags corresponding to the document with undetermined tags according to the intersection of the new word set and the topic set.

[0044] Among them, in the step of obtaining the document content of the document with undetermined tags and performing new word recognition on the document content to determine the new word set of the document with undetermined tags, this example does not limit the new word recognition method, which can be flexibly set by relevant personnel. For example, an unsupervised learning algorithm based on statistics can be used to enumerate all possible new words based on the content of the document with undetermined tags and filter them with degrees of freedom and coagulation to obtain the new word set.

[0045] Continuing with the above example, specifically, if the N-Gram algorithm is used for new word recognition, the N-Gram algorithm is an algorithm based on a statistical language model. N-Gram is based on an assumption: the nth word appears related to the previous n - 1 words and not related to any other words. If we have a sequence T (or a sentence) consisting of m words, and the word sequence is w1, w2, w3...wm, then the N-Gram language model formula is:

[0046] p(T) = p(w1, w2, w3,..., wm) = p(w1) * p(w2|w1) * p(w3|w1w2) * p(wn|w1w2w3...) Using the assumption in the Markov chain, that is, the current word is only related to the previous few limited words.

[0047] When n = 2, it is a bigram model, that is

[0048]

[0049] For example, in Chinese: How's the weather today?, its bigrams are in turn:

[0050] Today, Tian Tian, Weather, Qi Hao, Hao Ma

[0051] Extract consecutive word combinations from the content of the document with undetermined tags. These word combinations contain at most N words, and the frequency of each word combination is counted.

[0052] Then, cohesion is calculated. Cohesion is the degree of closeness between characters in a word segment. Based on the word frequency statistics above, the cohesion of adjacent characters can be calculated. For example, the cohesion of a three-character string is:

[0053]

[0054] Where P(abc) represents the probability of all three characters appearing together, P(ab) and P(bc) represent the probability of two characters appearing together, and P(a) and P(c) represent the probability of a single character appearing alone. In other words, it enumerates all possible ways to slice the character.

[0055] Set a minimum threshold for solidification; only fragments with a solidification degree greater than the threshold can form a set M.

[0056] Finally, the left and right information entropy are calculated; the higher the left and right information entropy, the greater the probability of forming a word. The formula for calculating information entropy is as follows:

[0057]

[0058] In this formula, w is a random variable representing either the left or right word, A is the set of all deduplicated left (right) words, and P(w) is the probability distribution of the left (right) word. The random variable W is the left word when calculating the left entropy and the right word when calculating the right entropy. The left and right entropies are calculated separately, and the minimum value between the left and right entropies is taken.

[0059] Set a threshold for the left and right entropy. When the minimum value is greater than the threshold, select a set of new words R that meet the threshold from the candidate new words M.

[0060] In the step of extracting topics from the documents to be tagged using a topic extraction model to determine the topic set of the documents to be tagged, this example does not limit the topic extraction model used and can be flexibly set by relevant personnel.

[0061] Continuing the previous example, for instance, using the LDA (Local Theory of Derivatives) subject extraction model, the LDA model can provide the topic of each document in the document set to be tagged in the form of a probability distribution. After analyzing some documents to be tagged and extracting their topics, documents can be tagged according to the topics. We can use generative models to view these two things: documents and topics. A generative model is one where each word in an article is obtained through a process of "selecting a certain topic with a certain probability, and selecting a certain document from that topic with a certain probability." Therefore, if we want to generate a document, the probability of each word appearing in it is:

[0062]

[0063] Where P(word|document) represents the word frequency of each word in each document to be tagged, i.e., the probability of its occurrence; P(word|topic) represents the probability of each word in each topic; and P(topic|document) represents the probability of each topic in each document to be tagged.

[0064] In the LDA model, a document with undetermined labels is generated as follows:

[0065] Generate the topic distribution of the document i to be labeled by sampling from the Dirichlet distribution;

[0066] Generate the topic of the j-th word in document i to be tagged by sampling from the multinomial distribution of the topics;

[0067] Generate word distributions corresponding to topics by sampling from the Dirichlet distribution;

[0068] Words are ultimately generated by sampling from the multinomial distribution of words;

[0069] Understandably, when using the open-source library gensim for topic modeling, it's necessary to set the number of topics. A threshold for the size of the document to be tagged needs to be set. When the number of characters in the document exceeds the threshold, the number of topics can be set larger, for example, 10; when the number of characters is less than the threshold, the number of topics can be set smaller, for example, 3. You can also set the number of top-ranking keywords for each topic; here, we uniformly set it to 10. This results in a topic set containing multiple topics.

[0070] For example: Topic 0

[0071] [('system',0.07887071),

[0072] ('human', 0.056233782)

[0073] ('interface', 0.0562044),

[0074] ('eps', 0.05613238),

[0075] ('trees', 0.05582566),

[0076] ('generation', 0.03381113),

[0077] ('random', 0.033807028),

[0078] ('unordered', 0.033805348)

[0079] ('computer', 0.03380298)

[0080] ('binary', 0.033802323)).

[0081] In some examples of this embodiment, determining the temporary tag corresponding to the document to be tagged based on the intersection of the new vocabulary set and the topic set includes: when the intersection of the new vocabulary set and the topic set is not empty, using the words from the intersection of the new vocabulary set and the topic set as the temporary tag of the document to be tagged. In some examples of this embodiment, determining the temporary tag corresponding to the document to be tagged based on the intersection of the new vocabulary set and the topic set includes: when the intersection of the new vocabulary set and the topic set is empty, obtaining the target words corresponding to each topic in the topic set; and using the target words corresponding to each topic as the temporary tag of the document to be tagged.

[0082] Continuing the previous example, we obtain the words contained in the new vocabulary set and the topic set respectively, and take the intersection of the two (i.e., words contained in both the new vocabulary set and the topic set). This intersection can be used as a temporary tag for the document whose tag is to be determined. If there is a case where the intersection is empty, then the first three topics of each topic set are taken as temporary tags.

[0083] In some examples of this embodiment, determining at least one of the temporary tags as the official tags of the document to be tagged according to a determination instruction includes: displaying the determined temporary tags on an interactive interface; receiving the determination instruction for determining the official tags, and determining at least one of the temporary tags as the official tags of the document to be tagged according to the determination instruction; then displaying the determined temporary tags through an interactive interface so that relevant personnel are aware of the temporary tags, and then receiving a determination instruction from relevant personnel to determine at least one or more temporary tags as the official tags of the document.

[0084] In some examples of this embodiment, after determining at least one of the temporary tags as the official tag of the document to be tagged according to the determination instruction, the method further includes: adding the official tag and words associated with the official tag to a tag dictionary.

[0085] The method provided in this embodiment includes: obtaining keywords of a document to be tagged; performing tag recognition on the document to be tagged using the keywords, wherein the keywords are determined based on the text content and / or related information of the document to be tagged; when tag recognition of the document using the keywords fails, extracting tags from the document to be tagged to extract temporary tags corresponding to the document to be tagged; and using at least one tag from the temporary tags as the official tag of the document to be tagged according to a determination instruction. This method first performs tag recognition on the tags to be tagged, extracts tags when recognition fails, and finally determines the official tag of the document to be tagged according to a determination instruction. In other words, it automatically determines the tags of the document to be tagged using multiple methods, avoiding the slow and inefficient manual tagging of the document to be tagged, thus improving the efficiency of tag determination. Furthermore, using multiple methods to determine the tags of the document to be tagged improves the accuracy of tag determination, thereby enhancing the user experience.

[0086] To better understand the present invention, this embodiment provides a more specific example to illustrate the invention, which includes the following steps:

[0087] Step 1: Data Preparation

[0088] 1) Obtain the tag dictionary, which includes tags and their corresponding keywords. For example: Product introduction: platform introduction, system introduction, product documentation, product description, product overview, product capability introduction, product function introduction, product manual, product specifications, product white paper.

[0089] 2) The word segmentation toolkit jieba is a Chinese word segmentation library for Python, characterized by high performance, accuracy, and scalability.

[0090] 3) The Elasticsearch search engine stores all uploaded documents, including information such as document filename, title, content, page number, uploader, download count, and downloaders.

[0091] 4) Redis database, used to cache tag dictionaries and document-related information.

[0092] 5) Enterprise graph database, which allows you to view the tags and attribute information of individuals.

[0093] 6) Gensim, a Python library for automatically extracting semantic topics from documents, can handle raw, unstructured numeric text (plain text).

[0094] 7) The latest stop word dictionary.

[0095] Step 2, Method Implementation

[0096] Method flow: First, the word segmentation tool loads the tag dictionary, reads the title, content and other field information of the uploaded document with the tags to be determined from Elasticsearch (search server), uses the word segmentation tool to segment the title and content, and extracts different high-frequency words according to the file size.

[0097] An inverted index is built for the tag dictionary. High-frequency words are searched in the inverted index to determine the tags corresponding to the documents with the tags to be determined.

[0098] Based on the uploader, downloader, and other information of the uploaded document retrieved from Elasticsearch, determine the tag to which the document to be tagged belongs.

[0099] If it is not possible to tag the document to be tagged using word segmentation or relevant fields in Elasticsearch, then it is necessary to extract new tags based on the new word discovery algorithm and topic discovery algorithm, and receive confirmation instructions to tag the document to be tagged and add it to the tag dictionary system.

[0100] Step 2.1: Obtain the tag dictionary and use it as the custom word segmentation dictionary for the word segmentation tool.

[0101] Retrieve the tag dictionary from Elasticsearch and organize it into a list. The list should include not only the keywords corresponding to the tags, but also the tags themselves.

[0102] Tags can be flexibly customized. For a document with tags to be determined, if a certain type of tag is missing, it can be added through a configuration file; if existing tags are outdated or incorrect, they can be deleted or modified through the configuration file. Therefore, each time the tag dictionary is retrieved from Elasticsearch and processed into a list, it must be compared with the previous tag dictionary list to obtain changes in the tag dictionary compared to the previous one, including whether any tags or keywords have been added, deleted, or modified.

[0103] The word segmentation tool jieba can directly load new words into its word segmentation dictionary, but for all loaded new words to be effective, the word frequency of the new words must be set to a relatively large number; here, it is set to 10. 7 When the word segmentation tool initially loads the tag dictionary, it loads the entire dictionary. Subsequent times, it only needs to load the newly added, modified, or deleted tag dictionaries. This avoids loading the entire dictionary every time; it only loads, deletes, or modifies the changed tags, which speeds up processing and improves the overall tagging performance of documents with undetermined tags.

[0104] Step 2.2: Obtain the tag dictionary and build an inverted index.

[0105] Retrieve the tag dictionary from Elasticsearch and build an inverted index on it. This involves converting the mapping from tag categories to keywords into a mapping from keywords to tags, where each keyword corresponds to one or more document tags. The resulting inverted index structure is as follows:

[0106] "Keyword 1": "Document Tag 1", "Document Tag 2"...

[0107] The purpose of building an inverted index is to speed up matching and retrieval, enabling the rapid finding of document tags.

[0108] Step 2.3 Obtain document title and content information

[0109] Obtain the title and content information of the document with the desired tags. Process the content information by page number and page content to obtain the first page content, which usually summarizes the entire document. If the first page is a table of contents, filter the table of contents pages to select only content that is not the first page of the table of contents.

[0110] The configuration file allows for flexible configuration of the content to be processed, including: processing all document content, processing the first page content, processing the last page content, or processing both the first and last page content. The default setting is to process the first page content.

[0111] The homepage content is segmented into sentences using '?','?','。','!','!',';',';',',',',','\n'. The word segmentation tool after loading the dictionary in step 2.1 is used for word segmentation. This means first using a tag dictionary for word segmentation, then using the word segmentation tool. After segmentation, a stop word dictionary is used for filtering, and word frequency statistics are performed, sorting the words by frequency from highest to lowest.

[0112] Set a document content size threshold of 50 characters. Determine if the first page content of the document containing the tag to be determined has more than 50 characters. If it does, select the top N words by frequency of sorted terms. N can be flexibly configured according to the scenario requirements. If it is less than the threshold, select the top M words by frequency of sorted terms. M can also be flexibly configured according to the scenario requirements. If the content is greater than the threshold, but the maximum frequency of a word is less than N, select the top M words by frequency of sorted terms.

[0113] Based on the selected first N or M words, a matching search is performed in the inverted index established in step 2.2 to find the document tags corresponding to the keywords.

[0114] Step 2.4 Process the document association information of the tags to be determined

[0115] Upload a document with undetermined tags. Parse the document, including extracting the author, uploader, title, and content. Store all relevant information in Elasticsearch. Retrieve the author, uploader, and downloader information from Elasticsearch. Use the author and uploader information to search the enterprise graph database for the author's industry information and other key information. If the search is successful, tag the document with relevant industry information or other category tags.

[0116] A threshold is set for the number of downloads. When the number of downloads of a document to be tagged exceeds the threshold, the downloader's information is used to search the enterprise graph database for the downloader's industry information and other key information. If the search is successful, the document to be tagged is labeled with the downloader's industry and other key tags, and the document's tag information is updated.

[0117] Step 2.5 New Word Discovery

[0118] When a document cannot be tagged using the tag dictionary and the association information between the document and the tag, it indicates that the document tag dictionary does not cover all documents or that the document is a relatively new or cutting-edge document. In this case, it is necessary to discover new words to serve as tags for the document, thereby expanding the document tag system dictionary.

[0119] This paper employs a statistical unsupervised learning algorithm, which enumerates all possible new words based on the content of the document with the label to be determined, and filters them using degrees of freedom and cohesion.

[0120] Step 2.5.1 Obtain word frequency:

[0121] This example uses the N-GRAM algorithm to obtain word frequencies, where N-GRAM is an algorithm based on a statistical language model.

[0122] N-Gram is based on the assumption that the occurrence of the nth word is related to the preceding n-1 words, but unrelated to any other words. If we have a sequence T (or a sentence) of m words, with the word sequence w1, w2, w3... wm, then N-Gram grammars...

[0123] The formula for the speech model is:

[0124] p(T)=p(w1,w2,w3,...,wm)=p(w1)*p(w2|w1)*p(w3|w1w2)*p(wn|w1w2w3...) utilizes the assumption in Markov chains that the current word is only related to a limited number of preceding words.

[0125] When n = 2, it is a bigram model, that is

[0126]

[0127] For example, in Chinese: How's the weather today?, its bigrams are successively:

[0128] Today, every day, weather, good weather, okay

[0129] Extract consecutive character combination fragments from the content of the document with undetermined tags. These character combination fragments contain at most N characters, and at the same time, count the frequency of each character combination.

[0130] Step 2.5.2 Cohesion calculation

[0131] Cohesion is the degree of tightness between characters in a character combination fragment. With the above word frequency statistics, the cohesion of adjacent characters can be calculated. For example: the cohesion of a three-character string is:

[0132]

[0133] Among them, P(abc) represents the probability that three characters appear together, P(ab) and P(bc) represent the probability that two characters appear together, and P(a) and P(c) represent the probability that a single character appears alone. That is, enumerate all possible segmentation methods.

[0134] Set the minimum threshold of cohesion. Only the fragments greater than the threshold can form a set M.

[0135] Step 2.5.3 Left and right entropy

[0136] The greater the left and right entropy, the greater the possibility of forming a word. The calculation formula of information entropy is as follows:

[0137]

[0138] In this formula, w is a random variable representing the left word or the right word, A is the set of all left words (right words) after removing duplicates, and P(w) is the probability distribution of this left word (right word). The random variable W is the left word when calculating the left entropy and the right word when calculating the right entropy. Calculate the left and right entropy respectively, and take the minimum value of the left and right information entropy.

[0139] Set a threshold for the left and right entropy. When the minimum value is greater than the threshold, screen out the new word set R that meets the threshold from the alternative new words M.

[0140] Step 2.6 Topic set acquisition

[0141] This example uses LDA (Local Theory Analysis) to obtain a topic set. LDA is a topic model that provides a probability distribution of the topic of each document in a document set to be tagged. By analyzing some documents to extract their topics, documents can be tagged based on those topics. We can view the process of determining tagged documents and topics using a generative model. A generative model means that each word in an article is obtained through a process of "selecting a certain topic with a certain probability, and selecting a document from that topic with a certain probability." Therefore, if we want to generate a document, the probability of each word appearing in it is:

[0142]

[0143] Where P(word|document) represents the word frequency of each word in each document to be tagged, i.e., the probability of its occurrence; P(word|topic) represents the probability of each word in each topic; and P(topic|document) represents the probability of each topic in each document to be tagged.

[0144] In the LDA model, a document is generated in the following way:

[0145] Generate the topic distribution of document i with undetermined tags by sampling from the Dirichlet distribution.

[0146] Generate the topic of the j-th word in document i to be tagged by sampling from the multinomial distribution of the topics.

[0147] Generate word distributions corresponding to topics by sampling from the Dirichlet distribution.

[0148] Words are ultimately generated by sampling from the multinomial distribution of words.

[0149] When using the open-source library gensim for topic modeling, you need to set the number of topics. You also need to set a threshold for the document size to be tagged. When the number of characters in the document exceeds the threshold, the number of topics can be set larger, for example, 10. When the number of characters in the document to be tagged is less than the threshold, the number of topics can be set smaller, for example, 3. You can also set the number of top-ranking keywords for each topic; here, we uniformly set it to 10.

[0150] For example: Topic 0

[0151] [('system',0.07887071),

[0152] ('human', 0.056233782)

[0153] ('interface', 0.0562044),

[0154] ('eps', 0.05613238),

[0155] ('trees', 0.05582566),

[0156] ('generation', 0.03381113),

[0157] ('random', 0.033807028),

[0158] ('unordered', 0.033805348)

[0159] ('computer', 0.03380298)

[0160] ('binary', 0.033802323)]

[0161] Step 2.2.7: Tag Extraction and Confirmation

[0162] Based on the new word set extracted in step 2.5 and the topic set extracted in step 2.6, the intersection of the two is taken. This intersection can be used as temporary tags for the document. If the intersection is empty, the first three words of each topic are taken as temporary tags. These temporary tags are displayed on the front end and, after manual verification, become the official tags for the document and are written into the Elasticsearch tag dictionary system. In one approach, the official tags are used as keywords, and other temporary tags are written into the Elasticsearch tag dictionary system as tag documents. The official tags are written into the tag dictionary with the key being the official tag and the keyword being the set of all official tags. For example, there are two official tags:

[0163] Product introductions and installation manuals should use the name Elasticsearch.

[0164] There are two pieces of information: 1. Document tag: Product introduction, keywords: Product introduction, Installation manual. 2. Document tag: Installation manual, keywords: Product introduction, Installation manual.

[0165] The document tagging method provided in this embodiment fully utilizes a tag dictionary and automatic tag expansion to tag documents. First, the entire content of the document to be tagged is obtained. Then, keywords from the tag dictionary are used to match fields related to the document content. If a match is successful, the tag corresponding to the tag keyword becomes the tag for the document. Furthermore, information such as author, uploader, and downloader is fully utilized for tag association and expansion to tagged the document. If the tag dictionary cannot match the relevant content of the document to be tagged, it means that the tag dictionary does not cover the tags for the document. In this case, automatic tag expansion is required, extracting new tags through new word discovery and topic discovery. After confirmation by relevant personnel, the new tags are assigned to the document and added to the tag dictionary. Using a tag dictionary and automatic tag expansion to tag documents makes document tags more accurate and richer, thereby making document query and recommendation services more intelligent, improving accuracy, and ultimately enhancing query efficiency.

[0166] Based on the same concept, this embodiment provides a document tag determining device, such as... Figure 2 As shown, the document tag determining device includes:

[0167] Tag recognition module 1, the tag recognition module 1 is used to obtain keywords of the document to be tagged, and to perform tag recognition on the document to be tagged using the keywords, wherein the keywords are determined based on the text content and / or related information of the document to be tagged;

[0168] Tag extraction module 2, which is used to extract tags from the document to be tagged when tag recognition of the document by the keywords fails, so as to extract temporary tags corresponding to the document to be tagged;

[0169] Tag determination module 3, which is used to determine at least one of the temporary tags as the official tag of the document to be determined according to the determination instruction.

[0170] It should be understood that the various modules of the document tag determination device provided in this embodiment can be combined to implement the various steps of the above-described document tag determination method, achieving the same technical effect as the above-described document tag determination method, which will not be elaborated here.

[0171] like Figure 3 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0172] Memory 113 is used to store computer programs;

[0173] In one embodiment of this application, when the processor 111 executes a program stored in the memory 113, it implements the document tag determination method provided in any of the foregoing method embodiments, including:

[0174] Obtain keywords of the document to be tagged, and perform tag recognition on the document to be tagged using the keywords. The keywords are determined based on the text content and / or related information of the document to be tagged.

[0175] When tag recognition of the document using the keywords fails, tag extraction is performed on the document whose tag is to be determined, so as to extract the temporary tag corresponding to the document whose tag is to be determined.

[0176] According to the determination instruction, at least one of the temporary tags will be used as the official tag of the document to be tagged.

[0177] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the document tag determination method provided in any of the foregoing method embodiments.

[0178] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0179] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for determining document tags, characterized in that, The document tag determination method includes: Obtain keywords of the document to be tagged, and perform tag recognition on the document to be tagged using the keywords. The keywords are determined based on the text content and / or related information of the document to be tagged. When tag recognition of the document using the keywords fails, tag extraction is performed on the document to be tagged to extract temporary tags corresponding to the document. This includes: obtaining the document content of the document to be tagged; identifying new words in the document content to determine a new word set for the document to be tagged, the new word set including multiple new words; extracting topics from the document to be tagged using a topic extraction model to determine a topic set for the document to be tagged, the topic set including multiple topics; determining the intersection of the new word set and the topic set; and determining the temporary tags corresponding to the document to be tagged based on the intersection of the new word set and the topic set. According to the determination instruction, at least one of the temporary tags will be used as the official tag of the document to be tagged.

2. The method according to claim 1, characterized in that, Obtain keywords from documents whose tags are to be determined, and perform tag recognition on the documents using the keywords, including: Obtain the document content of the document with the tag to be determined, perform word segmentation on the document content to obtain the high-frequency words of the document content, and use the high-frequency words as the keywords; Search for tags corresponding to the keywords in the tag dictionary, which has a mapping relationship between keywords and tags; If no tag corresponding to the keyword is found in the tag dictionary, it is determined that tag recognition of the document using the keyword has failed.

3. The method according to claim 1, characterized in that, Obtain keywords from documents whose tags are to be determined, and perform tag recognition on the documents using the keywords, including: Obtain the associated information of the document with the tag to be determined, the associated information including: document author information, document uploader information, and document downloader information, and use the associated information as the keyword; Based on the keywords, the target information corresponding to the associated information is searched in the target graph database. The target information includes: industry information and / or field information. If the target information corresponding to the associated information is not found in the target graph database, it is determined that the tag recognition of the document by the keyword has failed.

4. The method according to claim 1, characterized in that, Based on the intersection of the new vocabulary set and the topic set, the temporary tags corresponding to the documents to be tagged are determined, including: When the intersection of the new vocabulary set and the topic set is not empty, the words in the intersection of the new vocabulary set and the topic set are used as temporary tags for the document whose tags are to be determined.

5. The method according to claim 1, characterized in that, Based on the intersection of the new vocabulary set and the topic set, the temporary tags corresponding to the documents to be tagged are determined, including: When the intersection of the new word set and the topic set is empty, obtain the target words corresponding to each topic in the topic set; The target words corresponding to each topic are used as temporary tags for the document whose tags are to be determined.

6. The method according to any one of claims 1-5, characterized in that, According to the determination instruction, at least one of the temporary tags is used as the official tag of the document to be tagged, including: The determined temporary label is displayed on the interactive interface; Receive the determination instruction for determining the formal tag, and determine at least one of the temporary tags as the formal tag of the document to be tagged; After determining at least one of the temporary tags as the official tag of the document to be tagged according to the determination instruction, the method further includes: Add the official tag and words that are related to the official tag to the tag dictionary.

7. A document tag determining device, characterized in that, The document tag determining device includes: A tag recognition module is used to obtain keywords of a document with tags to be determined, and to perform tag recognition on the document with tags to be determined using the keywords. The keywords are determined based on the text content and / or related information of the document with tags to be determined. A tag extraction module is used to extract tags from the document to be tagged when tag recognition of the document by the keywords fails. This involves: obtaining the document content of the document to be tagged; identifying new words in the document content to determine a new word set, which includes multiple new words; extracting topics from the document using a topic extraction model to determine a topic set, which includes multiple topics; determining the intersection of the new word set and the topic set; and determining the temporary tag corresponding to the document to be tagged based on the intersection of the new word set and the topic set. A tag determination module is configured to determine at least one of the temporary tags as the official tag of the document to be tagged, according to a determination instruction.

8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the document tag determination method according to any one of claims 1-6.

9. 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 document tag determination method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Method and system for label automatic extraction

    CN103177036A

  • Document recommendation method and device based on semantic tags

    CN109376309A