Skip to content

Commit

Permalink
#10 Updating Knowledge Extraction
Browse files Browse the repository at this point in the history
The Knowledge Extraction feature has been partially updated to include its usage inside sub-Templates
  • Loading branch information
Sebastiano-G committed May 10, 2024
1 parent e19f416 commit 31eb150
Show file tree
Hide file tree
Showing 8 changed files with 614 additions and 387 deletions.
13 changes: 6 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def GET(self, name):
alert=block_user, limit=limit,
is_git_auth=is_git_auth,invalid=False,
project=conf.myProject,template=None,
query_templates=None,knowledge_extractor=False)
query_templates=None,knowledge_extractor=set())

def POST(self, name):
""" Submit a new record
Expand All @@ -579,7 +579,6 @@ def POST(self, name):
the record ID (a timestamp)
"""

web.header("X-Forwarded-For", session['ip_address'])
web.header("Content-Type","text/html; charset=utf-8")
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
Expand All @@ -597,18 +596,17 @@ def POST(self, name):
u.log_output('SUBMIT INVALID FORM', session['logged_in'], session['username'],name)
return render.record(record_form=f, pageID=name, user=user, alert=block_user,
limit=limit, is_git_auth=is_git_auth,invalid=True,
project=conf.myProject,template=None,query_templates=None,knowledge_extractor=False)
project=conf.myProject,template=None,
query_templates=None,knowledge_extractor=set())
else:
recordData = web.input()
print("inputData", recordData)


# load the template selected by the user
if 'res_name' in recordData:
if recordData.res_name != 'None':
f = forms.get_form(recordData.res_name)
query_templates = u.get_query_templates(recordData.res_name)
extractor = u.has_extractor(recordData.res_name)
extractor = u.has_extractor(recordData.res_name)
return render.record(record_form=f, pageID=name, user=user, alert=block_user,
limit=limit, is_git_auth=is_git_auth,invalid=False,
project=conf.myProject,template=recordData.res_name,
Expand Down Expand Up @@ -690,7 +688,8 @@ def GET(self, name):
return render.modify(graphdata=data, pageID=recordID, record_form=f,
user=session['username'],ids_dropdown=ids_dropdown,
is_git_auth=is_git_auth,invalid=False,
project=conf.myProject,template=res_template,query_templates=query_templates,knowledge_extractor=extractor)
project=conf.myProject,template=res_template,
query_templates=query_templates,knowledge_extractor=extractor)
else:
session['logged_in'] = 'False'
raise web.seeother(prefixLocal+'/')
Expand Down
3 changes: 2 additions & 1 deletion forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def get_form(json_form, from_dict=False, subtemplate=False):
class_= classes,
value=default,
mandatory = mandatory,
subtemplate = resource_class), ) + get_form(field['import_subtemplate'], subtemplate=True)
subtemplate = resource_class,
subtemplateID = field['import_subtemplate']), ) + get_form(field['import_subtemplate'], subtemplate=True)

if subtemplate:
return params
Expand Down
79 changes: 76 additions & 3 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,10 @@ span[class^='tag Q']:hover {
margin-left: 20px;
}

input[type='checkbox'],
input[type='radio'] {
accent-color: rgb(100, 23, 180);
}

input[type='text'],
input[type='textarea'],
Expand Down Expand Up @@ -2009,14 +2013,83 @@ button#showTemplates {
font-size: 85%;
}

.import_form {
.import-form {
margin-left: 0px !important;
margin-top: 0.7em;
}

.imported_graphs {
margin-top: 0.7em;
}

.import-form + .block_field {
margin-top: 15px;
margin-left: 10px;
}

.import-form + .block_field .btn {
max-width: 35%;
float: right;
}

/* new Knowledge Extraction code */

.extraction-form-div {
width: 90%;
margin-left: 5%;
margin-right: 5%;
}

.extraction-form-div:first-of-type {
color: rgb(100, 23, 180);
border-bottom: 1px solid rgb(100, 23, 180);
margin-top: 0.5em;
}

.fa-times {
position: absolute;
right: 50px;
margin-top: 12px;
color: rgb(100, 23, 180);
font-size: 0.9em;
}

.extraction-form-label:nth-child(2) {
margin-left: 3% !important;
}

.extraction-form-label, .extraction-form-input {
width: 48% !important;
display: inline-block;
}

.block_field input[type="text"].extraction-form-input:first-of-type {
margin-left: 0px !important;
}

.block_field input[type="text"].extraction-form-input {
margin-left: 3% !important;
padding-top: 0.4em;
}

.add-parameter {
display: block;
margin-left: 5%;
margin-bottom: 1.2em;
font-size: 0.8em;
color: rgb(100, 23, 180);
cursor: pointer;
}

.extractor-comment {
width: 90%;
margin-left: 5%;
margin-bottom: 0px;
padding: 5px;
font-size: 0.9em;
border-bottom: 1px solid darkgray;
}

/* subtemplates */
.check_subtemplate {
margin-left: 1em;
Expand Down Expand Up @@ -2162,10 +2235,10 @@ input[subtemplate]+.fa-plus-circle {
#lang-form {
display: block;
position: absolute;
background: #eae2f6;
background: #ECE0FD;
width: 400px;
padding: 20px;
border: solid 1px black;
border: solid 1px rgb(100, 23, 180);
border-radius: 5px;
z-index: 1023;
}
Expand Down
Loading

0 comments on commit 31eb150

Please sign in to comment.