コード例 #1
0
ファイル: thesaurus_loader.py プロジェクト: jt86/DiscoUtils
    def __delitem__(self, key):
        """
        Deletes key from the list of entries in the thesaurus and the matrix
        :param key:
        :type key:
        :return:
        :rtype:
        """
        if isinstance(key, DocumentFeature):
            item = DocumentFeature.tokens_as_str(key)

        del self._obj[key]
        if hasattr(self, 'matrix'):
            mask = np.ones(self.matrix.shape[0], dtype=bool)
            mask[self.name2row[key]] = False
            self.matrix = self.matrix[mask, :]
コード例 #2
0
ファイル: thesaurus_loader.py プロジェクト: jt86/DiscoUtils
 def __contains__(self, item):
     if isinstance(item, DocumentFeature):
         item = DocumentFeature.tokens_as_str(item)
     return item in self._obj
コード例 #3
0
ファイル: thesaurus_loader.py プロジェクト: jt86/DiscoUtils
 def __getitem__(self, item):
     if isinstance(item, DocumentFeature):
         item = DocumentFeature.tokens_as_str(item)
     return self._obj[item]
コード例 #4
0
ファイル: thesaurus_loader.py プロジェクト: jt86/DiscoUtils
 def __setitem__(self, key, value):
     if self.immutable:
         raise ValueError('This object is immutable')
     if isinstance(key, DocumentFeature):
         key = DocumentFeature.tokens_as_str(key)
     self._obj[key] = value