Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
334a6d18
Unverified
Commit
334a6d18
authored
Nov 27, 2023
by
Yixiao Yuan
Committed by
GitHub
Nov 27, 2023
Browse files
Modify group_sub_entities in TokenClassification Pipeline to support label with "-" (#27325)
* fix group_sub_entities bug * add space
parent
59499bbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/pipelines/token_classification.py
src/transformers/pipelines/token_classification.py
+1
-1
No files found.
src/transformers/pipelines/token_classification.py
View file @
334a6d18
...
@@ -503,7 +503,7 @@ class TokenClassificationPipeline(ChunkPipeline):
...
@@ -503,7 +503,7 @@ class TokenClassificationPipeline(ChunkPipeline):
entities (`dict`): The entities predicted by the pipeline.
entities (`dict`): The entities predicted by the pipeline.
"""
"""
# Get the first entity in the entity group
# Get the first entity in the entity group
entity
=
entities
[
0
][
"entity"
].
split
(
"-"
)[
-
1
]
entity
=
entities
[
0
][
"entity"
].
split
(
"-"
,
1
)[
-
1
]
scores
=
np
.
nanmean
([
entity
[
"score"
]
for
entity
in
entities
])
scores
=
np
.
nanmean
([
entity
[
"score"
]
for
entity
in
entities
])
tokens
=
[
entity
[
"word"
]
for
entity
in
entities
]
tokens
=
[
entity
[
"word"
]
for
entity
in
entities
]
...
...
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