/Rel2Graph

Primary LanguageJavaScriptMIT LicenseMIT

Rel2Graph

Overview

This project implements

Quick Start

Requirements

The main requirements are:

  • Python 3.6+
  • Neo4J Community Edition

Install Dependencies

We recommend using virtual environments to run this code:

python -m virtualenv venv
source venv\bin\activate

Python packages can be installed via:

   git clone git@github.com:nlp-tlp/Rel2Graph.git

   pip install torch torchvision

   python3 -m pip install -r requirements.txt
   or 
   pip install -r requirements.txt

Download Pre-process Data

Text-to-Spider benchmarks, e.g., Spider, KaggleDBQA, and BIRD. We use the Spider and KaggleDBQA benchmarks to illustrate the process.

Take Spider as an example, firstly download the pre-processed data release, and unzip the folder. Then, put the data into rel_db2kg/data/spider.

Note: If you would like to preprocess Spider dataset by yourself, please refer to salesforce TabularSemanticParsing

Set up Environment

  1. Setting the config.ini file.

    • Create an .env file.
    GRAPH_PASSWORD=<your-neo4j-password>
    • The application that will be run, are determined in the config.ini file:
    [FILENAMES]
    root = <path-to->/Rel2Graph
    benchmark = Spider
    
    neo4j_import_folder  = <path-to->/neo4j-community-4.4.11/import>
    neo4j_uri = http://localhost:7474/browser/
    neo4j_user = neo4j
    neo4j_password = <your-neo4j-password>
    • Meanwhile, please config Neo4j export path.
    cd ConverDB.py
    

    Set _neo4j_export_path = '<path-to->/neo4j-community-4.4.11/import' in Class ConvertDB.

  2. Configure conf/db.ini file

    spider_path = <path-to->/Rel2Graph/data/spider/database
    database = musical
    
    [neo4j]
    port = 7687
    host = localhost
    username = neo4j
    password = <your-neo4j-password>
    
    
  3. Running Neo4j

    cd <path-to-neo4j-bin>
    ./neo4j start
  4. Constructing a property graph database from any arbitrary relational database schemas directly.

    cd rel_db2kg
    python schema2graph.py --<benchmark_dataset-name> --cased
    

    Translate SQL queries to Cypher queries.

    cd rel_db2kg
    python sql2cypher.py 
    
  5. Running interface

    python interface --web_ui

Citation

If you find the resource in this repository helpful, please cite

https://arxiv.org/abs/2310.01080

Contact

If you are interested in our work, please feel free to contact Ziyu Zhao Email: ziyu.zhao@research.uwa.edu.au