The article presents the development and formalization of an algorithm for pattern matching in graph representations of textual data as a core component of syntactic-semantic transformations for ontology construction from text documents. The study aims to bridge the gap between natural language processing and formal logic by introducing a universal SPARQL-based approach for executing transf- ormation rules directly on graph database servers. The proposed method integrates RDF data repre- sentation with formal graph transformation techniques, including Double Pushout (DPO), ensuring correctness and mathematical rigor. Through the use of graph indexing schemes such as SPO, POS, and OSP, the proposed approach transforms the computationally expensive subgraph isomorphism task from exponential to practical polynomial complexity. The implementation achieves up to 73% runtime reduction during repeated executions due to server-side caching. The research contributes a flexible, formalized, and scalable mechanism for automatic ontology construction, facilitating deep semantic ana- lysis and causal reasoning from textual sources. The algorithm’s extensibility allows dynamic rule introduction without recompilation, making it suitable for applications in semantic web systems, kno- wledge extraction, and AI-driven natural language understanding.
Within the scope of this research, an algorithm was developed and analyzed for identifying homomorphic and isomorphic matches of pattern subgraphs within syntactic graphs, leveraging RDF representations and SPARQL queries enhanced with filter generation algorithms for shape-based mat- ching. The study demonstrates that the complexity of pattern search can be effectively mitigated through graph database indexing strategies, such as SPO, POS, and OSP indexes, reducing exponential complexity to polynomial levels for practical text block sizes. Experimental evaluation confirmed the scalability and efficiency of the proposed approach, revealing substantial runtime reductions during repeated executions as a result of server-side caching.
The work contributes flexible, formalized, and efficient methods for automatic ontology construction from natural language texts, enabling deep semantic analysis and causal reasoning. The approach supports extensibility and dynamic rule introduction without code recompilation, making it suitable for real-world semantic web and knowledge extraction systems. The results have implications for NLP, ontology engineering, and applications requiring interpretability and scalability in processing complex textual data.
- Al-Ghezi, A., & Wiese, L. (2024). Analyzing workload trends for boosting triple stores performance. Elsevier Ltd. doi:doi.org/10.1016/j.is.2024.102420
- Ali, W., Saleem, M., Yao, B., Hogan, A., & Ngonga Ngomo, A.-C. (2021). A Survey of RDF Stores & SPARQL Engines for Querying Knowledge Graphs. The VLDB Journal, 1-26. doi:doi.org/10.1007/s00778-021- 00711-3
- Andersen, J. L., Davoodi, A., Fagerberg, R., Flamm, C., Fontana, W., Kolčák, J., . . . Nøjgaard, N. (2024, Apr 3). Automated Inference of Graph Transformation Rules. doi:10.48550/arXiv.2404.02692
- Chornyi, A., & Dosyn Dmytro. (2025). Development of a unified output format for text parsers in the ontology construction system from text documents. Journal of Lviv Polytechnic National University "Information Systems and Networks". doi:10.23939/sisn2025.17.170
- Duval, D., Echahed, R., & Prost, F. (2020). An Algebraic Graph Transformation Approach for RDF and SPARQL. Eleventh International Workshop on Graph Computation Models (GCM 2020) (pp. 55-70). EPTCS. doi:10.4204/EPTCS.330.4
- König, H., & Stünkel , P. (2020). Single Pushout Rewriting in Comprehensive Systems. Graph Transformation. ICGT 2020. Lecture Notes in Computer Science(), vol 12150. Springer, (pp. 91-108). doi:doi.org/10.1007/978-3-030-51372-6_6
- Mennicke, S., Nagel, D., Kalo, J.-C., Aumann, N., & Balke, W.-T. (2017). Reconstructing Graph Pattern Matches Using SPARQL. Lernen, Wissen, Daten, Analysen, LWDA 2017 - Conference Proceedings (pp. 152-164). Rostock, Germany: CEUR-WS. Retrieved from https://ceur-ws.org/Vol-1917/paper24.pdf
- Mežnar, S., Bevec, M., Lavrač, N., & Škrlj, B. (2022). Ontology Completion with Graph-Based Machine Learning: A Comprehensive Evaluation. Machine Learning and Knowledge Extraction, 1107-1123. doi:doi.org/10.3390/make4040056
- Mousavi, H., Kerr, D., Iseli, M., & Zaniolo, C. (2014). Harvesting Domain Specific Ontologies from Text. International Conference on Semantic Computing. Newport Beach, CA, USA. doi:10.1109/ICSC.2014.
- Pokorný, J., Valenta, M., & Troup, M. (2018). Indexing Patterns in Graph Databases. Proceedings of the 7th International Conference on Data Science, Technology and Applications (DATA 2018) (pp. 313-321). Science and Technology Publications, Lda. doi: 10.5220/0006826903130321
- RDF 1.2 Schema. (2025, September). Retrieved from www.w3.org: https://www.w3.org/TR/rdf12-schema/
- Salehpour, M., & Davis, J. G. (2021). A Comparative Analysis of Knowledge Graph Query Performance. Third International Conference on Transdisciplinary AI (TransAI), (pp. 33-40). doi:10.1109/TransAI51903.2021.00014
- Söldner, R., & Plump, D. (2024, October 04). Formalising the double-pushout approach to graph transformation. Logical Methods in Computer Science, 3:1–3:37. doi:10.46298/LMCS-20(4:3)2024
- Stünkel, P., & König, H. (2021). Single pushout rewriting in comprehensive systems of graph-like structures. Theoretical Computer Science, 23-43. doi:doi.org/10.1016/j.tcs.2021.07.002