mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-19 20:52:23 +03:00
Use relative indices for mentions
Was using batch absolute indices to manage mentions, but extract_spans expects doc-relative ones.
This commit is contained in:
parent
3684f7fdfd
commit
4a9dc00d86
|
@ -153,7 +153,6 @@ def span_embeddings_forward(
|
||||||
get_mentions = model.attrs["get_mentions"]
|
get_mentions = model.attrs["get_mentions"]
|
||||||
max_span_width = model.attrs["max_span_width"]
|
max_span_width = model.attrs["max_span_width"]
|
||||||
mentions = ops.alloc2i(0, 2)
|
mentions = ops.alloc2i(0, 2)
|
||||||
total_length = 0
|
|
||||||
docmenlens = [] # number of mentions per doc
|
docmenlens = [] # number of mentions per doc
|
||||||
|
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
|
@ -161,8 +160,7 @@ def span_embeddings_forward(
|
||||||
docmenlens.append(len(starts))
|
docmenlens.append(len(starts))
|
||||||
cments = ops.asarray2i([starts, ends]).transpose()
|
cments = ops.asarray2i([starts, ends]).transpose()
|
||||||
|
|
||||||
mentions = xp.concatenate((mentions, cments + total_length))
|
mentions = xp.concatenate( (mentions, cments) )
|
||||||
total_length += len(doc)
|
|
||||||
|
|
||||||
# TODO support attention here
|
# TODO support attention here
|
||||||
tokvecs = xp.concatenate(tokvecs)
|
tokvecs = xp.concatenate(tokvecs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user