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
c8d4cf6e
Commit
c8d4cf6e
authored
1 year ago
by
Manon Blanco
Browse files
Options
Downloads
Patches
Plain Diff
Add a message to assertion errors
parent
63851d7c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!40
Add a message to assertion errors
Pipeline
#155143
failed
1 year ago
Stage: test
Stage: release
Changes
2
Pipelines
24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nerval/evaluate.py
+7
-7
7 additions, 7 deletions
nerval/evaluate.py
nerval/parse.py
+7
-3
7 additions, 3 deletions
nerval/parse.py
with
14 additions
and
10 deletions
nerval/evaluate.py
+
7
−
7
View file @
c8d4cf6e
...
...
@@ -58,10 +58,10 @@ def compute_matches(
Output : {TAG1 : nb_entity_matched, ...}, example : {
'
All
'
: 1,
'
OCC
'
: 0,
'
PER
'
: 1}
"""
assert
annotation
assert
prediction
assert
labels_annot
assert
labels_predict
assert
annotation
,
"
Annotation is empty
"
assert
prediction
,
"
Prediction is empty
"
assert
labels_annot
,
"
Annotation labels are empty
"
assert
labels_predict
,
"
Prediction labels are empty
"
entity_count
=
{
"
All
"
:
0
}
last_tag
=
NOT_ENTITY_TAG
...
...
@@ -190,9 +190,9 @@ def get_labels_aligned(original: str, aligned: str, labels_original: list) -> li
Output format :
list of strings
"""
assert
original
assert
aligned
assert
labels_original
assert
original
,
"
Original is empty
"
assert
aligned
,
"
Aligned is empty
"
assert
labels_original
,
"
Original labels are empty
"
labels_aligned
=
[]
index_original
=
0
...
...
This diff is collapsed.
Click to expand it.
nerval/parse.py
+
7
−
3
View file @
c8d4cf6e
...
...
@@ -42,7 +42,7 @@ def parse_line(index: int, line: str):
try
:
match_iob
=
REGEX_IOB_LINE
.
search
(
line
)
assert
match_iob
assert
match_iob
,
f
"
Line
{
line
}
does not match IOB regex
"
return
match_iob
.
group
(
1
,
2
)
except
AssertionError
:
...
...
@@ -149,10 +149,14 @@ def parse_bio(lines: List[str]) -> dict:
result
[
"
labels
"
]
=
labels
result
[
"
entity_count
"
]
=
entity_count
assert
len
(
result
[
"
words
"
])
==
len
(
result
[
"
labels
"
])
assert
len
(
result
[
"
words
"
])
==
len
(
result
[
"
labels
"
]
),
f
'
Found
{
len
(
result
[
"
words
"
])
}
word(s) for
{
len
(
result
[
"
labels
"
])
}
label(s)
'
for
tag
in
result
[
"
entity_count
"
]:
if
tag
!=
"
All
"
:
assert
result
[
"
labels
"
].
count
(
f
"
B-
{
tag
}
"
)
==
result
[
"
entity_count
"
][
tag
]
assert
(
result
[
"
labels
"
].
count
(
f
"
B-
{
tag
}
"
)
==
result
[
"
entity_count
"
][
tag
]
),
f
'
Found
{
result
[
"
entity_count
"
][
tag
]
}
entities for
{
result
[
"
labels
"
].
count
(
f
"
B-
{
tag
}
"
)
}
label(s) for entity
{
tag
}
'
return
result
...
...
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