Skip to content

Commit

Permalink
deprecate Tree get and set node methods (#2900)
Browse files Browse the repository at this point in the history
* deprecate get and set node methods

Co-authored-by: Tom Aarsen
  • Loading branch information
12mohaned committed Dec 6, 2021
1 parent 1892214 commit ba989e5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nltk/tree/tree.py
Expand Up @@ -6,6 +6,7 @@
# Peter Ljunglöf <peter.ljunglof@gu.se>
# Nathan Bodenstab <bodenstab@cslu.ogi.edu> (tree transforms)
# Eric Kafe <kafe.eric@gmail.com> (Tree.fromlist())
# Mohaned mashaly<mohaned.mashaly12@gmail.com> (Deprecating methods)
# URL: <https://www.nltk.org/>
# For license information, see LICENSE.TXT

Expand All @@ -18,6 +19,7 @@
import sys

from nltk.grammar import Nonterminal, Production
from nltk.internals import deprecated

######################################################################
## Trees
Expand Down Expand Up @@ -200,14 +202,13 @@ def __delitem__(self, index):
# ////////////////////////////////////////////////////////////
# Basic tree operations
# ////////////////////////////////////////////////////////////

@deprecated("Use label() instead")
def _get_node(self):
"""Outdated method to access the node value; use the label() method instead."""
raise NotImplementedError("Use label() to access a node label.")

@deprecated("Use set_label() instead")
def _set_node(self, value):
"""Outdated method to set the node value; use the set_label() method instead."""
raise NotImplementedError("Use set_label() method to set a node label.")

node = property(_get_node, _set_node)

Expand Down

0 comments on commit ba989e5

Please sign in to comment.