diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 7a2e95e4b..fb15323f5 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -28,7 +28,7 @@ from ..attrs cimport LENGTH, POS, LEMMA, TAG, DEP, HEAD, SPACY, ENT_IOB from ..attrs cimport ENT_TYPE, SENT_START from ..parts_of_speech cimport CCONJ, PUNCT, NOUN, univ_pos_t from ..util import normalize_slice -from ..compat import is_config, copy_reg, pickle +from ..compat import is_config, copy_reg, pickle, basestring_ from .. import about from .. import util from .underscore import Underscore @@ -571,7 +571,8 @@ cdef class Doc: cdef np.ndarray[attr_t, ndim=1] attr_ids cdef np.ndarray[attr_t, ndim=2] output # Handle scalar/list inputs of strings/ints for py_attr_ids - if not hasattr(py_attr_ids, '__iter__'): + if not hasattr(py_attr_ids, '__iter__') \ + and not isinstance(py_attr_ids, basestring_): py_attr_ids = [py_attr_ids] # Allow strings, e.g. 'lemma' or 'LEMMA'