Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nlp
ahisto-modules
Named Entity Recognition Experiments
Commits
1046301d
Commit
1046301d
authored
Aug 15, 2022
by
Vít Novotný
Browse files
Train using NER tags in BIO format
parent
16f1e88d
Pipeline
#146493
passed with stage
in 8 minutes and 41 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ahisto_named_entity_search/recognition/model.py
View file @
1046301d
...
...
@@ -65,7 +65,7 @@ class NerModel:
ner_texts
,
all_ner_tags
=
[],
[]
for
tagged_sentence
in
TaggedSentence
.
load
(
tagged_sentence_basename
):
ner_texts
.
append
(
tagged_sentence
.
sentence
)
all_ner_tags
.
append
(
tagged_sentence
.
ner_tags
)
all_ner_tags
.
append
(
tagged_sentence
.
bio_
ner_tags
)
return
ner_texts
,
all_ner_tags
ner_training_texts
,
ner_training_labels
=
load_ner_dataset
(
training_tagged_sentence_basename
)
...
...
ahisto_named_entity_search/search/result.py
View file @
1046301d
...
...
@@ -64,6 +64,23 @@ class TaggedSentence:
ner_tags
=
' '
.
join
(
self
.
ner_tags_tuple
)
return
ner_tags
@
property
def
bio_ner_tags
(
self
)
->
NerTags
:
previous_ner_tag
=
None
bio_ner_tags_list
=
[]
for
ner_tag
in
self
.
ner_tags_tuple
:
if
ner_tag
==
'O'
:
bio_ner_tag
=
ner_tag
else
:
if
previous_ner_tag
is
None
or
ner_tag
!=
previous_ner_tag
:
bio_ner_tag
=
f
'B-
{
ner_tag
}
'
else
:
bio_ner_tag
=
f
'I-
{
ner_tag
}
'
bio_ner_tags_list
.
append
(
bio_ner_tag
)
previous_ner_tag
=
ner_tag
bio_ner_tags
=
' '
.
join
(
bio_ner_tags_list
)
return
bio_ner_tags
@
classmethod
def
save
(
cls
,
basename
:
str
,
tagged_sentences
:
Iterable
[
'TaggedSentence'
])
->
None
:
sentences_filename
=
cls
.
_get_sentences_filename
(
basename
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment