Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emoUS-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
dsml
emoUS-public
Commits
7ae31c8b
Commit
7ae31c8b
authored
3 years ago
by
zqwerty
Browse files
Options
Downloads
Patches
Plain Diff
add load_dataset interface
parent
8962c9e0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
convlab2/__init__.py
+1
-0
1 addition, 0 deletions
convlab2/__init__.py
convlab2/util/unified_datasets_util.py
+28
-0
28 additions, 0 deletions
convlab2/util/unified_datasets_util.py
data/unified_datasets/README.md
+8
-1
8 additions, 1 deletion
data/unified_datasets/README.md
with
37 additions
and
1 deletion
convlab2/__init__.py
+
1
−
0
View file @
7ae31c8b
...
@@ -6,6 +6,7 @@ from convlab2.policy import Policy
...
@@ -6,6 +6,7 @@ from convlab2.policy import Policy
from
convlab2.nlg
import
NLG
from
convlab2.nlg
import
NLG
from
convlab2.dialog_agent
import
Agent
,
PipelineAgent
from
convlab2.dialog_agent
import
Agent
,
PipelineAgent
from
convlab2.dialog_agent
import
Session
,
BiSession
,
DealornotSession
from
convlab2.dialog_agent
import
Session
,
BiSession
,
DealornotSession
from
convlab2.util.unified_datasets_util
import
load_dataset
,
load_database
from
os.path
import
abspath
,
dirname
from
os.path
import
abspath
,
dirname
...
...
This diff is collapsed.
Click to expand it.
convlab2/util/unified_datasets_util.py
0 → 100644
+
28
−
0
View file @
7ae31c8b
from
zipfile
import
ZipFile
import
json
import
os
import
importlib
def
load_dataset
(
dataset_name
):
data_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
abspath
(
__file__
),
f
'
../../../data/unified_datasets/
{
dataset_name
}
'
))
archive
=
ZipFile
(
os
.
path
.
join
(
data_dir
,
'
data.zip
'
))
with
archive
.
open
(
'
data/dialogues.json
'
)
as
f
:
dialogues
=
json
.
loads
(
f
.
read
())
with
archive
.
open
(
'
data/ontology.json
'
)
as
f
:
ontology
=
json
.
loads
(
f
.
read
())
return
dialogues
,
ontology
def
load_database
(
dataset_name
):
data_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
abspath
(
__file__
),
f
'
../../../data/unified_datasets/
{
dataset_name
}
'
))
cwd
=
os
.
getcwd
()
os
.
chdir
(
data_dir
)
Database
=
importlib
.
import_module
(
'
database
'
).
Database
os
.
chdir
(
cwd
)
database
=
Database
()
return
database
if
__name__
==
"
__main__
"
:
dialogues
,
ontology
=
load_dataset
(
'
multiwoz21
'
)
database
=
load_database
(
'
multiwoz21
'
)
res
=
database
.
query
(
"
train
"
,
[[
'
departure
'
,
'
cambridge
'
],
[
'
destination
'
,
'
peterborough
'
],
[
'
day
'
,
'
tuesday
'
],
[
'
arrive by
'
,
'
11:15
'
]],
topk
=
3
)
print
(
res
[
0
],
len
(
res
))
This diff is collapsed.
Click to expand it.
data/unified_datasets/README.md
+
8
−
1
View file @
7ae31c8b
# Unified data format
# Unified data format
## Overview
## Overview
We transform different datasets into a unified format under
`data/unified_datasets`
directory.
We transform different datasets into a unified format under
`data/unified_datasets`
directory. To import a unified datasets:
```
python
from
convlab2
import
load_dataset
,
load_database
dialogues
,
ontology
=
load_dataset
(
'
multiwoz21
'
)
database
=
load_database
(
'
multiwoz21
'
)
```
Each dataset contains at least these files:
Each dataset contains at least these files:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment