Skip to content

Commit acbe1f5

Browse files
committed
Init project.
1 parent bedcc9a commit acbe1f5

23 files changed

+7568
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# VGStore
2+
23
Code for "VGStore: A Multimodal Extension to SPARQL for Querying RDF Scene Graph", ISWC 2022
34

4-
WIP, coming soon.
5+
> This repo still WIP.
6+
7+
## Demonstration
8+
9+
Please refer to `README.md` in `demo` folder.
10+
11+
## RDF-VG Builder
12+
13+
Please refer to code in `rdf-vg` folder.

demo/.gitignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
.idea

demo/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# VGSTore Demo
2+
3+
## Usage
4+
5+
```bash
6+
pip3 install -r requirements.txt
7+
python3 app.py
8+
```
9+
10+
## gStore Connection Config
11+
12+
Please modify the `gStore_config` variable to connect to your gStore database.
13+
14+
## About frontend
15+
16+
```bash
17+
cd frontend
18+
```
19+
20+
Requirement: node.js, yarn.
21+
22+
Install Dependencies:
23+
24+
```bash
25+
yarn install
26+
```
27+
28+
Build frontend:
29+
30+
```bash
31+
yarn build
32+
```
33+
34+
## About Backend
35+
36+
1. Install Dependencies
37+
```bash
38+
pip3 install -r requirements.txt
39+
```
40+
41+
2. Start gStore Endpoint
42+
3. Start backend server
43+
```bash
44+
python3 app.py
45+
```
46+
47+
### Query Example
48+
49+
Example SPARQL
50+
```sparql
51+
SELECT ?img ?x ?y ?h ?w ?dog_obj WHERE {
52+
?dog_obj <hasName> "dog"^^<http://www.w3.org/2001/XMLSchema#string>.
53+
?cat_obj <hasName> "cat"^^<http://www.w3.org/2001/XMLSchema#string>.
54+
?dog_obj ?mm.sim ?cat_obj.
55+
FILTER(?mm.sim > 0.7).
56+
# img,x,y,h,w is used to render the bounding box.
57+
?img <hasObject> ?dog_obj.
58+
?dog_obj <x> ?x.
59+
?dog_obj <y> ?y.
60+
?dog_obj <height> ?h.
61+
?dog_obj <width> ?w.
62+
} ORDER BY DESC(?mm.sim) LIMIT 10
63+
```
64+
65+
Converted SPARQL
66+
```sparql
67+
SELECT ?img ?x ?y ?h ?w ?dog_obj WHERE {
68+
?dog_obj <hasName> "dog"^^<http://www.w3.org/2001/XMLSchema#string>.
69+
?img <hasObject> ?dog_obj.
70+
?dog_obj <x> ?x.
71+
?dog_obj <y> ?y.
72+
?dog_obj <height> ?h.
73+
?dog_obj <width> ?w.
74+
<Image/2391890> <hasObject> ?dog_obj.
75+
} LIMIT 10
76+
```

demo/app.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from flask import Flask, render_template, request, redirect, url_for, flash, jsonify
2+
from gstore import GstoreConnector
3+
from flask_cors import CORS
4+
5+
gStore_config = {
6+
'ip': '127.0.0.1',
7+
'port': '5001',
8+
'user': 'root',
9+
'password': '123456',
10+
'database': 'vg_v5'
11+
}
12+
gc = GstoreConnector(gStore_config['ip'], gStore_config['port'], gStore_config['user'], gStore_config['password'])
13+
14+
app = Flask(__name__, static_url_path='', static_folder='./frontend/dist/')
15+
app.config['threaded'] = True
16+
CORS(app)
17+
18+
19+
@app.route('/')
20+
def server():
21+
return app.send_static_file('index.html')
22+
23+
24+
@app.route('/query', methods=['POST'])
25+
def query():
26+
query = request.get_json()['query']
27+
return gc.query(db_name=gStore_config['database'], format='json', sparql=query)
28+
29+
30+
if __name__ == '__main__':
31+
app.run(debug=True, host='0.0.0.0')

demo/frontend/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

demo/frontend/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# topk
2+
3+
## Project setup
4+
```
5+
yarn install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
yarn serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
yarn build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
yarn lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).

demo/frontend/babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

demo/frontend/jsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "esnext",
5+
"baseUrl": "./",
6+
"moduleResolution": "node",
7+
"paths": {
8+
"@/*": [
9+
"src/*"
10+
]
11+
},
12+
"lib": [
13+
"esnext",
14+
"dom",
15+
"dom.iterable",
16+
"scripthost"
17+
]
18+
}
19+
}

demo/frontend/package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "VGStore",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"@triply/yasqe": "^4.2.20",
12+
"ant-design-vue": "^1.7.8",
13+
"axios": "^0.26.1",
14+
"core-js": "^3.8.3",
15+
"vue": "^2.6.14",
16+
"vue-json-pretty": "^1.8.2"
17+
},
18+
"devDependencies": {
19+
"@babel/core": "^7.12.16",
20+
"@babel/eslint-parser": "^7.12.16",
21+
"@vue/cli-plugin-babel": "~5.0.0",
22+
"@vue/cli-plugin-eslint": "~5.0.0",
23+
"@vue/cli-service": "~5.0.0",
24+
"eslint": "^7.32.0",
25+
"eslint-plugin-vue": "^8.0.3",
26+
"vue-template-compiler": "^2.6.14"
27+
},
28+
"eslintConfig": {
29+
"root": true,
30+
"env": {
31+
"node": true
32+
},
33+
"extends": [
34+
"plugin:vue/essential",
35+
"eslint:recommended"
36+
],
37+
"parserOptions": {
38+
"parser": "@babel/eslint-parser"
39+
},
40+
"rules": {}
41+
},
42+
"browserslist": [
43+
"> 1%",
44+
"last 2 versions",
45+
"not dead"
46+
]
47+
}

0 commit comments

Comments
 (0)