Ontology generation method, device and product based on semantic mapping file

Through the method based on semantic mapping files, the class, data attributes and object attributes in the relational database are extracted and the relational data ontology is generated, which solves the problem of database security risks in the traditional ontology construction method and achieves efficient and secure ontology generation.

CN118394861BActive Publication Date: 2025-02-14BEIJING BIG DATA ADVANCED TECH RES INST
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410610987.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2025-02-14
Estimated Expiration
2044-05-16

AI Technical Summary

Technical Problem

In the era of big data, traditional ontological construction methods can easily lead to database security risks by directly accessing the database, especially when the database content is rich and the data sources are diverse.

Method used

The ontology generation method based on semantic mapping files is adopted, and the OBDA files in the relational database are obtained, the class, data attributes and object attributes are extracted, and the relational data ontology is generated, and the OWL files are constructed. This method reduces the scope of database exposure and improves security by indirectly accessing the database.

Benefits of technology

It realizes the improvement of database security while generating the body, avoids the security risks brought about by direct access to the database, and ensures the security and efficiency of data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394861B_ABST
    Figure CN118394861B_ABST
Patent Text Reader

Abstract

The present application provides a method, device and product for ontology generation based on semantic mapping files, and relates to the technical field of ontology generation. The method comprises: in response to an ontology generation request sent by a user, obtaining a semantic mapping file in a relational database, wherein the semantic mapping file is an OBDA file of the relational database, and is used to describe data feature information of multiple relational database tables in the relational database; extracting classes, data attributes and object attributes from the semantic mapping file; and generating a relational data ontology according to the extracted classes, data attributes and object attributes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of ontology generation, and in particular to an ontology generation method, device and product based on a semantic mapping file. Background Art

[0002] Ontology refers to the standardized semantic description of a set of concepts in a specific field and their internal logical relationships. It provides a basic classification framework and association description mechanism for domain data, and then rationally organizes the semantics contained in the data. Ontology can be regarded as a digital abstraction of the semantic framework of human knowledge. It is a knowledge bridge between humans and machines, and has the advantages of being easy to query, expand, understand, and share. Automatically converting relational databases into ontology can add semantics to data, achieve interoperability with other systems and applications, support reasoning about data, and create more flexible knowledge representation.

[0003] However, traditional ontology construction is completed by directly accessing the database. In the current big data era, the database is rich in content, and the data sources it contains come from multiple fields or multiple directions in a certain field. The amount of information it contains far exceeds the scope of information required for ontology construction for a certain task. If an ontology is constructed only to complete a certain task, and the access rights to all data in the database are opened without restriction, it is easy to cause security risks. Therefore, it is necessary to develop an ontology generation method, device and product based on semantic mapping files to achieve the goal of improving database security while generating the ontology. Summary of the invention

[0004] In view of the above problems, the embodiments of the present application provide a method, device and product for ontology generation based on a semantic mapping file, so as to overcome the above problems or at least partially solve the above problems.

[0005] In a first aspect of an embodiment of the present application, a method for generating an ontology based on a semantic mapping file is provided, the method comprising:

[0006] In response to an ontology generation request sent by a user, a semantic mapping file in a relational database is obtained, where the semantic mapping file is an OBDA file of the relational database and is used to describe data feature information of a plurality of relational database tables in the relational database;

[0007] Extracting classes, data attributes and object attributes from the semantic mapping file;

[0008] Generate a relational data ontology based on the extracted classes, data attributes and object attributes.

[0009] In a possible implementation manner, extracting classes, data attributes, and object attributes from the semantic mapping file includes:

[0010] Extracting target information of each content segment from the semantic mapping file, the target information comprising at least a plurality of triples, each triple consisting of a subject, a predicate and an object; each content segment in the semantic mapping file corresponds to a relational database table in the relational database;

[0011] According to the target information extracted from each piece of content, the class, data attributes and object attributes of the corresponding relational database table are extracted therefrom.

[0012] In a possible implementation, the extracting the class, data attribute and object attribute of the corresponding relational database table according to the target information extracted from each piece of content includes:

[0013] For the target information extracted from each piece of content, multiple triplets are extracted therefrom, and the following iterations are performed on the multiple triplets in sequence:

[0014] Get the subject, predicate and object in the current triple;

[0015] According to the class type in the current triplet, determining whether the current triplet is a class;

[0016] In the case where the current triple is a class, the class is identified and the next triple is extracted;

[0017] In the case where the current triple is not a class, determining whether the object of the current triple appears in a text type and does not have a unique identifier;

[0018] When the object of the current triplet has a text type and does not have a unique identifier, identify the data attribute and continue to extract the next triplet;

[0019] When the object of the current triple does not contain a text type and has a unique identifier, the object attribute is identified and the next triple is extracted;

[0020] Until all triples in the content are extracted, the class, data attributes and object attributes of the relational database table corresponding to the content are obtained.

[0021] In a possible implementation, the text type is int or string;

[0022] The unique identifier indicates that the object of the current triple does not appear repeatedly in the same target information of the semantic mapping file.

[0023] In a possible implementation, generating a relational data ontology according to the extracted classes, data attributes, and object attributes includes:

[0024] The identified classes, data attributes and object attributes are written into the OWL file in the format to generate the relational data ontology corresponding to the relational database table.

[0025] In a possible implementation, the method further includes:

[0026] For a plurality of relational data tables stored in the relational database, the semantic mapping file is generated according to the columns, primary keys and foreign keys in each relational database table.

[0027] In a possible implementation, the method further includes:

[0028] According to the received ontology generation request, it is determined that the user's access right is an indirect access right; the indirect access right is used to limit the data access scope of the user to the semantic mapping file in the relational database.

[0029] The second aspect of the embodiment of the present application further provides an ontology generation device based on a semantic mapping file, which is applied to the ontology generation method based on a semantic mapping file described in the first aspect of the embodiment of the present application, and the device includes:

[0030] A semantic mapping file acquisition module, used to obtain a semantic mapping file in a relational database in response to an ontology generation request sent by a user, wherein the semantic mapping file is an OBDA file of the relational database and is used to describe data feature information of multiple relational database tables in the relational database;

[0031] An extraction module, used for extracting classes, data attributes and object attributes from the semantic mapping file;

[0032] The ontology generation module is used to generate a relational data ontology based on the extracted classes, data attributes and object attributes.

[0033] In a possible implementation, the extraction module includes:

[0034] A first extraction submodule is used to extract target information of each content segment from the semantic mapping file, wherein the target information includes at least a plurality of triples, each triplet consisting of a subject, a predicate and an object; each content segment in the semantic mapping file corresponds to a relational database table in the relational database;

[0035] The second extraction submodule is used to extract the class, data attribute and object attribute of the corresponding relational database table according to the target information extracted from each piece of content.

[0036] In a possible implementation manner, the second extraction submodule is used to:

[0037] For the target information extracted from each piece of content, multiple triplets are extracted therefrom, and the following iterations are performed on the multiple triplets in sequence:

[0038] Get the subject, predicate and object in the current triple;

[0039] According to the class type in the current triplet, determining whether the current triplet is a class;

[0040] In the case where the current triple is a class, the class is identified and the next triple is extracted;

[0041] In the case where the current triple is not a class, determining whether the object of the current triple appears in a text type and does not have a unique identifier;

[0042] When the object of the current triplet has a text type and does not have a unique identifier, identify the data attribute and continue to extract the next triplet;

[0043] When the object of the current triple does not contain a text type and has a unique identifier, the object attribute is identified and the next triple is extracted;

[0044] Until all triples in the content are extracted, the class, data attributes and object attributes of the relational database table corresponding to the content are obtained.

[0045] In a possible implementation, the text type is int or string;

[0046] The unique identifier indicates that the object of the current triple does not appear repeatedly in the same target information of the semantic mapping file.

[0047] In a possible implementation, the ontology generation module includes:

[0048] The writing submodule is used to write the identified classes, data attributes and object attributes into the OWL file in a format to generate a relational data ontology corresponding to the relational database table.

[0049] In a possible implementation, the device further includes:

[0050] The semantic mapping file generation module is used to generate the semantic mapping file for the multiple relational data tables stored in the relational database according to the columns, primary keys and foreign keys in each relational database table.

[0051] In a possible implementation, the device further includes:

[0052] The permission determination module is used to determine the user's access rights as indirect access rights according to the received ontology generation request; the indirect access rights are used to limit the user's data access scope to the semantic mapping file in the relational database.

[0053] The third aspect of the embodiment of the present application also provides an electronic device, including a memory, a processor and a computer program stored on the memory, and the processor executes the computer program to implement the steps in the ontology generation method based on the semantic mapping file described in the first aspect of the embodiment of the present application.

[0054] The fourth aspect of the embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps in the ontology generation method based on the semantic mapping file described in the first aspect of the embodiment of the present application are implemented.

[0055] The fifth aspect of the embodiments of the present application also provides a computer program product. When the computer program product is run on an electronic device, the processor implements the steps in the ontology generation method based on the semantic mapping file as described in the first aspect of the embodiments of the present application.

[0056] An embodiment of the present application provides an ontology generation method based on a semantic mapping file, the method comprising: in response to an ontology generation request sent by a user, obtaining a semantic mapping file in a relational database, wherein the semantic mapping file is an OBDA file of the relational database, and is used to describe data feature information of multiple relational database tables in the relational database; extracting classes, data attributes, and object attributes from the semantic mapping file; and generating a relational data ontology based on the extracted classes, data attributes, and object attributes.

[0057] The embodiment of the present application mainly utilizes the basic ontology semantics contained in the semantic mapping file (i.e., OBDA file) (i.e., the classes, data attributes, and object attributes of each relational database table are extracted from the semantic mapping file) to construct the ontology and output the OWL file. By purposefully filtering and screening the information in the database and outputting the OBDA file, a firewall is built. When constructing the ontology, only information sufficient to reflect the direction of the relevant field is appropriately extracted. Compared with the method of directly accessing all the data in the relational database to generate the ontology, the method proposed in the embodiment of the present application, which relies on the OBDA file to indirectly access part of the database content, reduces the scope of exposure of the overall database and improves the protection of database security. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0059] Figure 1 It is a flowchart of the steps of a method for generating an ontology based on a semantic mapping file provided in an embodiment of the present application;

[0060] Figure 2 It is a structural schematic diagram of an ontology generation device based on a semantic mapping file provided in an embodiment of the present application;

[0061] Figure 3 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] The exemplary embodiments of the present application will be described in more detail below in conjunction with the accompanying drawings in the embodiments of the present application. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to enable the scope of the present application to be fully communicated to those skilled in the art.

[0063] Ontology refers to the standardized semantic description of the concept set and its internal logical relationship in a specific field. It can provide a basic classification framework and association description mechanism for domain data, and then reasonably organize the semantics contained in the data. Ontology can be regarded as a digital abstraction of the semantic framework of human knowledge. It is a knowledge bridge between humans and machines, and has the advantages of being easy to query, expand, understand, and share. The currently popular knowledge graph is also an intelligent application based on ontology technology. Ontology modeling refers to the use of ontology-based knowledge representation methods to model knowledge. Its core task is to clarify the concepts, attributes, constraints and hierarchical relationships between concepts in the field. It usually includes the following steps: ① domain analysis and overview, ② definition of concepts and relationships, ③ establishment of classes and instances, and ④ definition of rules and constraints. Specifically, it is a process of describing knowledge by defining a set of ontology axioms. Ontology technology provides a standard semantic description for domain concepts and their relationships, and is the basis for data semantic integration and knowledge sharing.

[0064] Dynamic ontology means that the ontology content can be adjusted, added or deleted according to the underlying data source when the system is running, so that the ontology can be flexibly expanded, modified or deleted. This allows it to work in a constantly changing environment and quickly integrate and associate with other ontologies. Correspondingly, dynamic ontology generation means that the system can automatically and agilely generate an ontology based on the structure and content of a given data source.

[0065] Relational Databases (RDB) are widely used to store and manage large amounts of data in various industries. Automatically converting relational databases into ontologies can add semantics to data, achieve interoperability with other systems and applications, support reasoning about data, and create more flexible knowledge representations. Currently, there is a great demand for semantic modeling technology for relational databases using ontologies.

[0066] Existing ontology generation methods only consider reading basic ontology semantics such as tables, columns, primary keys, foreign keys, their attributes and relationships directly from relational databases (RDB). However, the above ontology construction methods are completed by directly accessing the database. In the current era of big data, databases are rich in content, and the data sources they contain come from multiple fields or multiple directions in a certain field. The amount of information they contain far exceeds the scope of information required for ontology construction for a certain task. If an ontology is constructed only to complete a certain task, it is easy to cause security risks if the access rights to all data in the database are opened without restriction. From the perspective of data security, how to construct the required ontology without directly accessing the relational database is also a field worth studying.

[0067] In view of the above problems, the embodiment of the present application proposes an ontology generation method based on a semantic mapping file, so as to improve the protection of database security while generating a relational data ontology. The ontology generation method based on a semantic mapping file provided by the embodiment of the present application is described in detail below with reference to the accompanying drawings through some embodiments and their application scenarios.

[0068] The first aspect of the embodiment of the present application provides a method for generating an ontology based on a semantic mapping file, referring to Figure 1 , Figure 1 A flowchart of a method for generating an ontology based on a semantic mapping file provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:

[0069] Step S101, in response to an ontology generation request sent by a user, a semantic mapping file in a relational database is obtained, wherein the semantic mapping file is an OBDA file of the relational database, and is used to describe data feature information of multiple relational database tables in the relational database.

[0070] Specifically, in this embodiment, the relational database is used to store multi-source heterogeneous relational data (relational database tables). Exemplarily, the relational database may belong to a material transportation information relational database, which is used to store material transportation relational data, that is, a relational database table of material transportation information, such as a facility table, which includes: facility id, facility category code, height, length and width and other data columns.

[0071] Semantic mapping file, that is, the data access (Ontology Based Data Access, OBDA) file in the relational database. In a relational database, data access technology is often used to build the corresponding OBDA file based on the stored relational database table. The OBDA file is used as a semantic mapping file to describe the data feature information of multiple relational database tables (such as the class, data attributes and object attributes of the corresponding relational database table). Specifically, OBDA is a semantic-based data service provision method that can provide more intelligent and efficient services in data access and data query, and is used to implement distributed data services. OBDA uses ontology data access technology to integrate different data sources and data into a unified semantic graph to form a complex, multi-dimensional, semantic data network. In this semantic graph, different data resources can be identified, classified, connected and queried.

[0072] In order to improve the efficiency of relational data ontology modeling, related technologies have proposed a variety of relational data-oriented ontology automatic generation algorithms. However, all of them are implemented by directly accessing the relational database itself. For a given relational data source, such algorithms are responsible for automatically parsing the ontology semantic features from the data in the relational database and generating ontology axioms. The above ontology export algorithm does not consider the database security under full exposure. Most databases in the big data era contain multiple data source information, with extremely rich content, covering multiple fields and multiple directions, far exceeding the information required to construct an ontology for a certain task. Adopting the access permission strategy of opening all information of the relational database and directly extracting the correspondence between tables, fields, primary and foreign keys and ontology axioms can easily lead to the exposure of a large amount of information irrelevant to the ontology construction of the task, resulting in unnecessary security risks.

[0073] In response to the above problem (there are hidden dangers in information security after directly opening the access rights to the relational database), the embodiment of the present application proposes an ontology generation method using indirect access to the relational database. Through purposeful screening and filtering in advance, only the limited database information required for this ontology construction task is provided to generate the ontology and export the OWL file. The OBDA file itself just contains the basic ontology semantics (such as classes, data attributes and object attributes). The embodiment of the present application uses it as a bridge to avoid direct access to the database and read the information required to generate the ontology, thereby achieving the purpose of protecting the security of the relational database.

[0074] In this embodiment, the semantic mapping file may be pre-created and stored in a designated storage medium. In a possible implementation, the method further includes:

[0075] For the multiple relational data tables T1 to T2 stored in the relational database n , according to each relational database table T x The columns, primary keys and foreign keys in the generated semantic mapping file.

[0076] Therefore, after receiving the ontology generation request sent by the user, the pre-created semantic mapping file can be directly obtained, and based on the semantic mapping file, the information required for ontology creation (such as class, data attribute and object attribute) can be extracted to realize ontology creation.

[0077] Step S102: extracting classes, data attributes and object attributes from the semantic mapping file.

[0078] In a possible implementation, the step S102 of extracting classes, data attributes, and object attributes from the semantic mapping file includes:

[0079] Step S1021, extracting target information of each content segment from the semantic mapping file, the target information comprising at least a plurality of triples, each triple consisting of a subject, a predicate and an object; each content segment in the semantic mapping file corresponds to a relational database table in the relational database.

[0080] Specifically, the structure of the OBDA file (semantic mapping file) obtained in step S101 is arranged in segments, and each segment of content corresponds to a relational database table, that is, each segment of content contains the data feature information (class, data attribute and object attribute) of the corresponding relational database table. For the OBDA file, it includes mappingid information (used to represent the ID information of the corresponding relational database table in the semantic graph), target information and source information (used to represent the data source information of the corresponding relational database table). Among them, the data feature information about the corresponding relational database table is mainly concentrated in the target information. Therefore, after obtaining the semantic mapping file, the target information of each segment of content is extracted.

[0081] Step S1022: extracting the class, data attribute and object attribute of the corresponding relational database table according to the target information extracted from each piece of content.

[0082] Specifically, the target information is composed of multiple units, wherein each unit is composed of a triple of a subject, a predicate, and an object. Each unit (i.e., a triple) can be one of a class, a data attribute, and an object attribute. After the target information is extracted, each triple contained therein is identified to obtain the class, data attribute, and object attribute of the corresponding relational database table. This embodiment is based on the segmentation of the OBDA file, and each triple of subject, predicate, and object is decomposed by segment. Then, by analyzing the subject, predicate, and object features in each unit, the class, data attribute, and object attribute are extracted to form a new OWL file.

[0083] In a possible implementation, the step S1022, based on the target information extracted from each piece of content, extracting the class, data attribute and object attribute of the corresponding relational database table, includes:

[0084] For each target information extracted from the content, multiple triples are extracted from it. x The corresponding segment M x target(Mt x ), the subject-verb-object triples extracted from them are S1~S m The following iterations are performed for the multiple triples:

[0085] Step S201, obtain the subject, predicate and object in the current triple. k , the extracted subject, predicate, and object are S ks , S kp , S ko .

[0086] Step S202, judging whether the current triple is a class according to the class type in the current triple. In a triple, the distinction between a class and a data attribute or an object attribute is relatively clear, and the judgment can be made by the class type (for example, in the predicate S kp whether there is an "a" character in the text).

[0087] Step S203: when the current triple is a class, identify the class and continue to extract the next triple.

[0088] Specifically, the triple is judged as a class by the class type, and class S is identified kc , class S kc Directly add it to the file that constitutes OWL. Return to step S201 to obtain the subject, predicate and object of the next triple. If the current triple is not a class, continue to determine whether the current triple is a data attribute or an object attribute, that is, execute step S204.

[0089] Step S204, when the current triple is not a class, it is determined whether the object of the current triple appears in a text type and does not have a unique identifier.

[0090] In a possible implementation, the text type is int or string;

[0091] The unique identifier indicates that the object of the current triple does not appear repeatedly in the same target information of the semantic mapping file.

[0092] Specifically, the distinction between data attributes and object attributes can be judged from two aspects: on the one hand, the type of data attributes is generally int, string, etc., so the text type will appear in the object of the corresponding triple to indicate that it is specifically int or string, etc., while the text type of object attributes will not appear in the object of the corresponding triple.

[0093] On the other hand, the object of the data attribute in the corresponding triple is repetitive and does not have a unique identifier, while the object of the object attribute in the corresponding triple is not repetitive and has a unique identifier. Specifically, the data columns in the table as data attributes are all identified by "^^xsd:" to identify the type, so they will appear repeatedly in the target of the OBDA file. Exemplarily, the data attribute number column Id in the OBDA file contains "^^xsd:int" in the description; the name column Name contains "^^xsd:string" in the description, both of which contain the repetitive non-unique identifier "^^xsd:". As a foreign key, the object attribute will not repeat the same association because it specifies a specific association relationship (the association between table A and table B), so no identifier will appear repeatedly in the target of the OBDA file, that is, this association relationship can be used as a unique identifier. In this way, excluding non-"class" situations, the data attribute or object attribute can be identified by judging whether the object of the triple meets the conditions of "text type appears and does not have a unique identifier" or "text type does not appear and has a unique identifier".

[0094] Step S205, when the object of the current triplet has a text type and does not have a unique identifier, identify the data attribute and continue to extract the next triplet.

[0095] Specifically, when the object S ko If the text type appears (the characters "int" or "string" appear) and there is no unique identifier (there is a repeated identifier "^^xsd:"), then the triple is identified as belonging to the data attribute S kdi , the data attribute S kdi Directly add it to the file that constitutes OWL, and return to step S201 to obtain the subject, predicate and object of the next triple.

[0096] Step S206, when the object of the current triple does not contain a text type and has a unique identifier, identify the object attributes and continue to extract the next triple.

[0097] Specifically, when the object S ko If there is no text type (no "int" or "string" characters), and there is a unique identifier (there is a unique identifier that describes the association relationship), then the triple is identified as belonging to the object attribute S kobj , the object attribute S kobj Directly add it to the file that constitutes OWL, and return to step S201 to obtain the subject, predicate and object of the next triple.

[0098] Step S207, until all triples in the content segment are extracted, the class, data attributes and object attributes of the relational database table corresponding to the content segment are obtained.

[0099] Specifically, when the content of this paragraph Mt x All triples (S1~S m If all the iterations of the above two groups are completed, the class, data attributes and object attributes of the relational database table corresponding to the content of this section are obtained, and the corresponding ontology can be generated.

[0100] Step S103: Generate a relational data ontology based on the extracted classes, data attributes and object attributes.

[0101] In a possible implementation, the step S103, generating a relational data ontology according to the extracted classes, data attributes and object attributes, includes:

[0102] The identified classes, data attributes and object attributes are written into the OWL file in the format to generate the relational data ontology corresponding to the relational database table.

[0103] Specifically, each section M1 to M n , for each segment target (Mt1~Mt n ) After the iterations of the above steps S201 to S207 are completed, the corresponding OWL file has also been constructed in the above steps, and the OWL file can be directly output to obtain the relationship data tables T1 to T n The corresponding relational data ontology.

[0104] In a possible implementation, the method further includes:

[0105] According to the received ontology generation request, it is determined that the user's access right is an indirect access right; the indirect access right is used to limit the data access scope of the user to the semantic mapping file in the relational database.

[0106] In the related art, in order to create an ontology, it is necessary to first obtain access rights to all data in the relational database and directly read the stored database content before constructing the ontology. The above method relies on the tables and columns in the relational database for input, and does not get rid of the dependence on database access. This easily exposes all database content to users without screening, causing security risks. In this embodiment, after receiving the ontology generation request, the user's access rights are set to indirect access rights, thereby limiting the user to only obtain the semantic mapping file in the relational database, and cannot access other data, thereby improving the security of the relational database.

[0107] In summary, the embodiment of the present application proposes an ontology generation method based on a semantic mapping file. The method mainly utilizes the basic ontology semantics (classes, data attributes, and object attributes) already contained in the OBDA file to construct the ontology and output an OWL file. By purposefully filtering and screening the information in the relational database and outputting the OBDA file, a firewall is constructed. When constructing the ontology, only the information in the OBDA file that is sufficient to reflect the direction of the relevant field (classes, data attributes, and object attributes in the target information) is appropriately extracted. This method of indirectly accessing part of the database content by relying on the OBDA file greatly reduces the scope of exposure of the overall database and improves the protection of database security.

[0108] The second aspect of the embodiment of the present application further provides an ontology generation device based on a semantic mapping file, which is applied to the ontology generation method based on a semantic mapping file described in the first aspect of the embodiment of the present application, referring to Figure 2 , Figure 2 A schematic diagram of the structure of an ontology generation device based on a semantic mapping file is shown. Figure 2 As shown, the device comprises:

[0109] A semantic mapping file acquisition module, used to obtain a semantic mapping file in a relational database in response to an ontology generation request sent by a user, wherein the semantic mapping file is an OBDA file of the relational database and is used to describe data feature information of multiple relational database tables in the relational database;

[0110] An extraction module, used for extracting classes, data attributes and object attributes from the semantic mapping file;

[0111] The ontology generation module is used to generate a relational data ontology based on the extracted classes, data attributes and object attributes.

[0112] In a possible implementation, the extraction module includes:

[0113] A first extraction submodule is used to extract target information of each content segment from the semantic mapping file, wherein the target information at least includes: a subject, a predicate and an object; each content segment in the semantic mapping file corresponds to a relational database table in the relational database;

[0114] The second extraction submodule is used to extract the class, data attribute and object attribute of the corresponding relational database table according to the target information extracted from each piece of content.

[0115] In a possible implementation manner, the second extraction submodule is used to:

[0116] For the multiple target information extracted from each piece of content, the following iterations are performed in sequence:

[0117] Get the subject, predicate and object in the current triple;

[0118] According to the class type in the current triplet, determining whether the current triplet is a class;

[0119] In the case where the current triple is a class, the class is identified and the next triple is extracted;

[0120] In the case where the current triple is not a class, determining whether the object of the current triple appears in a text type and does not have a unique identifier;

[0121] When the object of the current triplet has a text type and does not have a unique identifier, identify the data attribute and continue to extract the next triplet;

[0122] When the object of the current triple does not contain a text type and has a unique identifier, the object attribute is identified and the next triple is extracted;

[0123] Until all triples in the content are extracted, the class, data attributes and object attributes of the relational database table corresponding to the content are obtained.

[0124] In a possible implementation, the text type is int or string;

[0125] The unique identifier indicates that the object of the current triple does not appear repeatedly in the same target information of the semantic mapping file.

[0126] In a possible implementation, the ontology generation module includes:

[0127] The writing submodule is used to write the identified classes, data attributes and object attributes into the OWL file in a format to generate a relational data ontology corresponding to the relational database table.

[0128] In a possible implementation, the device further includes:

[0129] The semantic mapping file generation module is used to generate the semantic mapping file for the multiple relational data tables stored in the relational database according to the columns, primary keys and foreign keys in each relational database table.

[0130] In a possible implementation, the device further includes:

[0131] The permission determination module is used to determine the user's access rights as indirect access rights according to the received ontology generation request; the indirect access rights are used to limit the user's data access scope to the semantic mapping file in the relational database.

[0132] The present application also provides an electronic device, referring to Figure 3 , Figure 3 Schematic diagram of an electronic device proposed in an embodiment of the present application. Figure 3 As shown, the electronic device 100 includes: a memory 110 and a processor 120. The memory 110 and the processor 120 are connected via a bus communication. A computer program is stored in the memory 110. The computer program can be executed on the processor 120 to implement the steps in the ontology generation method based on the semantic mapping file disclosed in the embodiment of the present application.

[0133] The embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps in the ontology generation method based on the semantic mapping file disclosed in the embodiment of the present application are implemented.

[0134] The embodiment of the present application also provides a computer program product. When the computer program product is run on an electronic device, the processor implements the steps of the ontology generation method based on the semantic mapping file disclosed in the embodiment of the present application.

[0135] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0136] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0139] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0140] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0141] The above is a detailed introduction to the ontology generation method, device and product based on semantic mapping files provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for ontology generation based on semantic mapping files, characterized in that: The method comprises: In response to an ontology generation request sent by a user, a semantic mapping file in a relational database is obtained, where the semantic mapping file is an OBDA file of the relational database and is used to describe data feature information of a plurality of relational database tables in the relational database; Extracting classes, data attributes and object attributes from the semantic mapping file; Generate a relational data ontology based on the extracted classes, data attributes, and object attributes; The extracting of classes, data attributes and object attributes from the semantic mapping file comprises: Extracting target information of each content segment from the semantic mapping file, the target information comprising at least a plurality of triples, each triple consisting of a subject, a predicate and an object; each content segment in the semantic mapping file corresponds to a relational database table in the relational database; According to the target information extracted from each piece of content, extract the class, data attribute and object attribute of the corresponding relational database table; The target information extracted from each content segment is used to extract the class, data attribute and object attribute of the corresponding relational database table, including: For the target information extracted from each piece of content, multiple triplets are extracted therefrom, and the following iterations are performed on the multiple triplets in sequence: Get the subject, predicate and object in the current triple; According to the class type in the current triplet, determining whether the current triplet is a class; In the case where the current triple is a class, the class is identified and the next triple is extracted; In the case where the current triple is not a class, determining whether the object of the current triple appears in a text type and does not have a unique identifier; When the object of the current triplet has a text type and does not have a unique identifier, identify the data attribute and continue to extract the next triplet; When the object of the current triple does not contain a text type and has a unique identifier, the object attribute is identified and the next triple is extracted; Until all triples in the content are extracted, the class, data attributes and object attributes of the relational database table corresponding to the content are obtained.

2. The ontology generation method based on semantic mapping file according to claim 1, characterized in that: The text type is int or string; The unique identifier indicates that the object of the current triple does not appear repeatedly in the same target information of the semantic mapping file.

3. The ontology generation method based on semantic mapping file according to claim 1, characterized in that: The step of generating a relational data ontology based on the extracted classes, data attributes and object attributes includes: The identified classes, data attributes and object attributes are written into the OWL file in the format to generate the relational data ontology corresponding to the relational database table.

4. The ontology generation method based on semantic mapping file according to claim 1, characterized in that: The method further comprises: For a plurality of relational data tables stored in the relational database, the semantic mapping file is generated according to the columns, primary keys and foreign keys in each relational database table.

5. The ontology generation method based on semantic mapping file according to claim 1, characterized in that: The method further comprises: According to the received ontology generation request, it is determined that the user's access right is an indirect access right; the indirect access right is used to limit the data access scope of the user to the semantic mapping file in the relational database.

6. An ontology generation device based on semantic mapping files, characterized in that: The ontology generation method based on a semantic mapping file applied to any one of claims 1 to 5, the device comprising: A semantic mapping file acquisition module, used to obtain a semantic mapping file in a relational database in response to an ontology generation request sent by a user, wherein the semantic mapping file is an OBDA file of the relational database and is used to describe data feature information of multiple relational database tables in the relational database; An extraction module, used for extracting classes, data attributes and object attributes from the semantic mapping file; The ontology generation module is used to generate a relational data ontology based on the extracted classes, data attributes and object attributes.

7. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps in the ontology generation method based on the semantic mapping file according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that: A computer program / instruction is stored, and when the computer program / instruction is executed by a processor, the steps in the ontology generation method based on a semantic mapping file described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Hierarchical ontology construction method based on multi-source heterogeneous data

    CN113360518A