From 59c4f2749934bb4279b5fdf5301db709317771f2 Mon Sep 17 00:00:00 2001 From: ines Date: Tue, 10 Oct 2017 04:14:35 +0200 Subject: [PATCH] Add get, set and has methods to Underscore --- spacy/tokens/underscore.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spacy/tokens/underscore.py b/spacy/tokens/underscore.py index 0b10e7afe..6e782647b 100644 --- a/spacy/tokens/underscore.py +++ b/spacy/tokens/underscore.py @@ -37,5 +37,14 @@ class Underscore(object): else: self._doc.user_data[self._get_key(name)] = value + def set(self, name, value): + return self.__setattr__(name, value) + + def get(self, name): + return self.__getattr__(name) + + def has(self, name): + return name in self._extensions + def _get_key(self, name): return ('._.', name, self._start, self._end)