Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Mateusz Pawlik
ted-datasets
Commits
3d3e41b8
Commit
3d3e41b8
authored
Oct 30, 2018
by
Thomas Huetter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db service option for statistic script
parent
cbba5a23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
statistics/statistics.py
statistics/statistics.py
+7
-7
No files found.
statistics/statistics.py
View file @
3d3e41b8
...
...
@@ -19,9 +19,9 @@ import psycopg2
from
psycopg2
import
sql
# http://initd.org/psycopg/docs/sql.html#module-psycopg2.sql
def
store_result
(
table_name
,
values_dict
):
def
store_result
(
service
,
table_name
,
values_dict
):
# Connect to database.
db
=
psycopg2
.
connect
(
"service=
ted-join"
)
db
=
psycopg2
.
connect
(
"service=
"
+
service
)
# Open a cursor to perform database operations
cur
=
db
.
cursor
()
attributes
=
values_dict
.
keys
()
...
...
@@ -41,14 +41,14 @@ def store_result(table_name, values_dict):
# parse input argurments
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--inputfile"
,
type
=
str
,
parser
.
add_argument
(
"--inputfile"
,
type
=
str
,
required
=
True
,
help
=
"path to input files containing line seperated trees in bracket notation"
)
parser
.
add_argument
(
"--shortdesc"
,
type
=
str
,
default
=
"no description"
,
help
=
"short description about the dataset"
)
parser
.
add_argument
(
"--printlabels"
,
action
=
'store_true'
,
dest
=
'printlabels'
,
help
=
"print label distribution"
)
parser
.
add_argument
(
"
--s
toreindb"
,
action
=
'store_true'
,
dest
=
'storeindb'
,
help
=
"
store the information about the dataset
in a database"
)
parser
.
add_argument
(
'
--s
ervice'
,
type
=
str
,
help
=
"
Service name for db connection. Specify this parameter to store the results
in a database
.
"
)
args
=
parser
.
parse_args
()
...
...
@@ -99,8 +99,8 @@ dataset_info += "}"
print
(
dataset_info
)
# store dataset in db
if
args
.
s
toreindb
:
store_result
(
db_table_name
,
json
.
loads
(
dataset_info
))
if
args
.
s
ervice
:
store_result
(
args
.
service
,
db_table_name
,
json
.
loads
(
dataset_info
))
# print label distribution
if
args
.
printlabels
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment