mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 04:08:09 +03:00
Merge branch 'master' of https://github.com/explosion/spaCy
This commit is contained in:
commit
5babb7d6f6
10
spacy/tests/regression/test_issue1539.py
Normal file
10
spacy/tests/regression/test_issue1539.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
'''Ensure vectors.resize() doesn't try to modify dictionary during iteration.'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from ...vectors import Vectors
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue1539():
|
||||||
|
v = Vectors(shape=(10, 10), keys=[5,3,98,100])
|
||||||
|
v.resize((100,100))
|
||||||
|
|
|
@ -261,6 +261,11 @@ cdef class Span:
|
||||||
self.start = start
|
self.start = start
|
||||||
self.end = end + 1
|
self.end = end + 1
|
||||||
|
|
||||||
|
property vocab:
|
||||||
|
"""RETURNS (Vocab): The Span's Doc's vocab."""
|
||||||
|
def __get__(self):
|
||||||
|
return self.doc.vocab
|
||||||
|
|
||||||
property sent:
|
property sent:
|
||||||
"""RETURNS (Span): The sentence span that the span is a part of."""
|
"""RETURNS (Span): The sentence span that the span is a part of."""
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
|
|
|
@ -341,19 +341,20 @@ cdef class Token:
|
||||||
|
|
||||||
property sent_start:
|
property sent_start:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
util.deprecated(
|
# Raising a deprecation warning causes errors for autocomplete
|
||||||
"Token.sent_start is now deprecated. Use Token.is_sent_start "
|
#util.deprecated(
|
||||||
"instead, which returns a boolean value or None if the answer "
|
# "Token.sent_start is now deprecated. Use Token.is_sent_start "
|
||||||
"is unknown – instead of a misleading 0 for False and 1 for "
|
# "instead, which returns a boolean value or None if the answer "
|
||||||
"True. It also fixes a quirk in the old logic that would "
|
# "is unknown – instead of a misleading 0 for False and 1 for "
|
||||||
"always set the property to 0 for the first word of the "
|
# "True. It also fixes a quirk in the old logic that would "
|
||||||
"document.")
|
# "always set the property to 0 for the first word of the "
|
||||||
|
# "document.")
|
||||||
# Handle broken backwards compatibility case: doc[0].sent_start
|
# Handle broken backwards compatibility case: doc[0].sent_start
|
||||||
# was False.
|
# was False.
|
||||||
if self.i == 0:
|
if self.i == 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return self.sent_start
|
return self.c.sent_start
|
||||||
|
|
||||||
def __set__(self, value):
|
def __set__(self, value):
|
||||||
self.is_sent_start = value
|
self.is_sent_start = value
|
||||||
|
|
|
@ -151,7 +151,7 @@ cdef class Vectors:
|
||||||
filled = {row for row in self.key2row.values()}
|
filled = {row for row in self.key2row.values()}
|
||||||
self._unset = {row for row in range(shape[0]) if row not in filled}
|
self._unset = {row for row in range(shape[0]) if row not in filled}
|
||||||
removed_items = []
|
removed_items = []
|
||||||
for key, row in self.key2row.items():
|
for key, row in list(self.key2row.items()):
|
||||||
if row >= shape[0]:
|
if row >= shape[0]:
|
||||||
self.key2row.pop(key)
|
self.key2row.pop(key)
|
||||||
removed_items.append((key, row))
|
removed_items.append((key, row))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user