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

added .pipe() method to spaCy integration #16

Merged
merged 15 commits into from
Aug 24, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: avoid overwriting pre-existing entities #17
davidberenstein1957 committed Jul 12, 2023
commit f34f813e14bd9c84af6da4024273e671d42b21a5
6 changes: 3 additions & 3 deletions span_marker/spacy_integration.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import torch
from datasets import Dataset
from spacy.tokens import Doc
from spacy.util import minibatch
from spacy.util import minibatch, filter_spans
import types

from span_marker.modeling import SpanMarkerModel
@@ -104,7 +104,7 @@ def __call__(self, doc: Doc) -> Doc:
span.label_ = entity["label"]
outputs.append(span)

doc.set_ents(outputs)
doc.set_ents(filter_spans(list(doc.ents) + outputs))
return doc

def pipe(self, stream, batch_size=128, include_sent=None):
@@ -131,5 +131,5 @@ def pipe(self, stream, batch_size=128, include_sent=None):
span = doc[start:end]
span.label_ = entity["label"]
outputs.append(span)
doc.set_ents(outputs)
doc.set_ents(filter_spans(list(doc.ents) + outputs))
yield doc