Skip to content

Commit

Permalink
Missing from last comit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmackie committed Dec 5, 2016
1 parent ce4e70a commit 0152bb0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions corpustools/corpus/classes/spontaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def __iter__(self):
for d in self.discourses.values():
yield d

def __setstate__(self,state):
self.__dict__.update(state)
self.lexicon.has_wordtokens = True
def __getstate__(self):
return self.__dict__

def __setstate__(self, state):
self.__dict__.update(state)

def add_discourse(self, discourse):
"""
Expand Down Expand Up @@ -157,6 +158,7 @@ def __init__(self, kwargs):
self.words = dict()
self.lexicon = Corpus(self.name + ' lexicon')
self.lexicon.has_wordtokens = True
self.lexicon.discourse = self

def random_word(self):
word = random.choice(list(self.words.keys()))
Expand All @@ -169,6 +171,7 @@ def attributes(self):
for a in self._attributes:
if not a.display_name in [at.display_name for at in att_list]:
att_list.append(a)
#att_list.sort()
return att_list
#return self._attributes

Expand Down Expand Up @@ -284,11 +287,12 @@ def __setstate__(self,state):
if 'wav_path' not in state:
state['wav_path'] = None
self.__dict__.update(state)

if hasattr(self,'lexicon'):
self.lexicon.has_wordtokens = True
for wt in self:
self.lexicon[str(wt.wordtype)].wordtokens.append(wt)
#wt.wordtype.wordtokens.append(wt)
# for wt in self:
# self.lexicon[str(wt.wordtype)].wordtokens.append(wt)
# wt.wordtype.wordtokens.append(wt)

def __iter__(self):
for k in sorted(self.words.keys()):
Expand Down Expand Up @@ -495,6 +499,8 @@ def __getstate__(self):
state['wavpath'] = None
return state

def __setstate__(self, state):
self.__dict__.update(state)

def __eq__(self, other):
if not isinstance(other,WordToken):
Expand Down

0 comments on commit 0152bb0

Please sign in to comment.