Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nerval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Named Entity Recognition
nerval
Commits
e5bf32a6
Commit
e5bf32a6
authored
1 year ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Use csv.DictReader rather than csv.reader
parent
525c1a9e
No related branches found
No related tags found
No related merge requests found
Pipeline
#150430
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demo/mapping_file.csv
+1
-0
1 addition, 0 deletions
demo/mapping_file.csv
nerval/evaluate.py
+11
-5
11 additions, 5 deletions
nerval/evaluate.py
with
12 additions
and
5 deletions
demo/mapping_file.csv
+
1
−
0
View file @
e5bf32a6
Annotation,Prediction
demo_annot.bio,demo_predict.bio
toy_test_annot.bio,toy_test_predict.bio
\ No newline at end of file
This diff is collapsed.
Click to expand it.
nerval/evaluate.py
+
11
−
5
View file @
e5bf32a6
import
csv
import
logging
from
csv
import
reader
from
pathlib
import
Path
from
typing
import
List
...
...
@@ -19,6 +19,10 @@ from nerval.utils import print_result_compact, print_results
logger
=
logging
.
getLogger
(
__name__
)
ANNO_COLUMN
=
"
Annotation
"
PRED_COLUMN
=
"
Prediction
"
CSV_HEADER
=
[
ANNO_COLUMN
,
PRED_COLUMN
]
def
compute_matches
(
annotation
:
str
,
...
...
@@ -346,7 +350,7 @@ def run_multiple(file_csv: Path, folder: Path, threshold: int, verbose: bool):
"""
Run the program for multiple files (correlation indicated in the csv file)
"""
# Read the csv in a list
with
file_csv
.
open
()
as
read_obj
:
csv_reader
=
r
eader
(
read_obj
)
csv_reader
=
csv
.
DictR
eader
(
read_obj
,
fieldnames
=
CSV_HEADER
)
list_cor
=
list
(
csv_reader
)
if
folder
.
is_dir
():
...
...
@@ -361,10 +365,10 @@ def run_multiple(file_csv: Path, folder: Path, threshold: int, verbose: bool):
predict
=
None
for
file
in
list_bio_file
:
if
row
[
0
]
==
file
.
name
:
if
row
[
ANNO_COLUMN
]
==
file
.
name
:
annot
=
file
for
file
in
list_bio_file
:
if
row
[
1
]
==
file
.
name
:
if
row
[
PRED_COLUMN
]
==
file
.
name
:
predict
=
file
if
annot
and
predict
:
...
...
@@ -374,7 +378,9 @@ def run_multiple(file_csv: Path, folder: Path, threshold: int, verbose: bool):
recall
+=
scores
[
"
All
"
][
"
R
"
]
f1
+=
scores
[
"
All
"
][
"
F1
"
]
else
:
raise
Exception
(
f
"
No file found for files
{
row
[
0
]
}
,
{
row
[
1
]
}
"
)
raise
Exception
(
f
"
No file found for files
{
row
[
ANNO_COLUMN
]
}
,
{
row
[
PRED_COLUMN
]
}
"
)
if
count
:
logger
.
info
(
"
Average score on all corpus
"
)
table
=
PrettyTable
()
...
...
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