Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Machina Callida
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
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
callidus
Machina Callida
Commits
8a57d015
Commit
8a57d015
authored
Jun 03, 2020
by
Konstantin Schulz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added documentation for text complexity formula
parent
25e2bb57
Pipeline
#11857
passed with stages
in 2 minutes and 35 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
mc_backend/mcserver/app/services/textComplexityService.py
mc_backend/mcserver/app/services/textComplexityService.py
+8
-5
No files found.
mc_backend/mcserver/app/services/textComplexityService.py
View file @
8a57d015
...
...
@@ -28,24 +28,27 @@ class TextComplexityService:
@
staticmethod
def
calculate_overall_complexity
(
tc
:
TextComplexity
)
->
float
:
""" Combines all the single elements of text complexity into one measure with a scale from 0 to 100. """
# the overall scale for all the separate measures should be from 0 to 100
tc_measure_overall
:
List
[
float
]
=
[]
wcrs
:
List
[
range
]
=
TextService
.
word_count_ranges
# each range/index is separated evenly across the scale
# each range/index is separated evenly across the scale
; adjust the index so it is between 1 and 10
wcr_idx
:
int
=
next
(
i
for
i
in
range
(
len
(
wcrs
))
if
tc
.
n_w
in
wcrs
[
i
])
+
1
# the overall scale for all the separate measures should be from 0 to 100
tc_measure_overall
.
append
(
wcr_idx
/
len
(
wcrs
)
*
100
)
# need to take care of empty text (0 POS); there are 17 different POS tags overall
tc_measure_overall
.
append
((
tc
.
pos
+
1
)
*
(
100
/
16
))
scrs
:
List
[
range
]
=
TextService
.
sentence_count_ranges
# each range/index is separated evenly across the scale
# each range/index is separated evenly across the scale
; adjust the index so it is between 1 and 10
scr_idx
:
int
=
next
(
i
for
i
in
range
(
len
(
scrs
))
if
tc
.
n_w
in
scrs
[
i
])
+
1
tc_measure_overall
.
append
(
scr_idx
/
len
(
scrs
)
*
100
)
# arbitrary maximum value as a reference to calculate a percentage; input texts must not exceed it
max_w_per_sent
:
int
=
700
tc_measure_overall
.
append
(
tc
.
avg_w_per_sent
/
max_w_per_sent
*
100
)
# arbitrary maximum value as a reference to calculate a percentage; input texts must not exceed it
max_w_len
:
int
=
50
tc_measure_overall
.
append
(
tc
.
avg_w_len
/
max_w_len
*
100
)
# we do not use the punctuation count because it needs to differentiated into various categories, e.g.
# whether it represents a subclause or an enumeration; we already calculate subclauses separately
# do not use the punctuation count (tc.n_punct) because it needs to be differentiated into various categories,
# e.g. whether it represents a subclause or an enumeration; subclauses are calculated separately
# tc_measure_overall.append(tc.n_punct / tc.n_w * 100)
tc_measure_overall
.
append
(
tc
.
n_types
/
tc
.
n_w
*
100
)
tc_measure_overall
.
append
(
tc
.
lex_den
*
100
)
# all the other measures need to be normalized for text length, e.g. word/sentence/clause count
...
...
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