This repository contains the codes used in the IJGIS work, "GeoEntity-type constrained knowledge graph embedding for predicting naturallanguage spatial relations". This project model and predict Natural-language spatial relations through knowledge graph embedding and also incorporates geoentity types as a constraint to capture spatial and semantic relations more accurately
This research constructed the Spatial Relation-based Knowledge Graph (SRKG) in three steps for the follow-up experiment. In Step 1, we built geo-instances KG (G_ins) with geoentities and relation terms extracted from the Wikipedia raw texts (https://dumps.wikimedia.org/) by GPT-4, and the geospatial triplets are in the form of <geoentity A, spatial relation, geoentity B>, as shown in figure 0. The extraction results are stored in the folder ./data.
To account for the impact of geoentity types on the usage of spatial relation terms, we integrated Google Map place types (2024), GeoNames feature codes (2024), and WordNet (Fellbaum 1998) to form geo-types KG (G_type) in Step 2. In Step 3, we linked the geoentities in G_ins to their type information in G_type resulted in the creation of P_type for subsequent joint training, aiming to use G_type to influence the natural-language spatial relations inferences in G_ins.
This research jointly embed G_ins and G_type using a link prediction task for spatial relation terms through our proposed joint knowledge graph embedding framework (SR-KGE). This framework enabled us to model the non-geometric semantic attributes while considering the constraints imposed by geoentity types. In this section, we first formulate some concepts and then detail the framework and the joint training method applied in our research.
An example of a model prediction is as follows:

To set parameters and train a new model, you can run:
python run.py
To predict on a trained model, you can run:
python inference.py
https://github.com/Sujit-O/pykg2vec
https://github.com/JunhengH/joie-kdd19
https://github.com/MIRALab-USTC/KGE-HAKE