src.dackar.knowledge_graph.KGconstruction¶
Created on September, 2025
@author: mandd, wangc
Attributes¶
Classes¶
Class designed to automate and check knowledge graph construction |
Functions¶
|
Method that convert a string into datetime according to specific format |
Module Contents¶
- class src.dackar.knowledge_graph.KGconstruction.KG(configFilePath, importFolderPath, uri, pwd, user)[source]¶
Class designed to automate and check knowledge graph construction
- _crossSchemasCheck()[source]¶
Method designed to perform a series of checks across the defined schemas @ In, None @ Out, None
- _checkSchemaStructure(importedSchema)[source]¶
Method designed to check importedSchema against self.baseSchema @ In, importedSchema, dict, schema parsed by tomllib from .toml file @ Out, None
- importGraphSchema(graphSchemaName, tomlFilename)[source]¶
Method that imports new schema contained in a .toml file @ In, graphSchemaName, string, name of the schema to be imported @ In, tomlFilename, string, .toml file contained the new schema @ Out, None
- _checkSchemaDataTypes(schema)[source]¶
Method that checks that the datatypes defined in the new schema are part of the allowed data types contained in self.datatypes @ In, schema, dict, schema parsed by tomllib from .toml file @ Out, None
- _schemaReturnNodeProperties(nodeLabel)[source]¶
Method that returns the properties of the node nodeLabel @ In, nodeLabel, string, ID of the node label @ Out, propdf, dataframe, dataframe containing nodeLabel properties
- _schemaReturnRelationProperties(relation)[source]¶
Method that returns the properties of the selected relation @ In, relation, string, ID of the node label @ Out, propdf, dataframe, dataframe containing relation properties
- _constructionSchemaStructureValidation(constructionSchema)[source]¶
Method that validates the structure of constructionSchema @ In, constructionSchema, dict, construction schema @ Out, None
- _constructionSchemaValidation(constructionSchema)[source]¶
Method that validates the constructionSchema against defined schemas @ In, constructionSchema, dict, construction schema @ Out, None
- genericWorkflow(data, constructionSchema)[source]¶
Method designed to importa data into knowledge graph according to constructionSchema @ In, data, pd.dataframe, pandas dataframe containing data to be imported in the knowledge graph @ Out, constructionSchema, dict, dataframe containing relation properties. A construction schema is defined as follows:
- constructionSchema = {‘nodes’nodeConstructionSchema,
‘relations’: edgeConstructionSchema}
- nodeConstructionSchema = {‘nodeLabel1’: {‘property1’: ‘dataframe.colA’, ‘property2’: ‘dataframe.colB’},
‘nodeLabel2’: {‘property1’: ‘dataframe.colC’}}
- edgeConstructionSchema = [{‘source’: {‘nodeLabel1.property1’:’dataframe.col1’},
‘target’: {‘nodeLabel2.property1’:’dataframe.col2’}, ‘type’ : ‘edgeType’, ‘properties’: {‘property1’: ‘dataframe.colAlpha’, ‘property2’: ‘dataframe.colBeta’}}]
- _checkDataframeDatatypes(data, constructionSchema)[source]¶
Method that checks that data elements in data match format specified in the graph schemas @ In, data, pd.dataframe, pandas dataframe containing data to be imported in the knowledge graph @ In, constructionSchema, dict, dataframe containing relation properties @ Out, None
- src.dackar.knowledge_graph.KGconstruction.stringToDatetimeConverterFlexible(dateString, formatCode=None)[source]¶
Method that convert a string into datetime according to specific format @ In, dateString, string, string containing date @ In, formatCode, string, datetime specific format @ Out, datetimeObject, datetime, datetime object