forked from brendano/tweetmotif
/
common.py
32 lines (26 loc) · 841 Bytes
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# data structures that need to be shared with the frontend
# actually the theory behind this isnt working - pickle.loads drags in other modules anyways.
# maybe this is now a "datastructures" file.
import util
class TweetGroup:
def __init__(self,**kwargs):
self.__dict__.update(kwargs)
class TopicResults:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
class Topic:
def __init__(self, **kwargs):
self.groups = self.ngram = self._label_ngrams = None
self.__dict__.update(kwargs)
assert self.ngram
self.label_set = set([self.ngram])
@property
def label_ngrams(self):
assert self._label_ngrams or self.ngram
return self._label_ngrams or (self.ngram,)
@property
def group_count(self):
return len(self.group_ids)
@property
def tweet_count(self):
return len(self.tweets)