Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Statistical_Grammar_Checker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NLP_WS_2021
Statistical_Grammar_Checker
Commits
536e4e6b
Commit
536e4e6b
authored
3 years ago
by
Heiko Raible
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
8c4cc887
Branches
Branches containing commit
No related tags found
1 merge request
!14
Upload New File
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deployment/tester.py
+66
-0
66 additions, 0 deletions
deployment/tester.py
with
66 additions
and
0 deletions
deployment/tester.py
0 → 100644
+
66
−
0
View file @
536e4e6b
import
os
import
pandas
as
pd
class
Sentence
:
def
__init__
(
self
,
text
,
incorrect
,
error_type
,
original
):
self
.
text
=
text
self
.
incorrect
=
incorrect
self
.
error_type
=
error_type
self
.
original
=
original
class
Tester
:
def
__init__
(
self
):
# load sentences_df
sentences_df
=
pd
.
read_csv
(
os
.
path
.
join
(
"
testsentences.csv
"
),
sep
=
"
;
"
)
# get subsets of sentences_df
correct_df
=
sentences_df
[
sentences_df
.
Incorrect
==
0
]
type_1_error_df
=
sentences_df
[(
sentences_df
.
Incorrect
==
1
)
&
(
sentences_df
[
"
Error type
"
]
==
1
)]
type_2_error_df
=
sentences_df
[(
sentences_df
.
Incorrect
==
1
)
&
(
sentences_df
[
"
Error type
"
]
==
2
)]
type_3_error_df
=
sentences_df
[(
sentences_df
.
Incorrect
==
1
)
&
(
sentences_df
[
"
Error type
"
]
==
3
)]
# get lists of sentence objects
self
.
correct_sentences
=
[
Sentence
(
entry
[
"
Sentence
"
],
entry
[
"
Incorrect
"
],
entry
[
"
Error type
"
],
entry
[
"
Original Sentence
"
])
for
i
,
entry
in
correct_df
.
iterrows
()]
self
.
type_1_error_sentences
=
[
Sentence
(
entry
[
"
Sentence
"
],
entry
[
"
Incorrect
"
],
entry
[
"
Error type
"
],
entry
[
"
Original Sentence
"
])
for
i
,
entry
in
type_1_error_df
.
iterrows
()]
self
.
type_2_error_sentences
=
[
Sentence
(
entry
[
"
Sentence
"
],
entry
[
"
Incorrect
"
],
entry
[
"
Error type
"
],
entry
[
"
Original Sentence
"
])
for
i
,
entry
in
type_2_error_df
.
iterrows
()]
self
.
type_3_error_sentences
=
[
Sentence
(
entry
[
"
Sentence
"
],
entry
[
"
Incorrect
"
],
entry
[
"
Error type
"
],
entry
[
"
Original Sentence
"
])
for
i
,
entry
in
type_3_error_df
.
iterrows
()]
# remember last indexes
self
.
correct_i
=
0
self
.
type_1_i
=
0
self
.
type_2_i
=
0
self
.
type_3_i
=
0
def
get_next_correct
(
self
):
res
=
None
if
self
.
correct_i
<
len
(
self
.
correct_sentences
):
res
=
self
.
correct_sentences
[
self
.
correct_i
]
self
.
correct_i
+=
1
return
res
def
get_next_type_1
(
self
):
res
=
None
if
self
.
type_1_i
<
len
(
self
.
type_1_error_sentences
):
res
=
self
.
type_1_error_sentences
[
self
.
type_1_i
]
self
.
type_1_i
+=
1
return
res
def
get_next_type_2
(
self
):
res
=
None
if
self
.
type_2_i
<
len
(
self
.
type_2_error_sentences
):
res
=
self
.
type_2_error_sentences
[
self
.
type_2_i
]
self
.
type_2_i
+=
1
return
res
def
get_next_type_3
(
self
):
res
=
None
if
self
.
type_3_i
<
len
(
self
.
type_3_error_sentences
):
res
=
self
.
type_3_error_sentences
[
self
.
type_3_i
]
self
.
type_3_i
+=
1
return
res
if
__name__
==
"
__main__
"
:
tester
=
Tester
()
print
(
tester
.
get_next_type_1
().
text
)
print
(
tester
.
get_next_type_1
().
text
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment