Knowledge graph node quantity determination method and apparatus, electronic device, and storage medium
By acquiring high-frequency words, calculating index numbers and scores to filter key sentences, the number of knowledge graph nodes is determined, solving the problem of inaccurate determination of the number of nodes in long texts and realizing the mapping of the core information of the knowledge graph.
Patent Information
- Application Number
- CN202210905461.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2042-07-29
AI Technical Summary
In the process of knowledge graph construction, existing technologies have difficulty in effectively determining the number of nodes required for each sentence in a long text, resulting in the construction of meaningless or unimportant relation nodes, causing the knowledge graph to lose its focus or become chaotic.
By acquiring high-frequency words from the text to be processed, determining the index number of the high-frequency words in the sentences after sentence segmentation, calculating the sentence score, and filtering out key sentences based on the score, the number of nodes for each key sentence is determined based on the preset total number of nodes and the score of the key sentences.
Effectively filter out non-essential sentences, highlight the key points of each sentence, and ensure that the knowledge graph can map out the core information, avoiding the loss of focus by building a knowledge graph for every sentence.
Smart Images

Figure CN115114456B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of knowledge graph construction, and particularly relates to a knowledge graph node quantity determination method and device, electronic equipment and a storage medium. BACKGROUND
[0002] In the process of knowledge graph construction, it is usually necessary to extract words for node construction. When the database is non-structured data, that is, a long text, the system often has difficulty in determining the number of nodes to be constructed for each sentence.
[0003] Generally speaking, for long texts, the same number of words is extracted from each segment after segmentation, and the number of nodes of the knowledge graph of each sentence is determined as the number of extracted words. However, this is equivalent to operating each sentence in the long text without distinction, which may construct many meaningless or unimportant relationship nodes, and further, may cause the constructed knowledge graph to lose focus or be chaotic. SUMMARY
[0004] The present application provides a knowledge graph node quantity determination method to solve the problem of determining the same number of nodes for each sentence, which leads to the construction of meaningless or unimportant relationship nodes.
[0005] In a first aspect, the present application provides a knowledge graph node quantity determination method, comprising:
[0006] obtaining high-frequency words of a to-be-processed text, and segmenting the to-be-processed text to obtain a plurality of sentences;
[0007] traversing the sentences to determine the index sequence number of the high-frequency words in the sentences;
[0008] calculating the score of the sentences according to the index sequence number;
[0009] selecting key sentences from the plurality of sentences according to the scores of the sentences;
[0010] determining the number of nodes of the knowledge graph of the key sentences according to a preset total number of nodes and the scores of the key sentences.
[0011] In a second aspect, the present application provides a knowledge graph node quantity determination device, comprising:
[0012] a high-frequency word obtaining module configured to obtain high-frequency words of a to-be-processed text, and segment the to-be-processed text to obtain a plurality of sentences;
[0013] an index sequence number determining module configured to traverse the sentences to determine the index sequence number of the high-frequency words in the sentences;
[0014] A sentence score calculation module is configured to calculate a score of the sentence according to the index sequence number.
[0015] A key sentence screening module is configured to screen a key sentence from the multiple sentences according to the score of the sentence.
[0016] A node number determination module is configured to determine a node number of the knowledge graph of the key sentence according to a preset total node number and the score of the key sentence.
[0017] In a third aspect, the present application provides an electronic device, which comprises:
[0018] at least one processor; and
[0019] a memory in communication with the at least one processor; wherein
[0020] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the knowledge graph node number determination method of the first aspect of the present application.
[0021] In a fourth aspect, the present application provides a computer readable storage medium, which stores computer instructions for enabling a processor to execute the knowledge graph node number determination method of the first aspect of the present application.
[0022] The knowledge graph node number determination method of the embodiments of the present application first acquires high-frequency words of a to-be-processed text, and divides the to-be-processed text into multiple sentences. Then, the method iterates through the sentences, determines index sequence numbers of the high-frequency words in the sentences, calculates scores of the sentences according to the index sequence numbers, screens key sentences from the multiple sentences according to the scores of the sentences, and determines node numbers of the knowledge graph of the key sentences according to a preset total node number and the scores of the key sentences. The scores of the sentences are calculated according to the index sequence numbers of the high-frequency words in the sentences, and the key sentences are screened according to the scores. The knowledge graph is constructed only for the key sentences. On the one hand, some non-key sentences can be screened out, and the focus can be avoided for each sentence. In addition, the node numbers of each key sentence are also determined according to the scores of the key sentences. This means that the node numbers of the key sentences with different scores are different. The node numbers of important sentences with high importance and high scores are more, and the node numbers of important sentences with low importance and low scores are less. The focus of the knowledge graph of each sentence can be further highlighted, and the knowledge graph can map core information.
[0023] It is to be understood that the description of the background art is not an acknowledgement or admission that the embodiments of the present application correspond to the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0025] Figure 1 is a flow chart of a knowledge graph node quantity determination method provided by the first embodiment of the present application;
[0026] Figure 2 is a flow chart of a knowledge graph node quantity determination method provided by the second embodiment of the present application;
[0027] Figure 3 is a structural schematic diagram of a knowledge graph node quantity determination device provided by the third embodiment of the present application;
[0028] Figure 4 is a structural schematic diagram of an electronic device provided by the fourth embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should be within the scope of the present application.
[0030] Embodiment one
[0031] Figure 1 A flow chart of a knowledge graph node quantity determination method provided by the first embodiment of the present application, the present embodiment can be applicable to the case of determining the node quantity of the knowledge graph of the text to be processed. The method can be executed by a knowledge graph node quantity determination device, which can be realized in the form of hardware and / or software. The knowledge graph node quantity determination device can be configured in an electronic device, for example, in a computer used for building a knowledge graph. As shown in the figure, the knowledge graph node quantity determination method comprises: Figure 1
[0032] S101, acquire high-frequency words of the text to be processed, and divide the text to be processed into sentences to obtain a plurality of sentences.
[0033] The knowledge graph is a visualized or knowledge field mapping map, that is, the focus information of people is displayed so that people can quickly and efficiently obtain the focus information without reading a long text, thereby saving information acquisition time. The text to be processed can be a long text, for example, a text of several thousand words. The high-frequency word is a word that appears frequently. Generally, the high-frequency word reflects the focus information contained in the text to some extent, so when the knowledge graph of the text to be processed is constructed, the high-frequency word in the text to be processed can be acquired first. Specifically, the words in the text can be determined according to a preset corpus, the number of each word in the text is counted, and the most numerous words are selected as the high-frequency words.
[0034] The construction of the knowledge graph is performed for the sentence, and the text to be processed can be a long text composed of a plurality of sentences, so the text can be divided into a plurality of sentences first. Specifically, the text can be divided into a plurality of sentences according to the form of the identifier to identify the punctuation, or a pause word table can be written to identify the pause word to divide the text into a plurality of sentences, which is not limited in the present application.
[0035] S102, traverse the sentence to determine the index sequence number of the high-frequency word in the sentence.
[0036] Since the high-frequency word reflects the focus information contained in the text to some extent, for the sentence that does not contain the high-frequency word, it is indicated that the focus information is not contained in the sentence, which can be excluded in advance. For the sentence containing the high-frequency word, the index sequence number of each word in the sentence is determined first, and then the index sequence number of the high-frequency word in the sentence is determined. For example, the sentence includes "artificial intelligence is a branch of computer science", and it is assumed that "artificial intelligence" and "branch" are high-frequency words, and "computer science" and "one" are non-high-frequency words. The index sequence number of the high-frequency word "artificial intelligence" is 1, and the index sequence number of the high-frequency word "branch" is 4. It should be noted that the words without actual word meaning such as adverbs and auxiliary words in the sentence are usually ignored when constructing the knowledge graph, so the index sequence number is not counted in the ordering, for example, "of", "is", and "is".
[0037] S103, calculate the score of the sentence according to the index sequence number.
[0038] The more the number of high-frequency words, the more the focus information contained in the sentence, and the higher the score of the sentence, so the score of the sentence can be positively correlated with the number of high-frequency words, and can also be positively correlated with the concentration degree of the index sequence number, that is, the closer the index sequence number of the high-frequency word, the more the number, and the higher the score of the sentence.
[0039] S104, screening a key sentence from the plurality of sentences according to the score of the sentence.
[0040] The higher the score of the sentence, the higher the importance of the sentence can be, and the key sentence can be screened from the sentence with a higher score. Specifically, the number of key sentences can be pre-set according to the number of all sentences, for example, the number of key sentences can be 1 / 4 of all sentences.
[0041] S105, determining the number of nodes of the knowledge graph of the key sentence according to the preset total number of nodes and the score of the key sentence.
[0042] The number of nodes of the key sentence is positively correlated with its importance, and the importance of the sentence is positively correlated with the score. The number of nodes of different key sentences is different, and for important sentences with high importance and high score, the number of nodes is more, and for important sentences with low importance and low score, the number of nodes is less. It should be noted that the preset total number of nodes is a reference value for allocating the number of nodes, rather than the actual total number of nodes.
[0043] The knowledge graph node number determination method of the embodiment of the application first acquires high-frequency words of the to-be-processed text, and divides the to-be-processed text into sentences to obtain a plurality of sentences; then iterates the sentences to determine the index sequence number of the high-frequency words in the sentences, and calculates the score of the sentence according to the index sequence number, and screens a key sentence from the plurality of sentences according to the score of the sentence, and determines the number of nodes of the knowledge graph of the key sentence according to the preset total number of nodes and the score of the key sentence. The score of the sentence is calculated by the index sequence number of the high-frequency words in each sentence, and the key sentence is screened according to the score, and the knowledge graph is constructed only for the key sentence, which can filter out some non-key sentences and avoid losing the focus point by constructing the knowledge graph for each sentence, and the number of nodes of each key sentence is also determined according to the score of the key sentence, which means that the number of nodes of the key sentences with different scores is different, and for important sentences with high importance and high score, the number of nodes is more, and for important sentences with low importance and low score, the number of nodes is less, which can further highlight the focus point of the knowledge graph of each sentence, and the knowledge graph can map the core information.
[0044] Embodiment two
[0045] Figure 2 A flowchart of a knowledge graph node number determination method provided by the embodiment two of the application, the embodiment of the application is optimized on the basis of the above-mentioned embodiment one, as shown in Figure 2 The knowledge graph node number determination method comprises:
[0046] S201, acquiring high-frequency words of the to-be-processed text, and dividing the to-be-processed text into sentences to obtain a plurality of sentences.
[0047] wherein the high-frequency words of the text to be processed are obtained, comprising:
[0048] The word frequency of each word in the text to be processed is calculated, which is the ratio of the number of a word in the text to the total number of words in the text. A preset corpus is needed to simulate the language use environment.
[0049] The inverse document frequency (IDF) of the word is calculated based on the preset corpus.
[0050]
[0051] wherein Nz is the total number of documents in the corpus, and N1 is the number of documents containing the word. If a word is more common, N1 is larger, and the inverse document frequency (IDF) is smaller. For example, the inverse document frequency (IDF) of common words such as “is” and “therefore” is relatively small.
[0052] The product of the word frequency and the inverse document frequency is calculated to obtain the score of the word. The first N words with the highest scores among the words are determined as the high-frequency words of the text to be processed, and N is a positive integer. That is, for common or colloquial words, even if the number is large, the score is small, and for rare words, the score is high when the number is large. The final score of the word can highlight important words and suppress less important words, so as to better screen high-frequency words and avoid the problem of less important words caused by directly determining high-frequency words according to the number of words. In addition, after obtaining the high-frequency words, the less important words can be filtered according to the user's needs, so as to further refine the high-frequency words, or the words that the user thinks are important but are not included in the high-frequency words can be added to the high-frequency words again. Specifically, the user can pre-set a set of less important words and a set of important words. After obtaining the high-frequency words for the first time, the less important words in the high-frequency words can be deleted according to the set of less important words, and it is determined whether the important words in the set of important words belong to the high-frequency words. If not, the important words are added to the high-frequency words to check for missing words.
[0053] S202, traversing the sentences to determine the index serial numbers of the high-frequency words in the sentences.
[0054] The index serial numbers of the high-frequency words in the sentences are the index position numbers of the high-frequency words in the sentences, and are also the serial numbers of the high-frequency words in all the words in the sentences.
[0055] S203, traversing each sentence to determine whether there are adjacent high-frequency words with a difference between the index serial numbers less than a preset threshold value in the sentence. If yes, S204 is performed, and if not, S205 is performed.
[0056] S204, adding the index serial numbers of the adjacent high-frequency words to the same cluster.
[0057] S205, add the index numbers of the high-frequency words into different clusters respectively.
[0058] For example, a sentence includes high-frequency words A and B, the index number of the high-frequency word A is 1 respectively, and the index number of the high-frequency word B is 3. If the preset threshold is 3, it is obvious that the difference between the index numbers of the high-frequency words A and B is less than the preset threshold, and then 1 and 3 can be put into the same cluster. If the preset threshold is 2, the difference between the index numbers of the high-frequency words A and B is no longer less than the preset threshold, and then 1 and 3 are put into different clusters respectively. It should be noted that adjacent high-frequency words refer to two or more high-frequency words whose index numbers are less than the preset threshold, that is, adjacent high-frequency words. For example, if the preset threshold is 3, the high-frequency words A and B are adjacent high-frequency words.
[0059] S206, traverse each cluster corresponding to the current sentence, and calculate the score of the cluster according to the number of index numbers in the cluster and the range, the score of the cluster is proportional to the number of index numbers and inversely proportional to the range of index numbers.
[0060] The high-frequency words represent the focus information of the text to some extent. The more the number of index numbers, the more the high-frequency words in the cluster. The range of index numbers is the difference between the maximum and minimum values of the index numbers, which represents the distance between the adjacent two index numbers. The smaller the distance between the index numbers, the higher the score of the cluster, and vice versa. The greater the distance between the index numbers, the lower the score of the cluster. In general, the score of the cluster is proportional to the concentration of high-frequency words. The more concentrated the high-frequency words (the smaller the range) or the more the number, the higher the score of the cluster.
[0061] In one example of the embodiment, the score of the cluster can be calculated by the following formula:
[0062]
[0063] Wherein, score is the score of the cluster, s is the number of index numbers in the cluster, k n is the maximum value of the index number, k0 is the minimum value of the index number, (k n -k0) is the range of the index number. It should be noted that the formula is only an example for calculating the score of the cluster, and other methods can also be used to calculate the score of the cluster, such as using the number of high-frequency words and the range of index numbers as the score of the cluster, etc. The present application does not limit this.
[0064] S207, taking the maximum value in the score of the cluster as the score of the current sentence.
[0065] A sentence can include multiple clusters, and the score of the cluster with the maximum score indicates that the high-frequency words in the cluster are most concentrated or the number of adjacent high-frequency words is the most, which best represents the importance of the current sentence, i.e., the maximum value in the score of the cluster can be taken as the score of the current sentence. Therefore, the more high-frequency words or the more adjacent high-frequency words a sentence has, the higher the score of the sentence is, and for sentences with the same number of high-frequency words, the more concentrated the high-frequency words are, the higher the score is. For example, assuming that "clouds" and "sunrise" are high-frequency words, sentence h1 "It is difficult to see the sunrise when clouds are dense", and sentence h2 "Basically, you can see the sunrise as long as the clouds are not dense", since the distance between "clouds" and "sunrise" in h1 is smaller, i.e., the high-frequency words are more concentrated, the score of sentence h1 is higher than that of sentence h2.
[0066] In addition, the score of the current sentence can also be calculated according to actual needs, for example, the average value or mean square deviation of the scores of the clusters is taken as the score of the current sentence.
[0067] S208, selecting a key sentence from the multiple sentences according to the score of the sentence.
[0068] In one example of the embodiment, selecting a key sentence from the multiple sentences according to the score of the sentence includes:
[0069] Step 1, calculating the mean and standard deviation of the scores of all sentences.
[0070]
[0071]
[0072] Step 2, calculating the score threshold by using the mean, standard deviation and a preset factor.
[0073]
[0074] In the above two formulas, is the mean of the scores of the n sentences, x is the standard deviation of the scores of the n sentences, score y is the score threshold, and b is an adjustment coefficient.
[0075] Step 3, determining a target sentence with a score less than the score threshold from the sentences.
[0076] b is a regulation coefficient, the greater b is, the greater the score threshold is, and the higher the upper limit of the score of the target sentence is, the smaller b is, the smaller the score threshold is, and the lower the upper limit of the score of the target sentence is. Since the high-frequency words also include some colloquial, common or non-highlighted words, the sentence may also include multiple such words, thereby causing the score of the sentence to be too high, and in fact, the content of the sentence includes little or no focus information. Therefore, the score threshold can be set to filter out these non-highlighted sentences, and then obtain the target sentence, thereby preventing non-highlighted sentences from being regarded as highlighted sentences and reducing the information integration degree of the knowledge graph. Wherein, b is a value between 0 and 1, and the value of b can be determined according to actual needs.
[0077] Step 4, determining the first M sentences with the highest scores in the target sentences as the highlighted sentences, wherein M = t / a, t is the total number of sentences of the text to be processed, and a is a preset value, and t is a positive integer.
[0078] After filtering out the non-highlighted sentences, the M sentences with the highest scores, i.e., the sentences with the highest focus information integration degree, are determined from the remaining target sentences. For example, when the total number of sentences t is 100 and a is 10, M is 10, which means that 10 sentences are selected from 100 sentences as highlighted sentences.
[0079] S209, determining the highest score from the scores of the highlighted sentences.
[0080] S210, calculating the node number of the highlighted sentences according to the preset total node number, the highest score, the number of highlighted sentences, and the scores of the highlighted sentences, wherein the node number is negatively related to the number of highlighted sentences and positively related to the scores of the highlighted sentences.
[0081] The scores of the highlighted sentences are also different, the higher the score of the highlighted sentence is, the higher the focus information integration degree of the highlighted sentence is, and for the construction of the knowledge graph, the node number of the highlighted sentence is positively related to the score of the highlighted sentence when the node number is constant, the more the number of highlighted sentences is, the fewer the node number allocated to each highlighted sentence is, i.e., the node number is negatively related to the number of highlighted sentences. The node number of the highlighted sentence is also positively related to the score of the highlighted sentence.
[0082] In one example of the embodiment, the node number of the highlighted sentence can be calculated according to the following formula:
[0083]
[0084] Wherein, N i is the node number of the i-th highlighted sentence, total is the preset total node number, M is the number of highlighted sentences, score i is the score of the i-th highlighted sentence, scoreh is the highest score, is a rounding up symbol.
[0085] After the number of nodes of each key sentence is obtained, the knowledge graph of each key sentence can be constructed according to the number of nodes.
[0086] In an optional embodiment of the present application, after the number of nodes of the key sentence is calculated, the sum of all node numbers can be calculated to obtain the total number of nodes of the text to be processed.
[0087] The knowledge graph node number determination method of the embodiment of the present application first obtains the high-frequency words of the text to be processed, and divides the text to be processed to obtain a plurality of sentences; then traverses the sentences, calculates the score of the sentence according to the number and concentration of the high-frequency words, and the higher the number and concentration, the higher the score of the sentence; then filters out the sentences with a false high score caused by common words from the key sentences with a high score to obtain target sentences, and then determines part of the sentences from the target sentences as key sentences. Not only the score of the sentence is calculated according to the number and concentration of the high-frequency words, but also the sentences with a false high score are filtered out, so that the sentences for constructing the knowledge graph are ensured to be sentences with effective information and high information integration. The knowledge graph of each sentence can be further highlighted to make the knowledge graph map core information.
[0088] Embodiment three
[0089] Figure 3 The structure diagram of a knowledge graph node number determination device provided by the embodiment three of the present application is shown in FIG. 3. Figure 3 As shown in FIG. 3, the knowledge graph node number determination device includes:
[0090] A high-frequency word acquisition module 301 is configured to acquire high-frequency words of a text to be processed, and divide the text to be processed to obtain a plurality of sentences.
[0091] An index number determination module 302 is configured to traverse the sentences, and determine the index number of the high-frequency words in the sentences.
[0092] A sentence score calculation module 303 is configured to calculate the score of the sentence according to the index number.
[0093] A key sentence screening module 304 is configured to screen key sentences from the plurality of sentences according to the score of the sentences.
[0094] A node number determination module 305 is configured to determine the number of nodes of the knowledge graph of the key sentence according to a preset total node number and the score of the key sentence.
[0095] In an optional embodiment of the present application, the high-frequency word acquisition 301 includes:
[0096] a word frequency calculation sub-module, configured to calculate a word frequency of each word in the text to be processed;
[0097] a reverse document frequency calculation sub-module, configured to calculate a reverse document frequency of the word based on a preset corpus;
[0098] a word score calculation sub-module, configured to calculate a product of the word frequency and the reverse document frequency to obtain a score of the word;
[0099] a high-frequency word determination sub-module, configured to determine N words with the highest scores among the words as high-frequency words of the text to be processed, wherein N is a positive integer.
[0100] In an optional embodiment of the present application, the sentence score calculation module 303 comprises:
[0101] a clustering sub-module, configured to traverse each of the sentences, determine whether there are adjacent high-frequency words with a difference between index numbers less than a preset threshold in the sentence, and if so, add the index numbers of the adjacent high-frequency words to the same cluster, and if not, add the index numbers of the high-frequency words to different clusters respectively;
[0102] a cluster score calculation sub-module, configured to traverse each cluster corresponding to the current sentence, calculate a score of the cluster according to a number of the index numbers in the cluster and a range of the index numbers, wherein the score of the cluster is directly proportional to the number of the index numbers and inversely proportional to the range of the index numbers;
[0103] a sentence score determination sub-module, configured to take a maximum value in the scores of the clusters as a score of the current sentence.
[0104] In an optional embodiment of the present application, the score of the cluster is calculated by the following formula:
[0105]
[0106] wherein score is the score of the cluster, s is the number of the index numbers in the cluster, k is a maximum value of the index numbers, k0 is a minimum value of the index numbers, and (k-k0) is the range of the index numbers. n n
[0107] In an optional embodiment of the present application, the key sentence screening module 304 comprises:
[0108] a mean and standard deviation calculation sub-module, configured to calculate a mean and a standard deviation of the scores of all the sentences;
[0109] a score threshold calculation sub-module, configured to calculate a score threshold by using the mean, the standard deviation and a preset factor.
[0110] a target sentence determination sub-module, configured to determine a target sentence with a score less than the score threshold from the sentences;
[0111] a key sentence determination sub-module, configured to determine the top M sentences with the highest scores in the target sentences as key sentences, where M=t / a, t is a total number of sentences in the text to be processed, and a is a preset value.
[0112] In an optional embodiment of the present application, the node number determination module 305 comprises:
[0113] a highest score determination sub-module, configured to determine a highest score from the scores of the key sentences;
[0114] a node number calculation sub-module, configured to calculate the node number of the key sentences according to the preset total node number, the highest score, the number of the key sentences, and the scores of the key sentences, the node number being negatively related to the number of the key sentences and positively related to the scores of the key sentences.
[0115] In an optional embodiment of the present application, the node number of the key sentences is calculated according to the following formula:
[0116]
[0117] wherein N i is the node number of the i-th key sentence, total is the preset total node number, M is the number of the key sentences, score i is the score of the i-th key sentence, score h is the highest score.
[0118] The knowledge graph node number determination apparatus provided by the embodiments of the present application can execute the knowledge graph node number determination method provided by any of the embodiments of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0119] Embodiment Four
[0120] Figure 4A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0121] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0122] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0123] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the method for determining the number of knowledge graph nodes.
[0124] In some embodiments, the knowledge graph node quantity determination method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 48. In some embodiments, portions or all of the computer program can be loaded and / or installed onto electronic device 40 via, e.g., ROM 42 and / or communication unit 49. When the computer program is loaded onto RAM 43 and executed by processor 41, one or more steps of the knowledge graph node quantity determination method described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to perform the knowledge graph node quantity determination method by other any suitable means, e.g., by way of firmware.
[0125] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, specially designed application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0126] Computer programs used to implement the methods of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, implements the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0127] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0128] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0129] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), blockchain network, and the Internet.
[0130] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0131] It should be understood that the various forms of flow shown above can be reordered, added to, or have steps deleted. For example, the steps described in the present application can be performed in parallel, in series, or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, and this is not limited herein.
[0132] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for determining a number of nodes of a knowledge graph, characterized in that, The method comprises the following steps: obtaining high-frequency words of a text to be processed, and dividing the text to be processed into multiple sentences; traversing the sentences to determine the index sequence numbers of the high-frequency words in the sentences; calculating the scores of the sentences according to the index sequence numbers; screening key sentences from the multiple sentences according to the scores of the sentences; determining the number of nodes of a knowledge graph of the key sentences according to a preset total number of nodes and the scores of the key sentences; the calculation of the scores of the sentences according to the index sequence numbers comprises the following steps: traversing each of the sentences to determine whether there are adjacent high-frequency words in the sentences with a difference between the index sequence numbers less than a preset threshold value; if yes, adding the index sequence numbers of the adjacent high-frequency words into the same cluster; if no, adding the index sequence numbers of the high-frequency words into different clusters respectively; traversing each cluster corresponding to the current sentence to calculate the score of the cluster according to the number of the index sequence numbers in the cluster and the range of the index sequence numbers, wherein the score of the cluster is directly proportional to the number of the index sequence numbers and inversely proportional to the range of the index sequence numbers; taking the maximum value in the score of the cluster as the score of the current sentence.
2. The method of claim 1, wherein, The obtaining of the high-frequency words of the text to be processed comprises the following steps: calculating the word frequency of each word in the text to be processed; calculating the inverse document frequency of the word based on a preset corpus; calculating the product of the word frequency and the inverse document frequency to obtain the score of the word; determining the first N words with the highest scores in the words as the high-frequency words of the text to be processed, wherein N is a positive integer.
3. The method of claim 1, wherein, The score of the cluster is calculated by the following formula: wherein score is the score of the cluster, s is the number of index numbers within the cluster, k n is the maximum value of the index numbers, k0is the minimum value of the index numbers, (k n - k0) is the range of the index numbers.
4. The method of claim 1, wherein, The screening of the key sentences from the multiple sentences according to the scores of the sentences comprises the following steps: calculating the mean value and the standard deviation of the scores of all the sentences; calculating a score threshold value by using the mean value, the standard deviation and a preset factor; determining target sentences with scores less than the score threshold value from the multiple sentences; determining the first M sentences with the highest scores in the target sentences as the key sentences, wherein M = t / a, t is the total number of sentences in the text to be processed, and a is a preset value.
5. The method of claim 1, wherein, The determination of the number of nodes of the knowledge graph of the key sentences according to the preset total number of nodes and the scores of the key sentences comprises the following steps: determining the highest score from the scores of the key sentences; calculating the number of nodes of the key sentences according to the preset total number of nodes, the highest score, the number of the key sentences and the scores of the key sentences, wherein the number of nodes is negatively related to the number of the key sentences and positively related to the scores of the key sentences.
6. The method of claim 5, wherein, The number of nodes of the key sentences is calculated by the following formula: Wherein, N i is the number of nodes of the ith key sentence, total is the preset total number of nodes, M is the number of key sentences, score i is the score of the ith key sentence, score h is the highest score.
7. A knowledge graph node quantity determination apparatus, characterized by comprising: The method comprises the following steps: a high-frequency word obtaining module is configured to obtain high-frequency words of a text to be processed, and divide the text to be processed into multiple sentences; an index sequence number determining module is configured to traverse the sentences to determine the index sequence numbers of the high-frequency words in the sentences; a sentence score calculating module is configured to calculate the scores of the sentences according to the index sequence numbers; a key sentence screening module is configured to screen key sentences from the multiple sentences according to the scores of the sentences. The node quantity determination module is configured to determine the node quantity of the knowledge graph of the key sentence according to a preset total node quantity and a score of the key sentence. The knowledge graph node quantity determination apparatus is configured to perform the knowledge graph node quantity determination method of any one of claims 1-6.
8. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the knowledge graph node quantity determination method of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to implement the knowledge graph node quantity determination method of any one of claims 1-6 when executed. The computer readable storage medium stores computer instructions for enabling the processor to implement the knowledge graph node quantity determination method of any one of claims 1-6 when executed.
Citation Information
Patent Citations
Noise document screening method and computer readable storage medium
CN111209737A
Method, device and equipment for generating knowledge graph, medium and product
CN113360672A