From 60c2695131f09ecc4f21aada71a3ccc54cd3a979 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 1 Jul 2020 22:33:39 +0200 Subject: [PATCH] Remove deprecated methods --- spacy/tokens/doc.pyx | 44 ------------------------------------------- spacy/tokens/span.pyx | 12 ------------ 2 files changed, 56 deletions(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 28590e91e..8fe922af9 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -1123,50 +1123,6 @@ cdef class Doc: remove_label_if_necessary(attributes[i]) retokenizer.merge(span, attributes[i]) - def merge(self, int start_idx, int end_idx, *args, **attributes): - """Retokenize the document, such that the span at - `doc.text[start_idx : end_idx]` is merged into a single token. If - `start_idx` and `end_idx `do not mark start and end token boundaries, - the document remains unchanged. - - start_idx (int): Character index of the start of the slice to merge. - end_idx (int): Character index after the end of the slice to merge. - **attributes: Attributes to assign to the merged token. By default, - attributes are inherited from the syntactic root of the span. - RETURNS (Token): The newly merged token, or `None` if the start and end - indices did not fall at token boundaries. - """ - cdef unicode tag, lemma, ent_type - warnings.warn(Warnings.W013.format(obj="Doc"), DeprecationWarning) - # TODO: ENT_KB_ID ? - if len(args) == 3: - warnings.warn(Warnings.W003, DeprecationWarning) - tag, lemma, ent_type = args - attributes[TAG] = tag - attributes[LEMMA] = lemma - attributes[ENT_TYPE] = ent_type - elif not args: - fix_attributes(self, attributes) - elif args: - raise ValueError(Errors.E034.format(n_args=len(args), args=repr(args), - kwargs=repr(attributes))) - remove_label_if_necessary(attributes) - attributes = intify_attrs(attributes, strings_map=self.vocab.strings) - cdef int start = token_by_start(self.c, self.length, start_idx) - if start == -1: - return None - cdef int end = token_by_end(self.c, self.length, end_idx) - if end == -1: - return None - # Currently we have the token index, we want the range-end index - end += 1 - with self.retokenize() as retokenizer: - retokenizer.merge(self[start:end], attrs=attributes) - return self[start] - - def print_tree(self, light=False, flat=False): - raise ValueError(Errors.E105) - def to_json(self, underscore=None): """Convert a Doc to JSON. The format it produces will be the new format for the `spacy train` command (not implemented yet). diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index b8f79f8a6..902d46f5a 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -280,18 +280,6 @@ cdef class Span: return array - def merge(self, *args, **attributes): - """Retokenize the document, such that the span is merged into a single - token. - - **attributes: Attributes to assign to the merged token. By default, - attributes are inherited from the syntactic root token of the span. - RETURNS (Token): The newly merged token. - """ - warnings.warn(Warnings.W013.format(obj="Span"), DeprecationWarning) - return self.doc.merge(self.start_char, self.end_char, *args, - **attributes) - def get_lca_matrix(self): """Calculates a matrix of Lowest Common Ancestors (LCA) for a given `Span`, where LCA[i, j] is the index of the lowest common ancestor among