From 84cb0aca49d5f6cd584e0d178f4cf0e530a51df6 Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Mon, 25 Nov 2024 12:47:35 +0100 Subject: [PATCH] fix(language): remove entity new line --- language/api/services/entities.py | 3 ++- language/api/services/models.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/language/api/services/entities.py b/language/api/services/entities.py index 68e8d6fc6..95e085b7f 100644 --- a/language/api/services/entities.py +++ b/language/api/services/entities.py @@ -9,6 +9,7 @@ # AGPL-3.0-only in the root of this repository. import string +import re from spacy.language import Language @@ -42,7 +43,7 @@ def extract_entities(self, text): list: A list of entities """ return [ - {"text": ent.text, "label": ent.label_} + {"text": re.sub(r"\n+", " ", ent.text).strip(), "label": ent.label_} for doc in self.nlp.pipe([text], disable=["tagger"]) for sent in doc.sents for ent in sent.ents diff --git a/language/api/services/models.py b/language/api/services/models.py index d744efb72..767bf3863 100644 --- a/language/api/services/models.py +++ b/language/api/services/models.py @@ -32,4 +32,4 @@ nlp[key].add_pipe("sentencizer") highlighted_package = f"\033[1m{package.ljust(package_max_length)}\033[0m" - print(f"🧠 Model {highlighted_package} is ready.") + print(f"🧠 Model {highlighted_package} loaded.")