-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.py
55 lines (48 loc) · 1.63 KB
/
post.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Post:
"""
A class for posts
"""
def __init__(self, author, sub_reddit, date, country, confidence, text, lang1, lang2, id, link_id, parent_id):
"""
:param author: str
Reddit userid
:param sub_reddit: str
subreddit of post
:param date: int
Date of the post in unix time
:param country: str
country of post, same as the subreddit
:param confidence: int
confidence of lang1 given by polyglot
:param text: str
the post body
:param lang1: str
primary language of the post
:param lang2: str
secondary language of post
:param id: str
post id given by reddit
:param link_id: str
id of the whole Post
:param parent_id: str
if the post is a reply, then this is the parent id(post replied to)
"""
self.author = author
self.sub_reddit = sub_reddit
self.text = text
self.lang1 = lang1
self.lang2 = lang2
self.date = date
self.country = country
self.confidence = confidence
self.id = id
self.link_id = link_id
self.parent_id = parent_id
def to_tuple(self):
return (self.author, self.sub_reddit, self.country, self.date, self.confidence, self.lang1,
self.lang2, self.text, self.id, self.link_id, self.parent_id)
@classmethod
def header(cls):
return (
'Author', "Subreddit", "Country", "Date", "confidence", "Lang1", "Lang2", "Text", "id", "link_id",
"parent_id")