Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-158
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-158
2022-158
Commits
fac17323
Commit
fac17323
authored
Oct 09, 2022
by
Thushara Thiwanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATE: variable name changes
parent
0ec47db4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
21 deletions
+26
-21
backend/database.db
backend/database.db
+0
-0
backend/services/question_preprocess_service.py
backend/services/question_preprocess_service.py
+16
-15
backend/services/tokenization_service.py
backend/services/tokenization_service.py
+10
-6
No files found.
backend/database.db
View file @
fac17323
No preview for this file type
backend/services/question_preprocess_service.py
View file @
fac17323
...
...
@@ -11,15 +11,15 @@ def remove_unwanted_values(data):
return
data
# removing duplicates
def
remove_duplicates
(
data
):
return
list
(
set
(
data
))
#
#
removing duplicates
#
def remove_duplicates(data):
#
return list(set(data))
# punctuation remov
al
# punctuation remov
ing
def
remove_punctuation
(
sentence
):
text_
no_punct
=
[
token
for
token
in
sentence
if
not
token
.
is_punct
]
cleaned_sentence
=
' '
.
join
(
token
.
text
for
token
in
text_
no_punct
)
text_
without_punctuation
=
[
token
for
token
in
sentence
if
not
token
.
is_punct
]
cleaned_sentence
=
' '
.
join
(
token
.
text
for
token
in
text_
without_punctuation
)
return
cleaned_sentence
...
...
@@ -37,31 +37,32 @@ def main(scenario, assignment_type):
del
sentences
[
-
1
]
# creating required lists
n
c
=
[]
n
ouns_pronouns
=
[]
cleaned_extracted_actions
=
[]
cleaned_sentences
=
[]
splitted_actions_array
=
[]
splitted_actions_a
nd_actor_a
rray
=
[]
# looping through each sentence
for
sentence
in
sentences
:
# getting actors using nouns pronouns
res
=
get_nouns_pronouns
(
sentence
)
n
c
.
append
(
str
(
res
))
n
ouns_pronouns
.
append
(
str
(
res
))
cleaned_sentence
=
remove_punctuation
(
sentence
)
cleaned_sentences
.
append
(
cleaned_sentence
)
splitted_actions
=
split_actions
(
str
(
cleaned_sentence
))
splitted_actions_a
rray
.
append
(
splitted_actions
)
splitted_actions
_and_actor
=
split_actions
(
str
(
cleaned_sentence
))
splitted_actions_a
nd_actor_array
.
append
(
splitted_actions_and_actor
)
extracted_actions
=
get_actions
(
splitted_actions
)
extracted_actions
=
get_actions
(
splitted_actions
_and_actor
)
if
extracted_actions
is
not
None
:
cleaned_extracted_actions
.
append
(
extracted_actions
)
# remove duplicates of the actors
n
c
=
list
(
dict
.
fromkeys
(
nc
))
data
=
remove_unwanted_values
(
n
c
)
n
ouns_pronouns
=
list
(
dict
.
fromkeys
(
nouns_pronouns
))
data
=
remove_unwanted_values
(
n
ouns_pronouns
)
extracted_relationships
=
get_include_extend_relationships
(
splitted_actions_array
)
extracted_relationships
=
get_include_extend_relationships
(
splitted_actions_a
nd_actor_a
rray
)
actors_and_use_cases_array
=
identify_use_cases
(
cleaned_extracted_actions
)
if
assignment_type
==
1
:
...
...
backend/services/tokenization_service.py
View file @
fac17323
...
...
@@ -24,12 +24,14 @@ def get_nouns_pronouns(sentence):
return
token
# removing punctuations
def
remove_punctuation
(
sentence
):
text_no_punct
=
[
token
for
token
in
sentence
if
not
token
.
is_punct
]
cleaned_sentence
=
' '
.
join
(
token
.
text
for
token
in
text_no_punct
)
return
cleaned_sentence
# get actions and actors
def
split_actions
(
sentence
):
split_string
=
"should be able to "
if
split_string
in
sentence
:
...
...
@@ -37,16 +39,18 @@ def split_actions(sentence):
return
extracted_string
def
get_actions
(
splitted_action
):
# get
def
get_actions
(
splitted_action_and_actor
):
temp_array
=
[]
if
splitted_action
is
not
None
and
'|'
in
splitted_action
[
1
]:
res
=
splitted_action
[
1
]
.
split
(
' | '
)
# print('res',res)
temp_array
.
append
(
splitted_action
[
0
])
if
splitted_action
_and_actor
is
not
None
and
'|'
in
splitted_action_and_actor
[
1
]:
res
=
splitted_action
_and_actor
[
1
]
.
split
(
' | '
)
temp_array
.
append
(
splitted_action
_and_actor
[
0
])
temp_array
.
append
(
res
[
0
])
print
(
temp_array
)
return
temp_array
else
:
return
splitted_action
return
splitted_action
_and_actor
def
get_sentences
(
text
):
...
...
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