mirror of
https://github.com/qurator-spk/sbb_ner.git
synced 2025-06-09 20:30:01 +02:00
simplify code
This commit is contained in:
parent
15d99074a9
commit
3ed5437f64
1 changed files with 5 additions and 2 deletions
|
@ -139,6 +139,9 @@ class NERTokenizer:
|
|||
|
||||
sentences = []
|
||||
for sen in sentences_tokenized:
|
||||
|
||||
sen = [tok.replace(" ", "") for tok in sen]
|
||||
|
||||
sentences.append((sen, []))
|
||||
|
||||
return sentences
|
||||
|
@ -259,7 +262,7 @@ def ner(model_id):
|
|||
|
||||
for (tokens, word_predictions), (input_sentence, _) in zip(prediction, sentences):
|
||||
|
||||
original_text = "".join(input_sentence).replace(" ", "")
|
||||
original_text = "".join(input_sentence)
|
||||
original_word_positions = \
|
||||
[pos for positions in [[idx] * len(word) for idx, word in enumerate(input_sentence)] for pos in positions]
|
||||
|
||||
|
@ -302,7 +305,7 @@ def ner(model_id):
|
|||
for output_sentence, (input_sentence, _) in zip(output, sentences):
|
||||
|
||||
try:
|
||||
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence).replace(" ", "")
|
||||
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence)
|
||||
except AssertionError:
|
||||
logger.warning('Input and output different!!! \n\n\nInput: {}\n\nOutput: {}\n'.
|
||||
format("".join(input_sentence).replace(" ", ""),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue