Ontology construction method and device, electronic device, and computer-readable storage medium
By using a hybrid clustering algorithm combining heuristic iterative algorithms and Gaussian mixture models, and combining it with open-source ontology datasets, ontology data is automatically constructed. This solves the problems of low efficiency and insufficient accuracy in ontology construction in existing technologies, and achieves efficient and accurate ontology construction and knowledge graph generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MASHANG CONSUMER FINANCE CO LTD
- Filing Date
- 2023-01-05
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies suffer from low efficiency and insufficient accuracy in ontology construction, relying on manual construction which leads to both inefficiency and inaccuracy.
A hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model is used to cluster text vectors. Combined with open source ontology dataset, candidate ontology is automatically extracted and target ontology data is constructed to generate knowledge graph.
It achieves efficient and accurate ontology construction, avoiding the inefficiency and inaccuracy of manual construction, improving the accuracy of ontology data in aligning with the actual domain, and reducing the amount of data processing and processing time.
Smart Images

Figure CN116150397B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an ontology construction method and apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] An ontology is a set of terms used to describe a domain. Its hierarchical structure serves as the skeleton and foundation of a knowledge base. Ontologies are typically used to acquire, describe, and represent knowledge in a related domain, provide a common understanding of the knowledge in that domain, identify commonly accepted terms within the domain, provide domain-specific concept definitions and relationships between concepts, and provide information on the activities that occur in the domain, as well as the main theories and fundamental principles of the domain.
[0003] In related technologies, when it is necessary to build an ontology for a certain domain, the ontology is usually built manually. That is, it requires people to be familiar with the professional knowledge of the domain, or it requires the collaboration of domain experts to abstract the concepts in the domain, and the ontology can only be built by combining it with specific application scenarios. This makes the ontology building work not only inefficient, but also potentially prone to low accuracy. Summary of the Invention
[0004] This application provides an ontology construction method and apparatus, electronic device, and computer-readable storage medium, which can efficiently and accurately construct target ontology data corresponding to text data.
[0005] Firstly, this application provides an ontology construction method, which includes:
[0006] Obtain the text vector of the text data to be processed, wherein the text vector includes multiple word vectors, and each word vector corresponds to a word in the text data;
[0007] The text vectors are clustered using a target clustering algorithm to obtain multiple target clusters. The target clustering algorithm is a hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model.
[0008] Based on preset ontology data, ontology extraction processing is performed on the multiple target clusters to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained from an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with the multiple target clusters from the multiple preset ontology corresponding to the preset ontology data.
[0009] Based on the preset relationship data, the preset ontology data, and the candidate ontology set, target ontology data corresponding to the text data is constructed. The target ontology data is used to construct a knowledge graph of the text data, and the preset relationship data is used to describe the relationships between the preset ontology data.
[0010] Secondly, this application provides an ontology construction apparatus, the apparatus comprising:
[0011] A vector acquisition unit is used to acquire text vectors of text data to be processed, wherein the text vectors include multiple word vectors, and each word vector corresponds to a word in the text data;
[0012] Clustering unit, used to cluster the text vector using a target clustering algorithm to obtain multiple target clusters, wherein the target clustering algorithm is a hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model;
[0013] An extraction unit is used to perform ontology extraction processing on the plurality of target clusters according to preset ontology data to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained from an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with the plurality of target clusters from the plurality of preset ontology corresponding to the preset ontology data.
[0014] The construction unit is used to construct target ontology data corresponding to the text data based on preset relationship data, preset ontology data, and the candidate ontology set. The target ontology data is used to construct a knowledge graph of the text data, and the preset relationship data is used to describe the relationships between the preset ontology data.
[0015] Thirdly, this application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the above-described ontology construction method.
[0016] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-described ontology construction method.
[0017] The embodiments provided in this application obtain text vectors of text data to be processed, and perform clustering processing on the text vectors based on a target clustering algorithm to obtain multiple target clusters. After obtaining the multiple target clusters, candidate ontologies are directly extracted from the multiple target clusters through preset ontology data. Then, the target ontology data corresponding to the text data can be constructed based on the candidate ontology set and preset relation data. In this embodiment, it is not necessary to rely on manual ontology construction. Instead, the electronic device automatically and efficiently constructs the target ontology data corresponding to the text data to be processed. Furthermore, during ontology extraction, a hybrid clustering algorithm based on heuristic iterative algorithms and Gaussian mixture models (GMM, Adaptive Background Mixture Models for Real-Time Tracking) is used for ontology clustering. On the one hand, multiple word vectors can be classified based on the semantics of different word vectors in the text vector, thus avoiding the problems of large data processing volume and slow processing speed that may occur when directly extracting ontology based on each word vector. On the other hand, using this hybrid clustering algorithm for ontology clustering also avoids the problems of local optima and failure to fit the true distribution of data that may occur when using a single clustering algorithm. Moreover, since the preset ontology data is obtained from an open-source ontology dataset, performing ontology extraction processing on multiple target clusters based on this preset ontology data makes the resulting candidate ontology more closely aligned with its actual domain, avoiding the problem of inaccurate target ontology data constructed manually due to insufficient understanding of domain common sense, thereby improving the accuracy of ontology construction.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0019] The accompanying drawings are provided to further illustrate the present application and form part of the specification. They are used together with the embodiments of the present application to explain the application and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed example embodiments described with reference to the accompanying drawings, in which:
[0020] Figure 1 A schematic diagram of the implementation environment for the ontology construction method provided in the embodiments of this application;
[0021] Figure 2 A flowchart illustrating an ontology construction method provided in this application embodiment;
[0022] Figure 3 A schematic diagram of the target ontology data provided in the embodiments of this application;
[0023] Figure 4 A flowchart for obtaining a target cluster provided in an embodiment of this application;
[0024] Figure 5 A block diagram illustrating the candidate ontology acquisition process provided in this application embodiment;
[0025] Figure 6 A block diagram of an ontology construction apparatus provided in an embodiment of this application;
[0026] Figure 7 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] To enable those skilled in the art to better understand the technical solutions of this application, exemplary embodiments of this application are described below in conjunction with the accompanying drawings, including various details of the embodiments of this application to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0028] Where there is no conflict, the various embodiments of this application and the features thereof may be combined with each other.
[0029] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.
[0030] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Terms such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.
[0031] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this application, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.
[0032] Please refer to Figure 1 This is a schematic diagram illustrating the implementation environment of the ontology construction method provided in this application embodiment. For example... Figure 1 As shown, the implementation environment may include electronic device 101, terminal device 102, and network 103.
[0033] Electronic device 101 can be either a server or a terminal device. When used as a server, it can be a physical server, such as a blade server or rack server, or a virtual server, such as a server cluster deployed in the cloud; no limitation is made here. When used as a terminal device, it can be a smartphone, laptop, desktop computer, tablet computer, etc.; no limitation is made here. In this application embodiment, unless otherwise specified, electronic device 101 is used as an example of a server. Electronic device 101 can be used to implement the ontology construction method of any embodiment of this application to construct target ontology data corresponding to the text data sent by terminal device 102, and generate a knowledge graph corresponding to the text data based on the target ontology data.
[0034] Terminal device 102 can be a smartphone, laptop, desktop computer, tablet computer, etc. In this embodiment, terminal device 102 can be used to acquire text data to be processed input by the user and send the text data to electronic device 102 to request electronic device 102 to construct target ontology data of the text data based on the method provided in this embodiment, and then generate a knowledge graph corresponding to the text data based on the target ontology data.
[0035] Network 103 can be a wireless network or a wired network, and it can be a local area network or a wide area network. Electronic devices 101 and terminal devices 102 can communicate with each other through network 103.
[0036] In this application embodiment, the electronic device 101 can be used to participate in implementing the ontology construction method according to any embodiment of this application. For example, it can be used to: obtain text vectors of text data to be processed sent by a user based on a terminal device 102, wherein the text vectors include multiple word vectors, each word vector corresponding to a word in the text data; perform clustering processing on the text vectors using a target clustering algorithm to obtain multiple target clusters, wherein the target clustering algorithm is a hybrid clustering algorithm based on a heuristic iterative algorithm and a Gaussian mixture model; perform ontology extraction processing on the multiple target clusters according to preset ontology data to obtain a candidate ontology set, wherein the preset ontology data is data used to describe information about the ontology, and the preset ontology data is obtained from an open-source ontology dataset, and the extraction processing is used to extract candidate ontology that has a relationship with the multiple target clusters from the multiple preset ontology corresponding to the preset ontology data; construct target ontology data corresponding to the text data according to preset relationship data and the candidate ontology set, wherein the target ontology data is used to construct a knowledge graph of the text data, and the preset relationship data is used to describe the relationship between each preset ontology in the preset ontology data.
[0037] Understandable Figure 1 The implementation environment shown is merely illustrative and is by no means intended to limit this application, its application, or its use. For example, although Figure 1 Only one electronic device 101 and one terminal device 102 are shown, but this does not mean that the number of each is limited. The implementation environment may include multiple electronic devices 101 and multiple terminal devices 102.
[0038] To construct ontology data efficiently and accurately, this application provides an ontology construction method. Please refer to [link / reference]. Figure 2 This is a flowchart illustrating an ontology construction method provided in an embodiment of this application. This method can be applied to electronic devices, such as... Figure 1 The electronic device 101 shown.
[0039] like Figure 2 As shown, the ontology construction processing method provided in this application embodiment includes the following steps S201-S204, which will be described in detail below.
[0040] Step S201: Obtain the text vector of the text data to be processed, wherein the text vector includes multiple word vectors, and each word vector corresponds to a word in the text data.
[0041] In the embodiments of this application, the text data can be various forms of text data, such as unstructured text data, semi-structured data, or structured data, such as data stored in a database.
[0042] Unless otherwise specified, in this embodiment of the application, the text data is illustrated as follows: "Urumqi, Xinjiang Economic and Technological Development Zone, Altay, Name or Title or Individual Name, XXX, Legal Representative (Principal Person in Charge) of yyy Co., Ltd. XX Branch (now relocated and renamed yyy Co., Ltd. ZZ Branch) during the period of serving as the branch manager... Date of the decision made: XXXX year X month X day".
[0043] In this embodiment, the text vector can be a text vector that includes multiple word vectors, obtained by segmenting text data and extracting the vectors of the corresponding words. For example, after segmenting the text data, the vectors of each segmented word can be obtained by querying a preset word vector dictionary. This preset word vector dictionary can be obtained by acquiring an open-source word vector dictionary, and is not specifically limited here.
[0044] Step S202: Use a target clustering algorithm to cluster the text vectors to obtain multiple target clusters. The target clustering algorithm is a hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model.
[0045] After obtaining the text vectors of the text data, in order to reduce the amount of data processing during ontology extraction and improve processing speed, considering that an ontology is a cognitive model of specific terms and concepts in a certain domain, i.e., abstract modeling, words belonging to a certain ontology can usually be classified into the same category. Therefore, in this embodiment of the application, the electronic device can perform clustering processing on the text vectors of the text data, so as to cluster each word in the text data into its possible ontology category by calculating the distance between the text vectors of different words.
[0046] Considering that a single clustering algorithm typically only solves problems in one dimension, while other dimensions may present different challenges. For example, while k-means clustering can quickly and easily complete clustering, the requirement for user-specified k can lead to the clustering results converging to local optima. Similarly, while Gaussian mixture models can approximate probability distributions of arbitrary shapes using Gaussian distribution functions (e.g., using the mean and standard deviation to produce elliptical clusters that better fit the true distribution of the data), this type of clustering algorithm suffers from the inability to accurately determine cluster centers, resulting in inaccurate calculations of distances between data points. Therefore, this application proposes a hybrid clustering algorithm based on heuristic iterative algorithms and Gaussian mixture models as the target clustering algorithm. This algorithm is used to cluster the text vector, resulting in more accurate target clusters that better fit the true distribution of words within the text vector.
[0047] Step S203: Perform ontology extraction processing on multiple target clusters based on preset ontology data to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained from an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with multiple target clusters from multiple preset ontology corresponding to the preset ontology data. Step S204: Construct target ontology data corresponding to the text data based on preset relationship data and the candidate ontology set. The target ontology data is used to construct a knowledge graph of the text data, and the preset relationship data is used to describe the relationship between each preset ontology in the preset ontology data.
[0048] In this embodiment, the preset ontology data can be obtained by acquiring ontology, attribute, and other data related to concepts in an open-source ontology set. For example, for the ontology "product," its content in the preset ontology data can be as shown in Table 1 below.
[0049]
[0050]
[0051] Table 1
[0052] In Table 1, the first column can be used to identify the hierarchical structure of the ontology concept, with the highest level being Thing, which means that everything is derived from Thing. The levels can be connected by "-", for example, the identifier after "-" in the first column of Table 1 is "product". The second column can represent the attributes of the ontology, the third column represents the type of each attribute, and the fourth column is used to provide a simple description of each attribute.
[0053] This preset relationship data can be used to describe the relationships between various preset entities in the preset ontology data. These relationships can be hierarchical or other manually defined relationships. The preset relationship data can be stored in a two-dimensional table, as shown in Table 2 below. In Table 2, the data is read in row-first, then column-second order. For example, when querying the relationship between the entity "Company" and the entity "Product," you first need to locate the row containing the entity "Company," and then locate the column containing the entity "Product" from the corresponding column of that row, thus obtaining the relationship between the entities "Company" and "Product" as "Production."
[0054] personnel company product personnel Father / Mother / Boss / Husband and Wife… company Legal representative / Chairman / Employee… Production product
[0055] Table 2
[0056] In this embodiment, after clustering the text vectors of the text data in step S202 to obtain multiple target clusters, ontology extraction processing can be performed on these multiple target clusters based on each preset ontology in the preset ontology data. Preset ontology in the preset ontology data that is associated with these multiple target clusters can be used as candidate ontology. This candidate ontology can be a concept used to abstractly describe a target cluster. For example, for the cluster ['Urumqi', 'Xinjiang', 'Economic and Technological Development Zone', 'Altay'], its candidate ontology could be "location".
[0057] A candidate ontology set is a set that includes at least one candidate ontology. Each candidate ontology corresponds to a target cluster and is used to represent the ontology to which each cluster sample in the target cluster may belong.
[0058] The above ontology extraction process can involve obtaining the text vector corresponding to each preset ontology in the preset ontology data as a sample to construct a test set. The candidate ontology corresponding to each target cluster is obtained by calculating the distance between each ontology vector in the test set and the cluster center of each target cluster. For example, for the three preset ontology "company," "location," and "product," their text vectors "vector1," "vector2," and "vector3" can be obtained as samples to construct a test set. Then, the distances to the aforementioned clusters can be calculated to obtain distance 1, distance 2, and distance 3. Based on the minimum of these three distances and the relationship between the mean distance between each word vector in the cluster and the cluster center, the candidate ontology for the cluster ['Urumqi', 'Xinjiang', 'Economic and Technological Development Zone', 'Altay'] is determined to be "location."
[0059] It should be noted that in the embodiments of this application, the distance between vectors can be their Euclidean distance. Of course, in actual implementation, the distance between vectors can also be obtained by other means, and other means can also be used to extract candidate entities from the target cluster. No special limitation is made here.
[0060] After extracting the candidate ontology set from the target cluster based on step S203, since the candidate ontology sets are isolated from each other, in order to accurately construct ontology data, the candidate ontology in the candidate ontology set can be paired, and the relationship between the corresponding candidate ontology pairs can be obtained by querying the preset relation data, thereby constructing relation triples. Then, based on the attribute data in the ontology data corresponding to each candidate ontology in the preset relation data, the target ontology data corresponding to the text data can be constructed. Based on the target ontology data, the knowledge graph corresponding to the text data can be accurately constructed.
[0061] For example, after the above text data has undergone clustering processing and ontology extraction of the target clusters obtained from the clustering, some of its content can be seen in Table 3 below:
[0062]
[0063] Table 3
[0064] According to Table 3, the candidate ontology set corresponding to this text data can be {'location', 'organization', 'person', 'person's name', 'person's former name', 'company'}. After obtaining this candidate ontology set, step S204 can be executed. First, query the preset relation data shown in Table 4 below to see if there is matching relation data for the corresponding candidate ontology pair. The content of Table 4 can be as shown below. In addition, the method of reading the data in Table 4 is explained in Table 2 above, and will not be repeated here.
[0065]
[0066] Table 4
[0067] After querying, the relational data for each candidate ontology pair is constructed as shown in Table 5. For example, for the candidate ontology pair <location, agency>, a query in Table 4 shows that there is no relationship between them. However, for the candidate ontology pair <agency, location>, a query in Table 4 shows that the relationship between them can be "located in". Therefore, the triplet data for this candidate ontology pair can be constructed as <agency, location, location>. By completing the attributes of "agency" and "location" based on the attributes of the corresponding ontology in the preset ontology data, the relational data for each candidate ontology pair can be constructed as shown in Table 5. Figure 3 The target ontology data corresponding to the text data shown.
[0068] <mechanism, located at, location> <Company, located at, location> <Authority, Supervision, Company> <Company, Subsidiary, Company> <Authority, Mayor, Personnel> <Company, Branch, Company> <Authority, Governor, Personnel> <Company, upstream and downstream, company> <Authority, District Chief, Personnel> <Company, Acquisition, Company> <Organization, staff, personnel> <Company, legal person, personnel> <Authority, Administrative Superior, Authority> <Company, General Manager, Personnel> <Organ, business superior, organ> <Company, Director, Personnel> <Company, Employee, Personnel>
[0069] Table 5
[0070] As can be seen, the ontology construction method provided in this application obtains the text vector of the text data to be processed, and performs clustering processing on the text vector based on the target clustering algorithm to obtain multiple target clusters; after obtaining the multiple target clusters, candidate ontology is directly extracted from the multiple target clusters through preset ontology data, and then the target ontology data corresponding to the text data can be constructed according to the candidate ontology set and preset relation data. In this embodiment, ontology construction can be performed automatically and efficiently by an electronic device based on the text data to be processed, without relying on manual methods. Furthermore, during ontology extraction, a hybrid clustering algorithm based on heuristic iterative algorithms and Gaussian mixture models is used for ontology clustering. This approach categorizes multiple word vectors based on their semantics, avoiding the large data processing volume and slow processing speed issues that can occur when directly extracting ontology from individual word vectors. Additionally, this hybrid clustering algorithm avoids the problems of local optima and inability to fit the true distribution of data that can occur with single clustering algorithms. Moreover, since the preset ontology data is obtained from an open-source ontology dataset, performing ontology extraction on multiple target clusters based on this preset ontology data ensures that the resulting candidate ontology is more closely aligned with the actual domain. This avoids the inaccuracy of manually constructed ontology data due to insufficient understanding of domain common sense, thereby improving the accuracy of ontology construction.
[0071] In some embodiments, before acquiring text data and extracting the text vector from the text data, considering that the user-inputted text data may contain input errors, duplicate inputs, and non-standard word usage, in order to improve the accuracy of the final processing result, after obtaining the text data, the method further includes: performing data preprocessing on the text data, wherein the data preprocessing is used to remove at least one of duplicate data, erroneous data, spaces, and invalid strings from the text data; performing word segmentation on the preprocessed text data to obtain multiple words corresponding to the text data; removing stop words from the multiple words based on a preset stop word dictionary to obtain target text data; after obtaining the target text data, the text vector in step S101 above can be obtained by acquiring the word vectors of each word in the target text data.
[0072] In this embodiment, the word segmentation of the preprocessed text data can be performed using Jieba word segmentation based on a preset word segmentation dictionary. This preset word segmentation dictionary can be user-defined or an open-source word segmentation dictionary can be used; no special limitation is made here.
[0073] For example, each word obtained after tokenizing text data can be ['Urumqi', 'Xinjiang', 'Economic Development Zone', 'Altay', 'name', 'or', 'title', 'or', 'personal name', 'xxx', 'company name', '', 'legal representative', '(', 'principal', 'person in charge', ')', 'served as', 'yyy', 'Co., Ltd.', 'xx', 'Sub-branch', '(', 'currently','relocated','renamed', 'to', 'yyy', 'Co., Ltd.', 'zz', 'Sub-branch', ')', 'branch manager', 'during', '...','made', 'a', 'decision', 'on', 'date', 'xxxx', 'year','month', 'day'].
[0074] Stop words refer to words that have no practical meaning in text data. For example, in text data, the modal particles 'de', 'di', 'de' usually do not have practical semantics and may also increase the workload in subsequent text processing. Therefore, it is possible to consider removing stop words from text data to reduce the subsequent data processing volume and thereby improve the data processing speed.
[0075] For example, after removing the stop words from the text data, we get ['Urumqi', 'Xinjiang', 'Economic Development Zone', 'Altay', 'name', 'title', 'personal name', 'xxx', 'company name', '', 'legal representative', 'person in charge','served as', 'yyy', 'Co., Ltd.', 'xx', 'Sub-branch','relocated','renamed', 'yyy', 'Co., Ltd.', 'zz', 'Sub-branch', 'branch manager', 'during', '...','made', 'date', 'xxxx', 'year','month', 'day'].
[0076] Please refer to Figure 4 , which is a flowchart provided by an embodiment of this application for obtaining target clusters. As Figure 4 shown, in some embodiments, the step of using the target clustering algorithm to cluster the text vectors in step S202 to obtain multiple target clusters may include the following steps S401 - S403:
[0077] Step S401, obtain a first number of clusters and a second number of clusters. Here, the first number of clusters is the initial number of clusters when clustering the text vectors based on the heuristic iterative algorithm, and the second number of clusters is the target number of clusters when clustering the text vectors based on the heuristic iterative algorithm. The second number of clusters is greater than the first number of clusters.
[0078] Step S402, based on the first number of clusters and the second number of clusters, perform a first clustering process on the text vectors based on the heuristic iterative algorithm to obtain multiple first clusters.
[0079] Step S403: The cluster centers of multiple first clusters are used as the initial values of the Gaussian mixture model, and the multiple first clusters are further subjected to a second clustering process based on the Gaussian mixture model to obtain multiple target clusters with a number at least equal to the number of second clusters.
[0080] In this embodiment of the disclosure, the heuristic iterative algorithm can be the xmeans algorithm, wherein, when implementing the algorithm, the range of x can be determined by the first cluster number (i.e., k). min ) and the second cluster number (i.e., k) max ) defines, where k min k is used to limit the initial number of clusters when performing clustering based on the xmeans algorithm. max Used to limit the number of final clusters when performing clustering based on the xmeans algorithm.
[0081] After performing the first clustering of word vectors in the text vector based on the xmeans algorithm, to avoid the problem of local optima in the iterative clustering process, the cluster center of the first cluster obtained from the first clustering process can be used as the initial value of the Gaussian mixture model. Then, based on the Gaussian mixture model, the multiple first clusters are subjected to a second clustering process. Since the Gaussian mixture model uses multiple Gaussian distribution functions to approximate the probability distribution of arbitrary shapes, the clustering results can better fit the true distribution of the data. That is, each word in the text data can be accurately classified into its corresponding category.
[0082] In step S401 above, based on the number of the first cluster and the number of the second cluster, the text vector is subjected to a first clustering process using a heuristic iterative algorithm to obtain multiple first clusters. This may include: (where k represents the number of the first cluster) Selecting k word vectors from multiple word vectors in the text vector as the cluster centers of the initial clusters; clustering other word vectors into the k initial clusters based on the first distance between other word vectors in the text vector and the k word vectors; performing clustering segmentation on each initial cluster according to the splitting index corresponding to each of the k initial clusters to obtain p third clusters, where the splitting index is used to determine whether the initial clusters have undergone clustering segmentation; if p is less than the number of the second cluster, continuing the first clustering process on the p third clusters until multiple first clusters are obtained with a number greater than or equal to the number of the second cluster.
[0083] In this embodiment of the application, the splitting index can be the Bayesian Information Criterion (BIC) score of the cluster, which can be calculated by the following formula 1.
[0084]
[0085] In Formula 1, c represents a cluster, n represents the number of data points in the current cluster, RSS is the sum of squared residuals of the distances from each data point in the cluster to its cluster center, and k represents the number of all clusters.
[0086] That is, in the embodiments of this application, the first clustering process of the text vector based on the heuristic iterative algorithm can be based on the above-mentioned k min Starting with an initial value of k, k word vectors are randomly selected from multiple word vectors in the text vector as the cluster centers of the initial clusters. Then, by calculating the distances between other word vectors and these k word vectors, the other word vectors are clustered into the initial clusters represented by these k cluster centers. Next, binary clustering (2-means) is performed on each of these k initial clusters. If a cluster can be split based on its BIC score, it is divided into two new clusters; otherwise, no splitting is performed. Finally, it is determined whether the number of clusters after splitting is less than k. max If the value is less than 0, the first clustering process described above can be performed; otherwise, the first clustering process can be terminated. That is, compared with the possibility that the clustering results may converge to a local optimum when clustering is performed directly based on the k-means algorithm, the embodiments of this application specify the target range of the clusters and determine whether to split the clusters in each round of clustering based on the BIC score. This can avoid the clustering results from converging to a local optimum and also avoid the clustering process from failing to converge.
[0087] As can be seen, in the embodiments of this application, when performing the first clustering process on text vectors based on the heuristic iterative algorithm, the Bayesian information content is used as the criterion for whether to perform the clustering process, and the number of target clusters is limited. Since 2-means is not sensitive to local optima, x cluster centers can be determined based on xmeans. This facilitates the subsequent calculation of the distance from each word vector in the cluster to the cluster center based on the Gaussian mixture model, and makes up for the shortcoming that the Gaussian mixture model cannot determine the cluster center and therefore cannot calculate the distance.
[0088] In some embodiments, the preset ontology data may include the ontology name of each preset ontology; the ontology extraction process performed on multiple target clusters based on the preset ontology data to obtain a candidate ontology set in step S203 above includes: obtaining the ontology vector of each preset ontology in the preset ontology data, and constructing a test set using the ontology vector as a sample; obtaining the average distance between each cluster text vector in the target cluster and its cluster center as a second distance; for each target cluster, calculating the third distance between each text vector in the test set and the cluster center of the target cluster; and selecting the preset ontology corresponding to the ontology vector whose third distance is less than the second distance as a candidate ontology of the target cluster to obtain a candidate ontology set.
[0089] That is, considering that the data required to construct the graph is often much larger than the ontology library, i.e. the concept categories in the preset ontology data, it is easier to discover potential cluster structures from the input data, i.e. the data to be processed. Then, by traversing the distance from each concept category in the ontology library to the cluster center of each cluster, the concept category of the sample points in the cluster corresponding to the nearest cluster center can be assigned to the nearest concept category in the ontology library.
[0090] Please refer to Figure 5 This is a block diagram of the candidate ontology acquisition process provided in the embodiments of this application. For example... Figure 5 As shown in this embodiment, the ontology vectors of the ontology names of each preset ontology in the preset ontology data, such as ontology 1, ontology 2, ..., ontology n, can be obtained as samples. For example, sample 1, sample 2, ..., sample n are used to construct a test set. Then, the text vectors (x_i, x_i, x_i) of each cluster in each target cluster are obtained respectively. i ) and its cluster center, i.e., the center point (u i The distance between dist(x) i ,u i The mean of ) is used as the second distance avg(C) i ), and obtain each sample in the test set, i.e., each ontology vector (o j ) and the center point (u) of each target cluster i The distance between them is used as the third distance. like That is, a certain sample in the test set, namely the ontology vector (o j ) to a certain target cluster (C i ) cluster center (u i The distance of ) is less than that of the target cluster (C) i All cluster text vectors in ) to their cluster centers (u i If the mean distance of the ontology vector is taken as the mean distance of the target cluster (C), then the preset ontology corresponding to the ontology vector in the preset ontology data can usually be taken as the target cluster (C). i Candidate ontology of ), where C i Let i represent the i-th target cluster, o j Let the j-th sample in the test set be the j-th ontology vector, and let the second distance avg(C) be the average distance between the j-th sample and the j-th ontology vector. i It can be calculated using Formula 2:
[0091] As can be seen from the above description, the method provided in this application embodiment does not need to rely on manual ontology construction. Instead, electronic devices can automatically extract candidate text from text data efficiently and accurately, thereby avoiding the inefficiency and inaccuracy that may exist in related technologies when relying on manual ontology data construction.
[0092] In some embodiments, the preset ontology data includes the ontology name and attributes of each preset ontology; the ontology extraction processing of multiple target clusters based on the preset ontology data to obtain a candidate ontology set in step S203 above includes: obtaining the fourth distance corresponding to each target cluster, wherein the fourth distance is the maximum distance between each text vector in the target cluster and the cluster center of the target cluster; constructing an enhancement test set based on the ontology name and attributes of each preset ontology in the preset ontology data, wherein the enhancement samples in the enhancement test set are generated based on the preset ontology and its attributes; calculating the fifth distance between each enhancement sample in the enhancement test set and the cluster center of the target cluster for each target cluster; if the fifth distance of a preset number of enhancement samples corresponding to a preset ontology is less than the fourth distance corresponding to the target cluster, the preset ontology is used as a candidate ontology of the target cluster to obtain a candidate ontology set.
[0093] In this embodiment, the step of constructing an enhanced test set corresponding to the test set based on the ontology name and attributes of each preset ontology in the preset ontology data can be as follows: concatenating the ontology name and attributes of each preset ontology in the preset ontology data, obtaining the text vector of the string obtained after concatenation as the enhanced sample corresponding to the ontology; and constructing the enhanced test set based on the enhanced sample.
[0094] The preset quantity can be 3, or it can be set as needed; there is no special limitation here.
[0095] For example, for the preset ontology "Enterprise", its name can be concatenated with its attribute "Legal Person" to obtain "Enterprise Legal Person". For the preset ontology "Product", its name can be concatenated with its attribute "Model" to obtain "Product Model". An enhanced test set can be constructed based on the vector of the concatenated strings.
[0096] Please continue reading. Figure 5 That is, to improve the recall and precision of the extracted candidate ontologies, during ontology extraction, the maximum distance between the cluster text vector and its cluster center (i.e., the center point) in each target cluster can be obtained first as the fourth distance (max dist(x)). i ,u i )); and, based on the ontology name and attributes of each preset ontology in the preset ontology data, construct an enhanced test set, and calculate the relationship between the enhanced test set and the original ontology vector (o q Each augmented sample (o) corresponds to enh_q The fifth distance between the cluster center of the target cluster and the cluster center. If the fifth distance between a preset number of augmented samples (e.g., 3 or more) of a preset ontology and the cluster center of a target cluster is less than the fourth distance corresponding to the target cluster, then the preset ontology can be determined as a candidate ontology for the target cluster, where o q This represents the q-th sample in the test set, i.e., the q-th ontology vector.
[0097] As can be seen, in this embodiment of the application, by expanding the preset ontology according to the attributes of each preset ontology in the preset ontology data, an enhanced test set is obtained. If the distance between a preset number of enhanced samples of a preset ontology and the cluster center of a target cluster is less than the maximum sample distance corresponding to the target cluster, that is, if multiple enhanced samples of a preset ontology hit a target cluster, then the probability that the ontology to which the target cluster belongs is the preset ontology will usually be extremely high. Based on this setting, the method can further improve the accuracy and recall rate of the extracted candidate ontology.
[0098] It should be noted that, in actual implementation, one or more of the above-described implementation methods for extracting candidate ontology from the target cluster can be used in combination, and no special limitation is made here.
[0099] In some embodiments, constructing target ontology data corresponding to text data based on preset relation data and a candidate ontology set may include: pairing candidate ontology pairs in the candidate ontology set to obtain multiple candidate ontology pairs; for each candidate text pair, querying the preset relation data to see if there is relation data corresponding to the candidate ontology pair, wherein the relation data includes data in triple format, the triples are used to describe the relationship between a first ontology and a second ontology, the triples use the ontology name of the first ontology as the subject, the relationship between the first ontology and the second ontology as the predicate, and the ontology name of the second ontology as the object; the first ontology and the second ontology are either ontology in the preset ontology data; if relation data exists, obtaining triple data for the candidate ontology pair based on the relation data, wherein the triple data is used to represent the relationship between the two candidate ontology pairs; and constructing target ontology data based on the triple data.
[0100] As shown in Table 2 above, in this embodiment, the preset relationship data can be represented as a two-dimensional table. This two-dimensional table can be a data table with equal row and column lengths. When reading the preset relationship data, a "row-first, column-later" order is used. That is, in this embodiment, when describing the relationships between various preset entities in the preset ontology data, it can be based on relation triples.<s,p,o> The expression is represented as follows: where 's' represents the subject, 'p' represents the predicate, and 'o' represents the object. For example, when searching for the relationship between the candidate ontology pair <Company, Product>, we can use "Company" as the head node and "Product" as the tail node. First, we query the rows of the predefined relation data to see if there is a predefined ontology matching the head node. If there is, we start from the first column of the matching row and query to see if there is a predefined ontology matching the tail node. This gives us the triple data <Company, Product, Product> corresponding to the candidate ontology pair <Company, Product>. It should be noted that after obtaining the triple data of the candidate ontology pair, we can further complete the candidate ontology by querying the attributes of the candidate ontology in the predefined ontology data, thus constructing a relation pair like <Company, Product>. Figure 3 The target ontology data shown corresponds to the text data.
[0101] It is understood that the various method embodiments mentioned above in this application can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this application will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.
[0102] In addition, this application also provides an ontology construction apparatus, an electronic device, and a computer-readable storage medium, all of which can be used to implement any ontology construction method provided in this application. The corresponding technical solutions and descriptions are described in the corresponding section of the method and will not be repeated here.
[0103] Figure 6 This is a block diagram of an ontology construction apparatus provided in an embodiment of this application.
[0104] Reference Figure 6 This application provides an ontology construction apparatus, which includes a vector acquisition unit 601, a clustering unit 602, an extraction unit 603, and a construction unit 604.
[0105] The vector acquisition unit 601 is used to acquire the text vector of the text data to be processed. The text vector includes multiple word vectors, each word vector corresponding to a word in the text data.
[0106] The clustering unit 602 is used to cluster text vectors using a target clustering algorithm to obtain multiple target clusters. The target clustering algorithm is a hybrid clustering algorithm based on a heuristic iterative algorithm and a Gaussian mixture model.
[0107] The extraction unit 603 is used to perform ontology extraction processing on multiple target clusters based on preset ontology data to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained based on an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with multiple target clusters from multiple preset ontology corresponding to the preset ontology data.
[0108] The construction unit 604 is used to construct target ontology data corresponding to text data based on preset relation data and candidate ontology set. The target ontology data is used to construct a knowledge graph of text data, and the preset relation data is used to describe the relationship between each preset ontology in the preset ontology data.
[0109] In some embodiments, when the clustering unit 602 performs clustering processing on text vectors using a target clustering algorithm to obtain multiple target clusters, it can be used to: obtain a first cluster number and a second cluster number, wherein the first cluster number is the initial number of clusters when performing clustering processing on text vectors based on a heuristic iterative algorithm, and the second cluster number is the target number of clusters when performing clustering processing on text vectors based on a heuristic iterative algorithm, and the second cluster number is greater than the first cluster number; perform a first clustering processing on text vectors based on a heuristic iterative algorithm according to the first cluster number and the second cluster number to obtain multiple first clusters; use the cluster centers of the multiple first clusters as the initial values of a Gaussian mixture model, and continue to perform a second clustering processing on the multiple first clusters based on the Gaussian mixture model to obtain multiple target clusters with a number at least equal to the second cluster number.
[0110] In some embodiments, when the clustering unit 602 performs a first clustering process on the text vectors based on a heuristic iterative algorithm according to the first cluster number and the second cluster number to obtain multiple first clusters, it can be used to: select k word vectors as the cluster centers of the initial clusters from the multiple word vectors of the text vectors, with k representing the value of the first cluster number; cluster other word vectors into the k initial clusters according to the first distance between other word vectors in the text vectors and the k word vectors; perform clustering segmentation processing on each initial cluster according to the splitting index corresponding to each initial cluster in the k initial clusters to obtain p third clusters, wherein the splitting index is used to determine whether the initial clusters have been subjected to clustering segmentation processing; if p is less than the second cluster number, continue to perform the first clustering process on the p third clusters until multiple first clusters with a number greater than or equal to the second cluster number are obtained.
[0111] In some embodiments, the preset ontology data includes the ontology name of each preset ontology; when the extraction unit 603 performs ontology extraction processing on multiple target clusters based on the preset ontology data to obtain a candidate ontology set, it can be used to: obtain the vector of the ontology name of each preset ontology in the preset ontology data as an ontology vector, and construct a test set using the ontology vector as a sample; obtain the average distance between the text vector of each cluster in the multiple target clusters and its cluster center as a second distance; for each target cluster, calculate the third distance between each ontology vector in the test set and the cluster center of the target cluster; and take the preset ontology corresponding to the ontology vector whose third distance is less than the second distance as the candidate ontology of the target cluster to obtain a candidate ontology set.
[0112] In some embodiments, the preset ontology data includes the ontology name and attributes of each ontology; when the extraction unit 603 performs ontology extraction processing on multiple target clusters based on the preset ontology data to obtain a candidate ontology set, it can be used to: obtain the fourth distance corresponding to each target cluster, wherein the fourth distance is the maximum distance between each text vector in the target cluster and its cluster center; construct an enhancement test set based on the ontology name and attributes of each preset ontology in the preset ontology data, wherein the enhancement samples in the enhancement test set are generated based on the preset ontology and its attributes; calculate the fifth distance between each enhancement sample in the enhancement test set and the cluster center of the target cluster for each target cluster; if the fifth distance of a preset number of enhancement samples corresponding to a preset ontology is less than the fourth distance corresponding to the target cluster, the preset ontology is used as a candidate ontology of the target cluster to obtain a candidate ontology set.
[0113] In some embodiments, when the extraction unit 603 constructs an enhanced test set corresponding to the test set based on the ontology name and attributes of each ontology in the preset ontology data, it can be used to: concatenate the ontology name and attributes of each preset ontology in the preset ontology data, and obtain the text vector of the string obtained after concatenation as the enhanced sample corresponding to the ontology; and construct the enhanced test set based on the enhanced sample.
[0114] In some embodiments, when constructing target ontology data corresponding to text data based on preset relational data and a candidate ontology set, the construction unit 604 can be used to: pair candidate ontology pairs in the candidate ontology set to obtain multiple candidate ontology pairs; for each candidate text pair, query the preset relational data to see if there is relational data corresponding to the candidate ontology pair, the relational data including data in triple format, the triple being used to describe the relationship between a first ontology and a second ontology, the triple using the ontology name of the first ontology as the subject, the relationship between the first ontology and the second ontology as the predicate, and the ontology name of the second ontology as the object; the first ontology and the second ontology are either ontology in the preset ontology data; if relational data exists, obtain triple data for the candidate ontology pair based on the relational data, wherein the triple data is used to represent the relationship between the two candidate ontology pairs; and construct the target ontology data based on the triple data.
[0115] Figure 7 This is a block diagram of an electronic device provided in an embodiment of this application.
[0116] Reference Figure 7 This application provides an electronic device 700, which includes: at least one processor 701; at least one memory 702; and one or more I / O interfaces 703 connected between the processor 701 and the memory 702; wherein the memory 702 stores one or more computer programs that can be executed by the at least one processor 701, and the one or more computer programs are executed by the at least one processor 701 to enable the at least one processor 701 to execute the above-described ontology construction method.
[0117] This application also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the above-described ontology construction method. The computer-readable storage medium can be volatile or non-volatile.
[0118] This application also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code. When the computer-readable code is run in the processor of an electronic device, the processor in the electronic device executes the above-described ontology construction method.
[0119] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).
[0120] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0121] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0122] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing the status information of the computer-readable program instructions. These electronic circuits can execute the computer-readable program instructions to implement various aspects of this application.
[0123] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0124] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0125] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0126] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0128] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for general illustrative purposes only and should not be construed as limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in conjunction with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in conjunction with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this application as set forth by the appended claims.
Claims
1. An ontology construction method, characterized in that, include: Obtain the text vector of the text data to be processed, wherein the text vector includes multiple word vectors, and each word vector corresponds to a word in the text data; The text vectors are clustered using a target clustering algorithm to obtain multiple target clusters. The target clustering algorithm is a hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model. Based on preset ontology data, ontology extraction processing is performed on the multiple target clusters to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained from an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with the multiple target clusters from the multiple preset ontology corresponding to the preset ontology data. Based on the preset relationship data and the candidate ontology set, target ontology data corresponding to the text data is constructed, wherein the target ontology data is used to construct a knowledge graph of the text data, and the preset relationship data is used to describe the relationships between the various preset ontology data.
2. The method according to claim 1, characterized in that, The text vector is clustered using a target clustering algorithm to obtain multiple target clusters, including: Obtain the first cluster number and the second cluster number, wherein the first cluster number is the initial cluster number when clustering the text vector based on the heuristic iterative algorithm, and the second cluster number is the target cluster number when clustering the text vector based on the heuristic iterative algorithm, and the second cluster number is greater than the first cluster number; Based on the number of the first cluster and the number of the second cluster, the text vector is subjected to a first clustering process using the heuristic iterative algorithm to obtain multiple first clusters; The cluster centers of the plurality of first clusters are used as the initial values of the Gaussian mixture model, and a second clustering process is performed on the plurality of first clusters based on the Gaussian mixture model to obtain the plurality of target clusters with a number at least equal to the number of the second clusters.
3. The method according to claim 2, characterized in that, The first clustering process, based on the first cluster number and the second cluster number, uses a heuristic iterative algorithm to perform a first clustering process on the text vector to obtain multiple first clusters, including: Let k represent the value of the first cluster number, and select k word vectors from the multiple word vectors of the text vector as the cluster centers of the initial cluster; Based on the first distance between other word vectors in the text vector and the k word vectors, the other word vectors are clustered into the k initial clusters; Based on the splitting index corresponding to each of the k initial clusters, each initial cluster is subjected to clustering and segmentation to obtain p third clusters. The splitting index is used to determine whether the initial clusters have been subjected to clustering and segmentation. If p is less than the number of the second clusters, the first clustering process is continued on the p third clusters until a number of first clusters greater than or equal to the number of the second clusters are obtained.
4. The method according to claim 1, characterized in that, The preset ontology data includes the ontology name of each preset ontology; the step of performing ontology extraction processing on the multiple target clusters based on the preset ontology data to obtain a candidate ontology set includes: Obtain the vector of the ontology name of each preset ontology in the preset ontology data as an ontology vector, and construct a test set using the ontology vector as a sample; The average distance between the text vector of each target cluster and its cluster center is obtained as the second distance; For each target cluster, calculate the third distance between each ontology vector in the test set and the cluster center of the target cluster; The preset ontology corresponding to the ontology vector whose third distance is less than the second distance is used as the candidate ontology of the target cluster to obtain the candidate ontology set.
5. The method according to claim 1, characterized in that, The preset ontology data includes the ontology name and attributes of each preset ontology; the step of performing ontology extraction processing on the multiple target clusters based on the preset ontology data to obtain a candidate ontology set includes: Obtain the fourth distance corresponding to each target cluster, wherein the fourth distance is the maximum distance between each text vector in the target cluster and its cluster center; An enhancement test set is constructed based on the ontology name and attributes of each preset ontology in the preset ontology data, wherein the enhancement samples in the enhancement test set are generated based on the preset ontology and its attributes. For each target cluster, calculate the fifth distance between each enhanced sample in the enhanced test set and the cluster center of the target cluster; If the fifth distance of a preset number of enhanced samples corresponding to a preset ontology is less than the fourth distance corresponding to the target cluster, the preset ontology is used as a candidate ontology of the target cluster, and the candidate ontology set is obtained.
6. The method according to claim 5, characterized in that, The step of constructing an enhanced test set corresponding to the test set based on the ontology name and attributes of each preset ontology in the preset ontology data includes: The ontology name and its attributes of each preset ontology in the preset ontology data are concatenated, and the text vector of the string obtained after concatenation is used as the augmented sample corresponding to the ontology. Based on the enhanced samples, construct the enhanced test set.
7. The method according to claim 1, characterized in that, The step of constructing target ontology data corresponding to the text data based on preset relationship data and the candidate ontology set includes: The candidate ontology in the candidate ontology set is grouped into pairs to obtain multiple candidate ontology pairs; For each candidate text pair, query the preset relation data to see if there is relation data corresponding to the candidate ontology pair. The relation data includes data in triple format. The triple is used to describe the relationship between the first ontology and the second ontology. The triple has the ontology name of the first ontology as the subject, the relationship between the first ontology and the second ontology as the predicate, and the ontology name of the second ontology as the object. The first ontology and the second ontology are both ontology in the preset ontology data. In the presence of the relation data, triple data of the candidate ontology pair is obtained based on the relation data, wherein the triple data is used to represent the relationship between the two candidate ontology pairs. The target ontology data is constructed based on the triplet data.
8. A body construction device, characterized in that, include: A vector acquisition unit is used to acquire text vectors of text data to be processed, wherein the text vectors include multiple word vectors, and each word vector corresponds to a word in the text data; Clustering unit, used to cluster the text vector using a target clustering algorithm to obtain multiple target clusters, wherein the target clustering algorithm is a hybrid clustering algorithm based on heuristic iterative algorithm and Gaussian mixture model; An extraction unit is used to perform ontology extraction processing on the plurality of target clusters according to preset ontology data to obtain a candidate ontology set. The preset ontology data is data used to describe information about the ontology. The preset ontology data is obtained from an open-source ontology dataset. The extraction processing is used to extract candidate ontology that has a relationship with the plurality of target clusters from the plurality of preset ontology corresponding to the preset ontology data. The construction unit is used to construct target ontology data corresponding to the text data based on preset relation data and the candidate ontology set, wherein the target ontology data is used to construct a knowledge graph of the text data, and the preset relation data is used to describe the relationships between various preset ontology data.
9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the ontology construction method as described in any one of claims 1-7.
10. 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 ontology construction method as described in any one of claims 1-7.
Citation Information
Patent Citations
Electric power knowledge graph construction method and device
CN112632287A