This commit is contained in:
svlandeg 2019-07-11 13:09:22 +02:00
parent 0f0f07318a
commit 349107daa3
3 changed files with 2 additions and 9 deletions

View File

@ -20,8 +20,6 @@ from spacy.lang.en import English
def test_issue3869(sentence): def test_issue3869(sentence):
"""Test that the Doc's count_by function works consistently""" """Test that the Doc's count_by function works consistently"""
nlp = English() nlp = English()
print()
doc = nlp(sentence) doc = nlp(sentence)
count = 0 count = 0

View File

@ -7,7 +7,6 @@ from ..typedefs cimport attr_t
from ..attrs cimport attr_id_t from ..attrs cimport attr_id_t
cdef attr_t get_token_attr(const TokenC* token, attr_id_t feat_name) nogil cdef attr_t get_token_attr(const TokenC* token, attr_id_t feat_name) nogil

View File

@ -14,7 +14,6 @@ from collections import Counter
import numpy import numpy
import numpy.linalg import numpy.linalg
import struct import struct
from libc.stdint cimport int64_t
import srsly import srsly
from thinc.neural.util import get_array_module, copy_array from thinc.neural.util import get_array_module, copy_array
@ -712,7 +711,6 @@ cdef class Doc:
cdef int i cdef int i
cdef attr_t attr cdef attr_t attr
cdef size_t count cdef size_t count
cdef int64_t this_value
if counts is None: if counts is None:
counts = Counter() counts = Counter()
@ -722,13 +720,11 @@ cdef class Doc:
# Take this check out of the loop, for a bit of extra speed # Take this check out of the loop, for a bit of extra speed
if exclude is None: if exclude is None:
for i in range(self.length): for i in range(self.length):
this_value = get_token_attr(&self.c[i], attr_id) counts[get_token_attr(&self.c[i], attr_id)] += 1
counts[this_value] += 1
else: else:
for i in range(self.length): for i in range(self.length):
if not exclude(self[i]): if not exclude(self[i]):
attr = get_token_attr(&self.c[i], attr_id) counts[get_token_attr(&self.c[i], attr_id)] += 1
counts[attr] += 1
if output_dict: if output_dict:
return dict(counts) return dict(counts)