KG#
This page summarizes the code structure for this directory and its immediate subdirectories. It focuses on the bin / KG area within the bin module. Use the table of contents below to navigate deeper.
Overview#
The KG (Knowledge Graph) directory contains the legacy knowledge graph construction pipeline and supporting modules for building RDF triples from structured data sources (CSV files, relational databases). It handles:
Database connectivity across multiple engines (PostgreSQL, MySQL, SQL Server)
CSV/matrix data transformation and formatting
Equipment tag analysis and codification (industrial domain)
Dictionary-based fuzzy matching via Elasticsearch
Mapping configuration management
Triple generation orchestration
This directory represents an older generation of KG building tools. The newer pipeline is in bin/KGbuilder/.
Modules#
Core KG building#
KGbuilder..js — Main orchestrator for knowledge graph construction that generates RDF triples from CSV or database sources using mapping definitions and handles triple generation workflows.
KGcontroller..js — File-based controller for managing mapping configurations, storing/retrieving JSON mapping definitions, and assembling global mapping collections for sources.
Database connectors#
dbConnector.js — Knex.js-based database connection abstraction that provides query execution and metadata retrieval (table/column information) across different database drivers (PostgreSQL, MySQL, SQL Server).
KGSqlConnector..js — Provides MySQL-specific SQL connections and queries for retrieving tag and model data with complex joins across multiple attribute tables.
PostgresProxy..js — PostgreSQL connection proxy and schema conversion utilities for migrating from SQL Server to PostgreSQL format.
SQLserverConnector..js — Manages SQL Server connections via the mssql library and handles data queries, with support for complex data enrichment and geometry operations.
Data transformation#
CSVmatrixFormatter.js — Transforms CSV data by reading files, extracting specified columns, and normalizing data into matrix format for further processing.
codification..js — Parses and analyzes equipment tag numbering systems (TEPDK format) from database records, mapping hierarchical codes to functional classifications and equipment properties for knowledge graphs.
definitions.js — Maintains a hardcoded list of POS CAESAR ontology URIs for industrial domain concepts (physical objects, quantities, activities, etc.) used in KG mappings.
temporary..js — Utility script that converts Excel spreadsheet data to tab-separated format by extracting specified columns from worksheets.
Matching & analysis#
dictionaryMatcher..js — Performs fuzzy text matching and similarity finding between CSV data and Elasticsearch indices to find semantic relationships and matching concepts.
tagAnalyzer..js — Analyzes equipment tag naming patterns, extracting character-level patterns (numeric vs alphabetic) and matching tags to functional classifications via database lookups.
Features#
Multi-database connectivity via Knex.js abstraction supporting PostgreSQL, MySQL, and SQL Server with unified query interface.
Industrial domain support with equipment tag codification (TEPDK format) and POS CAESAR ontology mappings.
Fuzzy matching between CSV data and Elasticsearch-indexed dictionaries for semantic enrichment.
Mapping configuration management with JSON-based storage and retrieval of column-to-predicate mappings.
Usage#
The KG builder is typically invoked by the frontend KGcreator tool via Express routes.
KGcontroller..jsmanages mapping configurations that define how CSV columns map to RDF predicates.KGbuilder..jsorchestrates the pipeline: reads data via connectors, applies mappings, and generates triples.Database connectors are selected based on the configured data source type.
Contents
Files in this directory#
codification..jsCSVmatrixFormatter.jsdbConnector.jsdefinitions.jsdictionaryMatcher..jsKGbuilder..jsKGcontroller..jsKGSqlConnector..jsPostgresProxy..jsSQLserverConnector..jstagAnalyzer..jstemporary..js