Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Requirement Formalization Tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thodoris Nestoridis
Requirement Formalization Tool
Commits
fe2267a1
Commit
fe2267a1
authored
Oct 01, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefix [Backend - Frontend] - Get syntax/verbs
parent
4d94a6cf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
25 deletions
+174
-25
Autonomy_v1.ttl
reqtool/Ontologies/Autonomy_v1.ttl
+16
-0
add-boilerplate.component.ts
...p/components/add-boilerplate/add-boilerplate.component.ts
+3
-0
boilerplate-details.component.ts
...ents/boilerplate-details/boilerplate-details.component.ts
+3
-0
boilerplate-list.component.ts
...components/boilerplate-list/boilerplate-list.component.ts
+5
-5
requirements.py
...ool/reqman/api/reqman/apps/reqtool/models/requirements.py
+8
-4
inference.py
...an/api/reqman/apps/reqtool/rest_api/services/inference.py
+32
-0
parse_ontologies.py
...reqman/apps/reqtool/rest_api/services/parse_ontologies.py
+97
-10
requirements_views.py
.../reqman/apps/reqtool/rest_api/views/requirements_views.py
+10
-6
No files found.
reqtool/Ontologies/Autonomy_v1.ttl
View file @
fe2267a1
...
...
@@ -2951,7 +2951,23 @@ RBO:P3
a
owl:
Class
;
rdfs:
comment
"As long as <time period>"
;
rdfs:
subClassOf
RBO:
SimplePrefix
;
rdfs:
subClassOf
[
a
owl:
Restriction
;
owl:
allValuesFrom
RBO:
OccuringFunctionality
;
owl:
onProperty
RBO:
isRelatedToPlaceholder
;
]
;
rdfs:
subClassOf
[
a
owl:
Restriction
;
owl:
cardinality
"1"
^^
xsd:
nonNegativeInteger
;
owl:
onProperty
RBO:
isRelatedToOccuringFunctionality
;
]
;
rdfs:
subClassOf
[
a
owl:
Restriction
;
owl:
cardinality
"1"
^^
xsd:
nonNegativeInteger
;
owl:
onProperty
RBO:
isRelatedToPlaceholder
;
]
;
.
RBO:
PerformOccuringFunctionality
a
owl:
Class
;
rdfs:
comment
"<system> performs <function>"
;
...
...
reqtool/ReqmanAngular11/src/app/components/add-boilerplate/add-boilerplate.component.ts
View file @
fe2267a1
...
...
@@ -39,6 +39,9 @@ export class AddBoilerplateComponent implements OnInit {
has_main
:
this
.
boilerplate
.
has_main
,
has_suffix
:
this
.
boilerplate
.
has_suffix
};
if
(
data
.
title
!=
""
)
{
data
.
title
=
data
.
title
?.
replace
(
/
[^\w\s]
/gi
,
' '
)
data
.
title
=
data
.
title
?.
replace
(
/ /g
,
"_"
)}
this
.
boilerplatelService
.
create
(
this
.
route
.
snapshot
.
params
.
gb
,
data
)
.
subscribe
(
...
...
reqtool/ReqmanAngular11/src/app/components/boilerplate-details/boilerplate-details.component.ts
View file @
fe2267a1
...
...
@@ -68,6 +68,9 @@ export class BoilerplateDetailsComponent implements OnInit {
}
updateBoilerplate
():
any
{
if
(
this
.
currentboilerplate
.
title
!=
""
)
{
this
.
currentboilerplate
.
title
=
this
.
currentboilerplate
.
title
?.
replace
(
/
[^\w\s]
/gi
,
' '
)
this
.
currentboilerplate
.
title
=
this
.
currentboilerplate
.
title
?.
replace
(
/ /g
,
"_"
)}
this
.
boilerplateService
.
update
(
this
.
route
.
snapshot
.
params
.
gb
,
this
.
currentboilerplate
.
id
,
this
.
currentboilerplate
)
.
subscribe
(
...
...
reqtool/ReqmanAngular11/src/app/components/boilerplate-list/boilerplate-list.component.ts
View file @
fe2267a1
...
...
@@ -33,11 +33,11 @@ export class BoilerplateListComponent implements OnInit {
type
:
'pie'
,
radius
:
[
'40%'
,
'70%'
],
data
:
[
{
value
:
1048
,
name
:
'1'
},
{
value
:
735
,
name
:
'2'
},
{
value
:
58
0
,
name
:
'3'
},
{
value
:
484
,
name
:
'4'
},
{
value
:
30
0
,
name
:
'5'
}
]
{
value
:
0
,
name
:
'1'
},
{
value
:
0
,
name
:
'2'
},
{
value
:
0
,
name
:
'3'
},
{
value
:
0
,
name
:
'4'
},
{
value
:
0
,
name
:
'5'
}
]
},
],
};
...
...
reqtool/reqman/api/reqman/apps/reqtool/models/requirements.py
View file @
fe2267a1
...
...
@@ -8,8 +8,10 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
from
pygments.formatters.html
import
HtmlFormatter
from
pygments
import
highlight
#get prefix syntax from the Onotlogy
get_prefix_syntax
()
#get prefix syntax from the Onotlogy#
#print(get_prefix_new_syntax())
PREFIX_SYNTAX
=
get_prefix_syntax
()
SIMPLE_PREFIX_CHOICES
=
(
(
""
,
""
),
(
"P1"
,
"If/Unless <logical expression>"
),
...
...
@@ -27,7 +29,9 @@ LOGICAL_EXPRESSION = ( ("",""),
(
"occuring functionality"
,
"occuring functionality"
)
)
VERB_CHOICES
=
get_verb_instances
(
"LO#Verb"
)
VERB_CHOICES_PREFIX
=
get_prefix_verbs
()
#Must read this info from the Ontology
PREFIX_CHOICES
=
(
(
"If"
,
"If"
),
(
"Unless"
,
"Unless"
),
...
...
@@ -142,7 +146,7 @@ class Prefix(models.Model):
prefix
=
models
.
CharField
(
choices
=
PREFIX_CHOICES
,
max_length
=
100
)
#state value constraint
system_fun_item
=
models
.
CharField
(
choices
=
(
ITEM_CHOICES
+
SYSTEM_CHOICES
+
FUNCTION_CHOICES
),
max_length
=
100
)
state_or_verb
=
models
.
CharField
(
choices
=
STATE_CHOICES
+
VERB_CHOICES
,
max_length
=
100
)
state_or_verb
=
models
.
CharField
(
choices
=
STATE_CHOICES
+
VERB_CHOICES
_PREFIX
,
max_length
=
100
)
#state_value = models.CharField(choices=STATE_VALUE_CHOICES, max_length=100, blank=True)
#occuring functionality
#sys_fun = models.CharField(choices=, max_length=100, blank=True)
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/services/inference.py
View file @
fe2267a1
...
...
@@ -10,9 +10,13 @@ Ontology_file = "../../Ontologies/Autonomy_v1.ttl"
list_of_inference_metrics
=
[
"IncompleteRequirement"
,
"AmbiguousRequirement"
,
"InconsistentRequirement"
,
"NoisyRequirement"
,
"OpaqueRequirement"
,
"RedundantRequirement"
]
prefix_syntax
=
get_prefix_syntax
()
main_syntax
=
get_main_sytax_inference
()
def
getclassofprefix
(
prefix
):
return
(
findclassofprefix
(
prefix
))
def
getclassofmain
(
main
):
return
(
findclassofmain
(
main
))
...
...
@@ -126,6 +130,34 @@ def shacl(ontotlogy_file):
print
(
metrics_dict
)
return
(
metrics_dict
)
'''Find if the Prefix exists in syntax'''
def
findclassofprefix
(
listofprefix
):
classlist
=
[]
currentverb
=
listofprefix
[
'state_or_verb'
]
.
rsplit
(
' : '
,
1
)
currentsubject
=
listofprefix
[
'system_fun_item'
]
currentattr
=
listofprefix
[
'item_function_flow_statevalue'
]
for
prefix
in
prefix_syntax
:
for
inprefix
in
prefix_syntax
[
prefix
]:
if
currentverb
[
1
]
in
prefix_syntax
[
prefix
][
inprefix
]:
if
currentsubject
.
split
(
":"
)[
0
]
.
strip
()
in
prefix_syntax
[
prefix
][
inprefix
.
split
(
"_"
)[
0
]
+
"_Subject"
]:
if
currentattr
.
split
(
":"
)[
0
]
.
strip
()
in
prefix_syntax
[
prefix
][
inprefix
.
split
(
"_"
)[
0
]
+
"_Attribute"
]:
if
listofprefix
[
'prefix'
]
==
"If"
:
return
"P1"
if
listofprefix
[
'prefix'
]
==
"As soon as"
:
return
"P2"
if
listofprefix
[
'prefix'
]
==
"As long as"
:
return
"P3"
if
listofprefix
[
'prefix'
]
==
"Once"
:
return
"P1"
if
listofprefix
[
'prefix'
]
==
"Unless"
:
return
"P1"
return
(
prefix
)
classlist
.
append
(
"ERROR"
)
return
classlist
'''Find if the Main exists in syntax'''
def
findclassofmain
(
listofmain
):
classlist
=
[]
for
i
in
range
(
len
(
main_syntax
)):
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/services/parse_ontologies.py
View file @
fe2267a1
...
...
@@ -547,11 +547,14 @@ def get_prefix_syntax():
prefix_list
.
extend
(
get_instances_list
(
prefix
))
for
prefix
in
prefix_list
:
prefix_dict
[
prefix
]
=
{}
prefix_dict
[
prefix
][
"Verbs"
]
=
[]
#prefix_dict[prefix]["Verbs"] = []
#prefix_dict[prefix]["Attribute"] = []
#prefix_dict[prefix]["Subject"] = []
bnodes_uriref
=
find_triples
(
prefix
)
subclass_data
=
[]
for
per
in
bnodes_uriref
:
tmp
=
get_instances_list
(
str
(
per
))
bnodes_uriref
.
extend
(
tmp
)
for
i
in
tmp
:
subclass_data
.
append
(
i
)
for
pre
in
subclass_data
:
...
...
@@ -574,20 +577,104 @@ def get_prefix_syntax():
isrelated
.
append
(
i
)
else
:
sub
.
append
(
i
)
for
i
in
sub
:
for
j
in
isrelated
:
if
i
in
j
:
prefix_dict
[
prefix
][
"Attribute"
]
=
i
sub
.
remove
(
i
)
if
len
(
sub
)
>
1
:
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Verbs"
]
=
[]
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
]
=
[]
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Subject"
]
=
[]
# if pre is StateValueConstraint we know that Atribute is StateValue
if
"StateValue"
in
str
(
pre
)
and
len
(
sub
)
>
1
:
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
]
.
append
(
"StateValue"
)
sub
.
remove
(
"StateValue"
)
else
:
for
i
in
sub
:
for
j
in
isrelated
:
if
i
in
j
:
if
i
not
in
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
]:
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
]
.
append
(
i
)
sub
.
remove
(
i
)
#add verbs
if
tmp_list2
:
ver
=
get_verb
(
tmp_list2
)
prefix_dict
[
prefix
][
"Verbs"
]
.
append
(
ver
)
#for i in ver:
# sub.remove(i)
prefix_dict
[
prefix
][
"Suject"
]
=
sub
if
(
len
(
ver
)
==
0
):
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Verbs"
]
.
append
(
'is'
)
else
:
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Verbs"
]
.
extend
(
ver
)
for
j
in
tmp_list2
:
if
"LO"
in
str
(
j
):
sub
.
remove
(
j
.
split
(
"#"
)[
1
])
#Subjects are everything that is not a verb or an attribute - may some erros here
for
newsub
in
sub
:
if
newsub
not
in
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Subject"
]:
if
(
len
(
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
])
==
0
and
len
(
sub
)
>=
2
):
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Attribute"
]
.
append
(
sub
[
len
(
sub
)
-
2
])
sub
.
pop
(
len
(
sub
)
-
2
)
else
:
prefix_dict
[
prefix
][
str
(
pre
)
+
"_Subject"
]
.
append
(
newsub
)
return
prefix_dict
'''Return Verb list Of Prefixes'''
def
get_prefix_verbs
():
prefix_dict
=
{}
prefix_list
=
[]
verblist
=
[]
out_list
=
[]
get_prefix
=
get_instances_list
(
"RBO#Prefix"
)
for
prefix
in
get_prefix
:
prefix_list
.
extend
(
get_instances_list
(
prefix
))
for
prefix
in
prefix_list
:
bnodes_uriref
=
find_triples
(
prefix
)
subclass_data
=
[]
for
per
in
bnodes_uriref
:
tmp
=
get_instances_list
(
str
(
per
))
bnodes_uriref
.
extend
(
tmp
)
for
i
in
tmp
:
subclass_data
.
append
(
i
)
for
pre
in
subclass_data
:
tmp_list2
=
find_triples
(
pre
)
tmp_list2
=
[
str
(
i
)
for
i
in
tmp_list2
]
#add verbs
if
tmp_list2
:
ver
=
get_verb
(
tmp_list2
)
if
(
len
(
ver
)
==
0
):
out_list
.
append
(
'Is : is'
)
verblist
.
append
(
'Is : is'
)
else
:
verblist
.
extend
(
ver
)
for
extra
in
tmp_list2
:
if
"LO"
in
str
(
extra
):
per
=
URIRef
(
extra
)
for
s
,
p
,
o
in
g
.
triples
((
None
,
RDF
.
type
,
per
)):
spl
=
s
.
split
(
"#"
)
out_list
.
append
(
extra
.
split
(
"#"
)[
1
]
+
" : "
+
str
(
spl
[
1
]))
return
tuple
((
str
(
n
),
str
(
n
))
for
n
in
(
set
(
out_list
)))
'''The new prefix syntaxt parser'''
def
get_prefix_new_syntax
():
bnodes
=
[]
prefix_list
=
[]
get_prefix
=
get_instances_list
(
"RBO#Prefix"
)
for
prefix
in
get_prefix
:
prefix_list
.
extend
(
get_instances_list
(
prefix
))
#owl:allValuesFrom
for
prefix
in
prefix_list
:
per
=
URIRef
(
"http://delab.csd.auth.gr/ontologies/2018/RBO#"
+
prefix
)
#per2 = URIRef("http://www.w3.org/2002/07/owl#allValuesFrom")
bnodes_uriref
=
find_triples
(
prefix
)
subclass_data
=
[]
#print(bnodes_uriref)
for
per
in
bnodes_uriref
:
tmp
=
get_instances_list
(
str
(
per
))
bnodes_uriref
.
extend
(
tmp
)
for
i
in
tmp
:
subclass_data
.
append
(
i
)
print
(
subclass_data
)
#
'''Find the triples of the prefix - return list.type(URIRef)'''
def
find_triples
(
prefix
):
bnodes
=
[]
...
...
reqtool/reqman/api/reqman/apps/reqtool/rest_api/views/requirements_views.py
View file @
fe2267a1
...
...
@@ -5,8 +5,8 @@ from django.http import HttpResponse, JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework.parsers
import
JSONParser
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
BoilerplateGroup
,
PREFIX_CHOICES
,
LOGIC_CONNECTIVE
,
VERB_CHOICES
from
reqman.apps.reqtool.models.requirements
import
VERB_CHOICES
,
ITEM_CHOICES
,
SYSTEM_CHOICES
,
FUNCTION_CHOICES
,
STATE_CHOICES
from
reqman.apps.reqtool.models.requirements
import
Prefix
,
Boilerplate
,
BoilerplateGroup
,
PREFIX_CHOICES
,
LOGIC_CONNECTIVE
from
reqman.apps.reqtool.models.requirements
import
VERB_CHOICES
_PREFIX
,
ITEM_CHOICES
,
SYSTEM_CHOICES
,
FUNCTION_CHOICES
,
STATE_CHOICES
from
reqman.apps.reqtool.models.requirements
import
ITEM_CHOICES
,
FLOW_CHOICES
,
FUNCTION_CHOICES
,
STATE_VALUE_CHOICES
from
reqman.apps.reqtool.models.requirements
import
BoilerplateData
,
InferenceResults
...
...
@@ -19,6 +19,7 @@ from reqman.apps.reqtool.rest_api.services import fuseki, inference
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework.exceptions
import
APIException
from
django.shortcuts
import
get_object_or_404
...
...
@@ -183,8 +184,11 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
ei_instance
=
instance
[
'item_function_flow_statevalue'
]
.
rsplit
(
':'
,
1
)
pr
=
(
instance
[
'prefix'
]
+
' '
+
es_instance
[
len
(
es_instance
)
-
1
]
+
' '
+
ev_instance
[
len
(
ev_instance
)
-
1
]
+
' '
+
ei_instance
[
len
(
ei_instance
)
-
1
])
BoilerplateData
.
objects
.
filter
(
owner_data
=
instance
[
'prefix_boilerplate'
]
.
owner
,
boilerplate_data_id
=
instance
[
'prefix_boilerplate'
])
.
update
(
prefix_data
=
pr
)
sprefix
=
self
.
simple_prefix
(
instance
[
"prefix"
])
serializer
.
save
(
simple_prefix
=
sprefix
)
prefix_choices
=
inference
.
getclassofprefix
(
instance
)
if
prefix_choices
[
0
]
==
'ERROR'
:
raise
APIException
(
"Prefix choices not in [P1-P3]"
)
else
:
serializer
.
save
(
simple_prefix
=
prefix_choices
[
0
])
#Custom actions when DELETE
...
...
@@ -255,7 +259,7 @@ class InferDetailsAPIView(RetrieveUpdateDestroyAPIView):
prefixdata
.
append
(
self
.
getprefixdata
(
id
.
boilerplate_data_id
.
id
))
maindata
.
append
(
self
.
getmaindata
(
id
.
boilerplate_data_id
.
id
))
suffixdata
.
append
(
self
.
getsuffixdata
(
id
.
boilerplate_data_id
.
id
))
metrics
=
inference
.
inferencing
(
project_title
,
boildata
,
prefixdata
,
maindata
,
suffixdata
)
metrics
,
onto_file
=
inference
.
inferencing
(
project_title
,
boildata
,
prefixdata
,
maindata
,
suffixdata
)
#print(prefix[0].boilerplate_data_id.id)
#inference.inferencing(prefix)
instance
.
update
(
inference_data
=
metrics
)
...
...
@@ -289,7 +293,7 @@ class LogConChoicesViewSet(APIView):
class
VerbChoicesViewSet
(
APIView
):
def
get
(
self
,
request
):
response
=
Response
(
STATE_CHOICES
+
VERB_CHOICES
)
response
=
Response
(
STATE_CHOICES
+
VERB_CHOICES
_PREFIX
)
return
response
class
FunItemSysChoicesViewSet
(
APIView
):
...
...
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