Skip to content

Commit 8c92951

Browse files
committed
Possibly turn off zeros via a user flag
1 parent 0aeea8b commit 8c92951

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

stanza/pipeline/coref_processor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def _set_up_model(self, config, pipeline, device):
8383

8484
self._model = model
8585

86+
# coref_use_zeros=False will turn off creating new nodes and attaching mentions to those zero nodes
87+
self._use_zeros = config.get('use_zeros', True)
88+
if isinstance(self._use_zeros, str):
89+
self._use_zeros = self._use_zeros.lower() != 'false'
90+
8691
def process(self, document):
8792
sentences = document.sentences
8893

@@ -189,8 +194,10 @@ def process(self, document):
189194
def _handle_zero_anaphora(self, document, results, sent_ids, word_pos):
190195
"""Handle zero anaphora by creating zero nodes and updating coreference clusters."""
191196
if results.zero_scores is None or results.word_clusters is None:
192-
return
193-
197+
return {}
198+
if not self._use_zeros:
199+
return {}
200+
194201
zero_scores = results.zero_scores.squeeze(-1) if results.zero_scores.dim() > 1 else results.zero_scores
195202
is_zero = []
196203

0 commit comments

Comments
 (0)