Skip to content

Commit

Permalink
fix(language): remove entity new line
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 25, 2024
1 parent af0b9f0 commit 84cb0ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion language/api/services/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# AGPL-3.0-only in the root of this repository.

import string
import re
from spacy.language import Language


Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion language/api/services/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit 84cb0ac

Please sign in to comment.