Knowledge graph construction method, device and equipment based on unsupervised syntactic analysis
By using unsupervised syntactic analysis, we obtain text datasets for preprocessing and encoding, calculate syntactic tree scores, and decode to construct knowledge graphs. This solves the problems of large workload and poor portability in traditional methods, and achieves low-cost and efficient knowledge graph construction.
Patent Information
- Application Number
- CN202210053719.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-18
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2042-01-18
AI Technical Summary
Existing technologies rely on heuristic rules when constructing knowledge graphs, resulting in a large workload and poor portability. This is especially true in single-data domains such as Weibo text datasets, where costs are high. Traditional supervised syntactic analysis requires a large amount of manual annotation, limiting its application value.
An unsupervised syntactic analysis method is adopted. By acquiring a text dataset, preprocessing it, encoding it into phrase vector representations of the syntactic tree, calculating the score, decoding the syntactic tree with the highest score, and constructing a knowledge graph.
It enables low-cost and high-efficiency knowledge graph construction, reduces the need for manual annotation, and improves the accuracy and portability of the construction.
Smart Images

Figure CN114661912B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of natural language technology, and particularly relates to a knowledge graph construction method and device based on unsupervised syntactic analysis and equipment. BACKGROUND
[0002] Internet as a global, distributed information service center, provides people with rich data resources and convenient resource acquisition method, but also caused the people's dependence on computers growing. While people use the Internet, also for the Internet into more information; more netizens mean the explosive growth of Internet information. But at the same time, these Internet information is a large number of repetition and redundancy, which brings great difficulty to the efficient use of Internet information; therefore, how to efficiently extract useful information from the Internet in the mass of information and efficient analysis and use is a very important and meaningful problem. The computer processing is very efficient, so people hope to use existing information processing technology to automatically, intelligently from micro-blog text data to obtain valuable information. And the important part of obtaining meaningful information associated with the construction of knowledge graph.
[0003] The existing knowledge graph construction can be divided into two ways according to the data source: one is based on the basic text knowledge base, using natural language processing technology, extracting the entity and the relationship between entities to form triples to construct, this way is generally used for Internet search, the present application relates to this way, the information extraction is a kind of automatic extraction of structured information such as entity, relationship and entity attribute from semi-structured and unstructured data, which is the key step to build correct knowledge graph; the second way needs to use the user pre-defined knowledge graph, which is generally used for specific fields, such as the construction of subject knowledge graph.
[0004] Traditional entity relationship extraction and knowledge graph construction mostly rely on heuristic rules, although simple to implement and high accuracy, but the workload is large, the portability is very poor, with the continuous enrichment of corpus, especially the continuous expansion of micro-blog text data set, this traditional method is no longer feasible. Syntactic analysis as a method of information extraction, over analysis of the relationship between words to reveal the syntactic structure, construct syntax tree, view the core verb as the center component, not dominated by other words, the dominated word is attached to the dominated word by dependency relationship. Whether in the development field or in the professional field, there are already a number of scholars based on syntactic analysis to extract entity relationship.
[0005] Although the effect of supervised syntactic analysis is much better than unsupervised syntactic analysis (for example, the F1 value of the supervised algorithm on the PTB data set and the CTB data set is above 90), supervised syntactic analysis needs a lot of manual work to carefully label the text, and sometimes the participation of linguists is needed, which requires a lot of manpower and material resources. For microblog, a single data field, these costs are sometimes higher, so the application value of supervised syntactic analysis in the actual scene is small. SUMMARY
[0006] Therefore, it is necessary to provide a knowledge graph construction method, device and equipment based on unsupervised syntactic analysis with low cost and high efficiency in view of the above technical problems.
[0007] An embodiment of the present application provides a knowledge graph construction method based on unsupervised syntactic analysis, which comprises:
[0008] obtaining a text data set and preprocessing the text data set;
[0009] encoding the preprocessed data set to obtain a vector representation of each phrase in a syntactic tree;
[0010] calculating a score of the phrase vector representation;
[0011] decoding the syntactic tree with the highest score as the result of syntactic analysis;
[0012] constructing a knowledge graph according to the syntactic tree with the highest score.
[0013] In an embodiment, the obtaining a text data set and preprocessing the text data set comprises:
[0014] converting the text data set into a string and reading the string into a buffer;
[0015] segmenting sentences in the text data set converted into the string;
[0016] initially encoding each of the sentences into a vector and storing in a tuple.
[0017] In an embodiment, the encoding the preprocessed data set to obtain a vector representation of each phrase in a syntactic tree comprises:
[0018] obtaining a text vector representation of a sentence in the preprocessed text data set according to the context in the training corpus;
[0019] obtaining a vector representation of each phrase in a syntactic tree according to the text vector representation of the preprocessed sentence in the text data set.
[0020] In an embodiment, the obtaining the text vector representation of a sentence in the preprocessed text data set according to the context in the training corpus comprises:
[0021] inputting the word sequence of the preprocessed sentence in the text data set into an encoder to obtain the text vector representation of each word;
[0022] the obtaining the vector representation of each phrase in the syntax tree according to the text vector representation of the preprocessed sentence in the text data set comprises:
[0023] obtaining the vector representation of each phrase in the syntax tree according to the text vector representation of each word.
[0024] In an embodiment, the calculating the score of the phrase vector representation comprises:
[0025] obtaining the score and span score of the non-terminal of the phrase;
[0026] determining the score and span score of the non-terminal as the score of the phrase vector representation.
[0027] In an embodiment, the decoding the syntax tree with the highest score comprises:
[0028] for a syntax distance sequence, finding the largest element di in the sequence;
[0029] constructing a left sub-tree with the sentences with subscript less than i and a right sub-tree with the sentences with subscript greater than or equal to i;
[0030] recursively decoding the left sub-tree and the right sub-tree.
[0031] In an embodiment, the constructing a knowledge graph according to the syntax tree with the highest score comprises:
[0032] determining two entities with an associated relationship according to the syntax tree and the part-of-speech feature;
[0033] determining the associated relationship between the two entities according to the syntax tree;
[0034] filtering the associated relationship to obtain an entity relationship without repeated associated relationship.
[0035] An embodiment of the present application provides a knowledge graph construction device based on unsupervised syntax analysis, which comprises:
[0036] a data acquisition module, which acquires a text data set and preprocesses the text data set;
[0037] a data encoding module, which encodes the preprocessed data set to obtain a vector representation of each phrase in the syntax tree;
[0038] a score calculation module, which calculates a score of the phrase vector representation;
[0039] a decoding module, which decodes the syntax tree with the highest score as a result of the syntax analysis;
[0040] a graph construction module, which constructs a knowledge graph according to the syntax tree with the highest score.
[0041] An embodiment of the present application provides a computer readable storage medium, which stores computer instructions,
[0042] The instructions are executed by a processor to implement the steps of the knowledge graph construction method based on unsupervised syntax analysis.
[0043] An embodiment of the present application provides a knowledge graph construction device based on unsupervised syntax analysis, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor,
[0044] The processor executes the program to implement the steps of the knowledge graph construction method based on unsupervised syntax analysis.
[0045] In summary, the method for constructing a knowledge graph based on unsupervised syntax analysis provided by the present application comprises the following steps: obtaining a text data set, preprocessing the text data set, encoding the preprocessed data set to obtain a vector representation of each phrase in a syntax tree, calculating a score of the phrase vector representation, decoding the syntax tree with the highest score as a result of the syntax analysis, and constructing a knowledge graph according to the syntax tree with the highest score. The method solves the problem of large workload and poor portability in the prior art in which a knowledge graph is constructed by using heuristic rules, and realizes the construction of a knowledge graph based on unsupervised syntax analysis, which is low in cost and high in accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. 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.
[0047] Figure 1 A flow chart of the method for constructing a knowledge graph based on unsupervised syntax analysis in an embodiment of the present application;
[0048] Figure 2FIG. 1 is a flow chart of a knowledge graph construction method based on unsupervised syntactic analysis according to an embodiment of the present application;
[0049] Figure 3 FIG. 2 is a flow chart of a knowledge graph construction method based on unsupervised syntactic analysis according to another embodiment of the present application;
[0050] Figure 4 FIG. 3 is a flow chart of a knowledge graph construction method based on unsupervised syntactic analysis according to yet another embodiment of the present application;
[0051] Figure 5 FIG. 4 is a flow chart of a knowledge graph construction method based on unsupervised syntactic analysis according to still another embodiment of the present application;
[0052] Figure 6 FIG. 5 is a flow chart of a knowledge graph construction method based on unsupervised syntactic analysis according to yet another embodiment of the present application;
[0053] Figure 7 FIG. 6 is a schematic diagram of a knowledge graph construction device based on unsupervised syntactic analysis according to an embodiment of the present application;
[0054] Figure 8 FIG. 7 is a hardware schematic diagram of a knowledge graph construction device based on unsupervised syntactic analysis according to an embodiment of the present application. DETAILED DESCRIPTION
[0055] In order to make the above objectives, features and advantages of the present application more apparent, specific embodiments of the present application will be described in detail below with reference to the accompanying drawings. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. It will be apparent, however, to one skilled in the art that the present application can be practiced without using these specific details. In other instances, well-known methods have not been described in detail in order to avoid unnecessarily obscuring the present application. Therefore, the specific embodiments described herein are meant to be only exemplary and not limiting of the present application.
[0056] The technical solutions of the present application will be described below in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0057] In addition, the terms "first", "second", etc. are used only for the purpose of description and should not be understood as indicating or implying relative importance or implying the number of the technical features indicated. Therefore, the features defined with "first", "second", etc. can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "a plurality of" is at least two, such as two, three, etc., unless otherwise specifically limited.
[0058] In the description of the present application, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connection", "connecting" should be understood in a broad sense, for example, can be fixedly connected, can be detachably connected, or integrally connected, can be mechanically connected, can be electrically connected, can be directly connected, can be indirectly connected through an intermediate medium, can be internal communication of two elements, can be wireless connection, or can be wired connection. For those skilled in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.
[0059] In addition, the technical features involved in the different embodiments of the application described below can be combined with each other as long as there is no conflict.
[0060] Embodiment one
[0061] Please refer to Figure 1 An embodiment of the present application provides a knowledge graph construction method based on unsupervised syntactic analysis, which comprises the following steps:
[0062] S100, obtaining a text data set, and preprocessing the text data set.
[0063] In the embodiment of the present application, the text data set can be a microblog text data set. The microblog text data set is obtained, and a series of preprocessing is performed on the data set.
[0064] In one embodiment, please refer to Figure 2 , step S100 comprises:
[0065] S110, converting the text data set into a string, and reading the string into a buffer.
[0066] The text data set is converted into a string format, so as to store the text data set in the buffer.
[0067] S120, performing word segmentation on the sentences in the text data set converted into a string.
[0068] The word segmentation operation is performed on the sentences in the text data set converted into a string, which is realized by using jieba word segmentation, and the underlying word segmentation algorithm is a generative word segmentation algorithm based on hidden Markov, and a Chinese commonly used word dictionary is added to improve the word segmentation effect.
[0069] S130, converting each sentence into a vector by preliminary coding, and storing in a tuple.
[0070] In an embodiment, the text data set needs to be vectorized, each sentence in the text data set is preliminarily coded according to the order of words in the constructed training corpus dictionary, the text string is converted into a vector, and then the vector is coded and trained through the word embedding layer in the coding model. The trained vector is stored in a tuple.
[0071] S200, coding the preprocessed data set to obtain a vector representation of each phrase in the syntax tree.
[0072] Based on the preprocessed text data set in step S100, the text vector representation of the sentence in the text data set is learned according to the context in the training corpus, and then the vector representation of each phrase in the syntax tree is further obtained.
[0073] In an embodiment, please refer to Figure 3 , step S200 includes the following steps:
[0074] S210, obtaining a text vector representation of a sentence in the preprocessed text data set according to the context in the training corpus.
[0075] Specifically, the word sequence of the sentence in the preprocessed text data set is input into the encoder to obtain a text vector representation of each word.
[0076] S220, obtaining a vector representation of each phrase in the syntax tree according to the text vector representation of the sentence in the preprocessed text data set.
[0077] Specifically, the vector representation of each phrase in the syntax tree is obtained according to the text vector representation of each word.
[0078] Further, in the embodiment of the present application, for a given word sequence (i.e. sentence) S=(w0, w1,..., wn), the encoder takes the above word sequence as input to obtain a context vector representation of each word, and then further obtains a vector representation of each phrase in the syntax tree. n-1
[0079] The training of the tree-shaped coding model based on the transformer network is realized, and the tree-shaped coding model modifies the traditional Transformer neural network, adds a module for calculating the syntax component prior in the sentence before the ordinary multi-head self-attention layer, and adds a hierarchical constraint similar to syntax analysis in the calculation of each sub-layer, hoping to implicitly model the hierarchical structure of the sentence and learn the syntax structure of the sentence unsupervisedly.
[0080] In order to join the syntactic prior attention between the words in the sentence, the syntactic structure is implicitly modeled, and on the basis of traditional self-attention, a syntactic prior knowledge calculation module is added as follows:
[0081]
[0082] On the basis of the original dot product self-attention, a C representing syntactic prior knowledge is newly added, wherein different heads in the multi-head self-attention layer are set to share the same syntactic prior knowledge C, which helps to reduce the parameters in the network and prevent overfitting caused by the design of a too complex network. Wherein C is an attention score matrix, C ij represents the probability that the words i and j form a phrase.
[0083] In order to calculate the prior component C, the present application uses maximum likelihood estimation and introduces the assumption that the events of forming a phrase between each word are independent events, and the prior component C ij is calculated as follows:
[0084]
[0085] Wherein P(i,j) represents the probability that the word order set formed by the words i and j constitutes a phrase, a k represents the probability that the words k and k+1 form a phrase.
[0086] Wherein the calculation method of p(i,i+1) (which is equivalent to a i ) is that the present application adopts an attention mechanism similar to the attention mechanism, and also adopts a synthetic attention method to construct an n*n size attention matrix A between words:
[0087] A=Relu(XW1+b1)W2+b2
[0088] Since the score s k,k+1 is in order, in order to prevent the special case of all identical scores, the score is normalized:
[0089] p(k,k+1),p(k,k-1)=softmax(s k,k+1 ,s k,k-1 )
[0090] Then, we need to obtain the self-attention scores between each word in the sentence through the multi-head self-attention mechanism layer, and the operation process of the multi-head self-attention mechanism is briefly introduced below.
[0091] The ordinary dot product attention mechanism can be represented by the following mathematical formula:
[0092]
[0093] where Q ∈ R M×d can be seen as a query vector of length M and dimension d, K ∈ R N×d can be seen as a key vector of length N and dimension d. is a normalization factor to ensure the stability of the gradient during training, and V is the value vector.
[0094] Self-attention mechanism is to set Q, K, and V as source vectors, i.e., Q, K, and V are the same, and then perform calculation. Multi-head self-attention mechanism is to project Q, K, and V to different spaces through H different linear transformations, and then perform self-attention mechanism calculation in different spaces, and finally splice the results in different spaces:
[0095] MultiHead(Q,K,V)=Concat(head1,…,head h )W O
[0096] where W O is a randomly initialized matrix that needs to be trained, and its role is to adjust the spliced matrix to an H-size matrix.
[0097] head i =Attention(QW i Q , KW i K , VW i V )
[0098] In summary, we can finally get the prior component C, which is a matrix representing the probability of forming a phrase between each word. Then multiply the self-attention score matrix between each word obtained by the multi-head self-attention mechanism layer at the corresponding position elements, and finally get the final result of a layer, i.e., the final representation of all words in the sentence that fuse syntactic information and semantic information.
[0099] In addition, due to the recursive nature of the syntactic tree structure, for example: the words connected to each other in the lower layers of the phrase component in the syntactic tree have a higher probability of being connected to each other in a larger phrase in the higher layers, or two words that cannot form a phrase in the lower layers may form a phrase in the higher layers. These special properties of syntactic structure should be considered and implicitly modeled to allow the model to learn the sentence structure unsupervised. Therefore, in view of these hierarchical properties, a hierarchical restriction is added to the model, and we make the score always less than the score where l represents the layer number of the encoding network, k represents the kth word in the sentence; specifically, the representation of the kth word in the sentence in the lth layer has the following properties:
[0100]
[0101] where represents the result of the kth word in the l-1th layer, represents the result of the kth word in the lth layer calculated according to the previous formula. At initialization, we set to 0. Based on these calculations, we can obtain the probability of a phrase composed of all the words in a sentence in each layer, that is, the syntactic prior component matrix; and each layer is also dependent on the result of the previous layer, having a certain hierarchical property. Through experiments, these structures can help the model better learn the syntactic information in the sentence unsupervisedly.
[0102] S300, calculating the score of the phrase vector representation.
[0103] In the embodiment of the present application, the score is divided into two parts, the first part is the score of the non-terminal of the phrase, and the second part is the span score of the phrase. The score is generally obtained by using a two-layer feedforward neural network. According to the obtained phrase span score and non-terminal score, the total score of the final syntactic tree is defined as the sum of the non-terminal scores of all phrases and the span scores of all phrases.
[0104] Specifically, please refer to Figure 4 , step S300 includes:
[0105] S310, obtaining the non-terminal score and the span score of the phrase.
[0106] S320, determining the non-terminal score and the span score as the score of the phrase vector representation.
[0107] The non-terminal score and the span score are added to obtain the score of the phrase vector representation.
[0108] S400, decoding the syntactic tree with the highest score as the result of the syntactic analysis.
[0109] According to step S300, the score of each syntactic tree is calculated, the syntactic tree with the highest score is obtained, and the syntactic tree is taken as the result of the syntactic analysis.
[0110] Specifically, please refer to Figure 5 , the decoding step in step S400 includes:
[0111] S410, for a syntactic distance sequence, first find the largest element di in the sequence.
[0112] S420, the sentences with the subscript less than i form a left sub-tree, and the sentences with the subscript greater than or equal to i form a right sub-tree.
[0113] S430, recursively decoding the left sub-tree and the right sub-tree.
[0114] S500, constructing a knowledge graph according to the syntax tree with the highest score.
[0115] Specifically, please refer to Figure 6 , step S500 includes:
[0116] S510, determining two entities with an associated relationship according to the syntax tree and in combination with a part-of-speech feature.
[0117] S520, determining an associated relationship between two entities according to the syntax tree.
[0118] After obtaining the entity relationship through syntax analysis, the knowledge graph construction based on the entity relationship mainly includes the following three modules: a data module responsible for providing the extracted entity relationship triple; a graph module for constructing the relationship graph between entities based on the triple data provided by the data layer; and an application module for providing reliable support for intelligent search, intelligent question answering and other Internet field applications based on the constructed knowledge graph.
[0119] S530, filtering the associated relationship to obtain an entity relationship without repeated associated relationship.
[0120] To sum up, the method for constructing a knowledge graph based on unsupervised syntax analysis provided by the application, by obtaining a text data set, pre-processing the text data set, encoding the pre-processed data set to obtain a vector representation of each phrase in the syntax tree, calculating the score of the phrase vector representation, decoding the syntax tree with the highest score as the result of syntax analysis, and constructing a knowledge graph according to the syntax tree with the highest score, solves the problem of large workload in constructing a knowledge graph using heuristic rules in the prior art, and poor portability, realizes the construction of a knowledge graph based on unsupervised syntax analysis, and has low cost and high accuracy.
[0121] Embodiment two
[0122] Please refer to Figure 7 , an embodiment of the application provides a device for constructing a knowledge graph based on unsupervised syntax analysis, which comprises a data acquisition module 100, a data encoding module 200, a score calculation module 300, a decoding module 400 and a graph construction module 500.
[0123] The data acquisition module 100 acquires a text data set and pre-processes the text data set;
[0124] The data encoding module 200 encodes the preprocessed data set to obtain a vector representation of each phrase in the syntax tree.
[0125] The score calculation module 300 calculates the score of the phrase vector representation.
[0126] The decoding module 400 decodes the syntax tree with the highest score and takes it as the result of the syntax analysis.
[0127] The graph construction module 500 constructs a knowledge graph according to the syntax tree with the highest score.
[0128] In an embodiment, the data acquisition module 100 is further configured to: convert the text data set into a string, and read the string into a buffer; perform word segmentation on the sentences in the text data set converted into a string; and convert each sentence into a vector and store it in a tuple.
[0129] In an embodiment, the data encoding module 200 is further configured to: obtain a text vector representation of a sentence in the preprocessed text data set according to the context in the training corpus; and obtain a vector representation of each phrase in the syntax tree according to the text vector representation of the sentence in the preprocessed text data set.
[0130] Specifically, the data encoding module 200 is further configured to: input a word sequence of a sentence in the preprocessed text data set into an encoder to obtain a text vector representation of each word; and obtain a vector representation of each phrase in the syntax tree according to the text vector representation of each word.
[0131] In an embodiment, the score calculation module 300 is further configured to: obtain a non-terminal score and a span score of a phrase; and determine the non-terminal score and the span score as the score of the phrase vector representation.
[0132] In an embodiment, the decoding module 400 is further configured to: for a syntax distance sequence, find the largest element di in the sequence; form a left sub-tree with sentences with a subscript less than i and a right sub-tree with sentences with a subscript greater than or equal to i; and perform recursive decoding on the left sub-tree and the right sub-tree.
[0133] In an embodiment, the graph construction module 500 is further configured to: determine two entities with an associated relationship according to the syntax tree and a part-of-speech feature; determine an associated relationship between the two entities according to the syntax tree; and filter the associated relationship to obtain an entity relationship without repeated associated relationships.
[0134] Embodiment Three
[0135] The embodiment of the present application provides a computer readable storage medium, which stores computer instructions, and the instructions are executed by a processor to realize the steps of the method in the embodiment one. The storage medium also stores information. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc. The storage medium can also include a combination of the above-mentioned memories.
[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a computer readable storage medium. When the program is executed, the program can include the processes of the above-mentioned embodiment methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0137] Embodiment four
[0138] The embodiment provides a knowledge graph construction device based on unsupervised syntactic analysis, as shown in the figure, including a memory 820, a processor 810 and a computer program stored in the memory 820 and executable on the processor 810, and the processor 810 executes the program to realize the steps of the method in the embodiment one. Figure 8
[0139] Figure 8 The embodiment of the present application provides a hardware structure diagram of the device for executing the knowledge graph construction method based on unsupervised syntactic analysis, as shown in the figure, the system includes one or more processors 810 and a memory 820, Figure 8 In the embodiment, the processor 810 is taken as an example.
[0140] The device for executing the knowledge graph construction method based on unsupervised syntactic analysis can also include an input device 830 and an output device 840.
[0141] The processor 810, the memory 820, the input device 830 and the output device 840 can be connected through a bus or other means, Figure 8 In the embodiment, the connection through the bus is taken as an example.
[0142] The processor 810 can be a central processing unit (CPU). The processor 810 can also be other general purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, or a combination thereof. The general purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0143] Obviously, the above-described embodiments are only examples for clearly illustrating the present application and are not intended to limit the present application. Based on the above description, one of ordinary skill in the art can further make other different forms of changes or modifications. Here, all the embodiments are not required to be enumerated, and the changes or modifications derived therefrom are still within the protection scope of the present application.
[0144] In the description of the present application, the description of the terms "some embodiments", "other embodiments", "ideal embodiments", etc. means that the specific features, structures, materials or characteristics described in connection with the embodiments or examples are included in at least one embodiment or example of the present application. In the present application, the illustrative description of the above terms does not necessarily refer to the same embodiment or example.
[0145] The technical features of the above-described embodiments can be combined arbitrarily, and for the sake of brevity, not all possible combinations of the technical features in the above-described embodiments are described, however, as long as the combinations of the technical features do not contradict, they should be considered within the scope of the present application.
[0146] The above-described embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as limiting the scope of the patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A method for constructing a knowledge graph based on unsupervised syntactic analysis, characterized in that, The method comprises: obtaining a text dataset and preprocessing the text dataset; encoding the preprocessed dataset to obtain a vector representation of each phrase in the syntax tree; calculating the score of the phrase vector representation; decoding the highest-scoring syntax tree and taking it as the result of the syntax analysis; constructing a knowledge graph according to the highest-scoring syntax tree; wherein the encoding of the preprocessed dataset to obtain a vector representation of each phrase in the syntax tree comprises: inputting the word sequence of the sentence in the preprocessed text dataset into the encoder to obtain a text vector representation of each word; obtaining a vector representation of each phrase in the syntax tree according to the text vector representation of each word; the score calculation of the phrase vector representation comprises: obtaining the score and span score of the non-terminal symbol of the phrase; adding the score and span score of the non-terminal symbol to determine the score of the phrase vector representation. 2.The method of claim 1, wherein, The obtaining of the text dataset and the preprocessing of the text dataset comprises: converting the text dataset into a string and reading the string into a buffer; segmenting the sentences in the text dataset converted into the string; initially encoding each sentence into a vector and storing it in a tuple. 3.The method of claim 1, wherein, The decoding of the highest-scoring syntax tree comprises: finding the largest element di in the sequence for a syntax distance sequence; constructing a left subtree from the sentences with a subscript less than i and a right subtree from the sentences with a subscript greater than or equal to i; recursively decoding the left and right subtrees. 4.The method of claim 1, wherein, The construction of the knowledge graph according to the highest-scoring syntax tree comprises: determining two entities with an associated relationship according to the syntax tree and the part-of-speech features; determining the associated relationship between the two entities according to the syntax tree; filtering the associated relationship to obtain entity relationships without duplicate associated relationships.
5. An apparatus for constructing a knowledge graph based on unsupervised syntactic analysis, characterized by, The apparatus comprises: a data acquisition module that acquires a text dataset and preprocesses the text dataset; a data encoding module that encodes the preprocessed dataset to obtain a vector representation of each phrase in the syntax tree; a score calculation module that calculates the score of the phrase vector representation; a decoding module that decodes the highest-scoring syntax tree and takes it as the result of the syntax analysis; a graph construction module that constructs a knowledge graph according to the highest-scoring syntax tree; wherein the data encoding module is further configured to: input the word sequence of the sentence in the preprocessed text dataset into the encoder to obtain a text vector representation of each word; obtain a vector representation of each phrase in the syntax tree according to the text vector representation of each word; the score calculation module is further configured to: obtain the score and span score of the non-terminal symbol of the phrase; add the score and span score of the non-terminal symbol to determine the score of the phrase vector representation.
6. A computer-readable storage medium having computer instructions stored thereon, wherein the instructions, when executed by a processor, implement the steps of the knowledge graph construction method based on unsupervised syntax analysis according to any one of claims 1-4. 7.A knowledge graph construction device based on unsupervised syntactic analysis, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, the processor implements the steps of the knowledge graph construction method based on unsupervised syntactic analysis according to any one of claims 1-4 when executing the program.
Citation Information
Patent Citations
Text classification method and device
CN101937436A
Dependency syntax tree-based knowledge graph expansion method and system
CN107797991A