Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve safety of NER build #127

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gilda/grounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def __init__(
def _build_prefix_index(self):
prefix_index = defaultdict(set)
for norm_term in self.entries:
if not norm_term:
continue
parts = norm_term.split()
if not parts:
continue
prefix_index[parts[0]].add(len(parts))
self.prefix_index = dict(prefix_index)

Expand Down
2 changes: 2 additions & 0 deletions gilda/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def __init__(self, norm_text, text, db, id, entry_name, status, source,
organism=None, source_db=None, source_id=None):
if not text:
raise ValueError('Text for Term cannot be empty')
if not norm_text.strip():
raise ValueError('Normalized text for Term cannot be empty')
self.norm_text = norm_text
self.text = text
self.db = db
Expand Down
Loading