Skip to content

Commit

Permalink
Getter and setter for pos tags in Corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Jul 9, 2021
1 parent d648647 commit 07a7fe7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion orangecontrib/text/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, domain=None, X=None, Y=None, metas=None, W=None,
self._ngrams_corpus = None
self.ngram_range = (1, 1)
self.attributes = {}
self.pos_tags = None
self._pos_tags = None
from orangecontrib.text.preprocess import PreprocessorList
self.__used_preprocessor = PreprocessorList([]) # required for compute values
self._titles: Optional[np.ndarray] = None
Expand Down Expand Up @@ -448,6 +448,20 @@ def dictionary(self):
return self._base_tokens()[1]
return self._dictionary

@property
def pos_tags(self):
"""
np.ndarray: A list of lists containing POS tags. If there are no
POS tags available, return None.
"""
if self._pos_tags is None:
return None
return np.array(self._pos_tags, dtype=object)

@pos_tags.setter
def pos_tags(self, pos_tags):
self._pos_tags = pos_tags

def ngrams_iterator(self, join_with=' ', include_postags=False):
if self.pos_tags is None:
include_postags = False
Expand Down

0 comments on commit 07a7fe7

Please sign in to comment.