-
Notifications
You must be signed in to change notification settings - Fork 1
/
shared_structure.py
98 lines (85 loc) · 2.77 KB
/
shared_structure.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
"""
Module for shared structural elements
"""
from collections import namedtuple
class PostStructure():
"""Shared structure for Post Attributes
Contains attributes shared among PG DB and LBSN ProtoBuf spec.
- this could also be replaces by protobuf lbsnPost() from
lbsnstructure package
"""
def __init__(self):
self.origin_id = None
self.guid = None
self.post_latlng = None
self.place_guid = None
self.city_guid = None
self.country_guid = None
self.post_geoaccuracy = None
self.user_guid = None
self.post_create_date = None
self.post_publish_date = None
self.post_body = None
self.post_language = None
self.user_mentions = None
self.hashtags = None
self.emoji = None
self.post_like_count = None
self.post_comment_count = None
self.post_views_count = None
self.post_title = None
self.post_thumbnail_url = None
self.post_url = None
self.post_type = None
self.post_filter = None
self.post_quote_count = None
self.post_share_count = None
self.input_source = None
self.post_content_license = None
# optional:
self.latitude = None
self.longitude = None
self.loc_id = None
"""This auto-class provides a structure for fast handling
of essential post attributes for use in tag maps clustering
"""
CleanedPost = namedtuple(
'cleanedPostLocation_tuple',
'origin_id lat lng guid user_guid '
'post_create_date post_publish_date '
'post_body hashtags emoji '
'post_views_count loc_id')
class CleanedPost_():
"""Shared structure for Post Attributes
Contains only the attributes needed for tag maps.
- in correct order for CSV read/write (PostStructure.__dict__)
"""
def __init__(self):
self.origin_id = None
self.latitude = None
self.longitude = None
self.guid = None
self.place_guid = None
self.user_guid = None
self.post_create_date = None
self.post_publish_date = None
self.post_body = None
self.hashtags = None
self.emoji = None
self.post_views_count = None
self.loc_id = None
def __iter__(self):
return iter([self.origin_id,
self.latitude,
self.longitude,
self.guid,
self.place_guid,
self.user_guid,
self.post_create_date,
self.post_publish_date,
self.post_body,
self.hashtags,
self.emoji,
self.post_views_count,
self.loc_id])