Commit 3d3e41b8 authored by Thomas Huetter's avatar Thomas Huetter
Browse files

db service option for statistic script

parent cbba5a23
...@@ -19,9 +19,9 @@ import psycopg2 ...@@ -19,9 +19,9 @@ import psycopg2
from psycopg2 import sql from psycopg2 import sql
# http://initd.org/psycopg/docs/sql.html#module-psycopg2.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. # Connect to database.
db = psycopg2.connect("service=ted-join") db = psycopg2.connect("service=" + service)
# Open a cursor to perform database operations # Open a cursor to perform database operations
cur = db.cursor() cur = db.cursor()
attributes = values_dict.keys() attributes = values_dict.keys()
...@@ -41,14 +41,14 @@ def store_result(table_name, values_dict): ...@@ -41,14 +41,14 @@ def store_result(table_name, values_dict):
# parse input argurments # parse input argurments
parser = argparse.ArgumentParser() 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") help="path to input files containing line seperated trees in bracket notation")
parser.add_argument("--shortdesc", type=str, default="no description", parser.add_argument("--shortdesc", type=str, default="no description",
help="short description about the dataset") help="short description about the dataset")
parser.add_argument("--printlabels", action='store_true', dest='printlabels', parser.add_argument("--printlabels", action='store_true', dest='printlabels',
help="print label distribution") help="print label distribution")
parser.add_argument("--storeindb", action='store_true', dest='storeindb', parser.add_argument('--service', type=str,
help="store the information about the dataset in a database") help="Service name for db connection. Specify this parameter to store the results in a database.")
args = parser.parse_args() args = parser.parse_args()
...@@ -99,8 +99,8 @@ dataset_info += "}" ...@@ -99,8 +99,8 @@ dataset_info += "}"
print(dataset_info) print(dataset_info)
# store dataset in db # store dataset in db
if args.storeindb: if args.service:
store_result(db_table_name, json.loads(dataset_info)) store_result(args.service, db_table_name, json.loads(dataset_info))
# print label distribution # print label distribution
if args.printlabels: if args.printlabels:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment