Beispiel #1
0
 def _generate_post_comment_connections(self, post, comments):
     author_connections = []
     for comment in comments:
         ac = AuthorConnection()
         ac.connection_type = 'post_comment_connection'
         ac.source_author_guid = post.post_id
         ac.destination_author_guid = comment.post_id
         author_connections.append(ac)
     return author_connections
 def _add_source_id_topic_id_to_author_connections(self, arg):
     table_name = arg['source']['table_name']
     id_name = arg['source']['id']
     connection_type = '{0}.{1} to topic id'.format(table_name, id_name)
     author_connections = []
     for source_id, topic_id in self._source_id_topic_dict.items():
         ac = AuthorConnection()
         ac.source_author_guid = source_id
         ac.destination_author_guid = topic_id
         ac.connection_type = connection_type
         author_connections.append(ac)
     self._author_connections = author_connections
Beispiel #3
0
 def _add_claim_id_topic_id_to_author_connections(self):
     table_name = u'claims'
     id_name = u'claim_id'
     connection_type = u'{0}.{1} to topic id'.format(table_name, id_name)
     author_connections = []
     for source_id, topic_id in self._claim_id_topic_dict.iteritems():
         ac = AuthorConnection()
         ac.source_author_guid = source_id
         ac.destination_author_guid = topic_id
         ac.connection_type = connection_type
         author_connections.append(ac)
     self._db.add_author_connections(author_connections)
Beispiel #4
0
    def _create_connections(self, term, post):
        term_post_connection = AuthorConnection()

        term_post_connection.source_author_guid = term
        term_post_connection.destination_author_guid = post.post_id
        term_post_connection.connection_type = u"term-post"

        term_author_connection = AuthorConnection()
        term_author_connection.source_author_guid = term
        term_author_connection.destination_author_guid = post.author_guid
        term_author_connection.connection_type = u"term-author"

        return term_post_connection, term_author_connection
    def _create_post_user_mention_connections(self, entities_dict, post):
        connections = []
        post_guid = post.post_id

        user_mention_dicts = entities_dict['user_mentions']
        for user_mention_dict in user_mention_dicts:
            screen_name = user_mention_dict['screen_name']

            author_connection = AuthorConnection()
            author_connection.source_author_guid = post_guid
            author_connection.destination_author_guid = screen_name
            author_connection.connection_type = "post_user_mention_connection"

            connections.append(author_connection)
        return connections
    def _create_post_media_url_connections(self, entities_dict, post):
        connections = []
        post_guid = post.post_id

        media_dicts = entities_dict['media_url']
        for media_dict in media_dicts:
            media_url = media_dict['media_url']

            author_connection = AuthorConnection()
            author_connection.source_author_guid = post_guid
            author_connection.destination_author_guid = media_url
            author_connection.connection_type = "post_media_url_connection"

            connections.append(author_connection)
        return connections
    def _create_post_url_connections(self, entities_dict, post):
        connections = []
        post_guid = post.post_id

        url_dicts = entities_dict['urls']
        for url_dict in url_dicts:
            expanded_url = url_dict['expanded_url']

            author_connection = AuthorConnection()

            author_connection.source_author_guid = post_guid
            author_connection.destination_author_guid = expanded_url
            author_connection.connection_type = "post_url_connection"
            connections.append(author_connection)
        return connections
 def create_follow_connection(self, follow, follower_id):
     author_connection = AuthorConnection()
     author_connection.source_author_guid = compute_author_guid_by_author_name(
         follower_id)
     author_connection.destination_author_guid = compute_author_guid_by_author_name(
         follow['nsid'])
     author_connection.connection_type = 'follow'
     author_connection.weight = 1.0
     return author_connection
 def create_cascade_edge(self, follower_id, node, photo_id):
     author_connection = AuthorConnection()
     author_connection.source_author_guid = compute_author_guid_by_author_name(
         follower_id)
     author_connection.destination_author_guid = compute_author_guid_by_author_name(
         node)
     author_connection.connection_type = str(photo_id)
     author_connection.weight = 1.0
     return author_connection
Beispiel #10
0
    def create_author_connection(self, source_author_id, destination_author_id, connection_type):
        print("---create_author_connection---")
        author_connection = AuthorConnection()
        print("Author connection: source -> " + str(source_author_id) + ", dest -> " + str(destination_author_id) + ", connection type = " + connection_type)
        author_connection.source_author_osn_id = source_author_id
        author_connection.destination_author_osn_id = destination_author_id
        author_connection.connection_type = unicode(connection_type)
        author_connection.insertion_date = self._window_start

        return author_connection
 def add_graph_to_db(cls, graph):
     post = Post(post_id=str(graph.graph['name']),
                 domain='flickr',
                 post_osn_id=str(graph.graph['name']))
     post.post_type = 'labels'
     author_connections = []
     for edge in graph.edges():
         author_connections.append(
             AuthorConnection(source_author_guid=edge[0],
                              destination_author_guid=edge[1],
                              connection_type=graph.graph['name']))
     authors = []
     for node in graph.nodes():
         authors.append(
             Author(name=str(node),
                    domain=str(graph.graph['name']),
                    author_guid=str(node)))
     cls._db.addPosts([post])
     cls._db.addPosts(author_connections)
     cls._db.addPosts(authors)
Beispiel #12
0
 def _convert_page_and_user_to_connection(self, page_authors, user_author):
     """
     Method creates connection objects for given page_authors and user_author
     In the connection, the source is the user, and destination is the page. Type = 'Likes-Page'
     :return: List of connection objects
     """
     connections = []
     user_author_guid = user_author.author_guid
     for page_author in page_authors:
         connection = AuthorConnection()
         page_author_guid = page_author.author_guid
         connection.source_author_guid = user_author_guid
         connection.destination_author_guid = page_author_guid
         connection.connection_type = 'User-Likes-Page'
         now = datetime.now()
         dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
         connection.insertion_date = dt_string
         connections.append(connection)
     return connections
Beispiel #13
0
    def _convert_group_and_members_to_connections(
            self, users_id_to_name_dict, connection_type='Group-Member'):
        """
        Method creates connection objects for group in config.ini with given user_id to user_name dictionary.
        Appends all connections created to a list and returns it.
        :return: List of AuthorConnection: src = group_id, dst = member_id
        """

        connections = []
        for user_id in users_id_to_name_dict:
            connection = AuthorConnection()
            group_author_guid = self._get_guid_by_osn_id(self._group_id)
            connection.source_author_guid = group_author_guid
            user_author_osn_id = self._get_guid_by_osn_id(user_id)
            connection.destination_author_guid = user_author_osn_id
            connection.connection_type = connection_type
            now = datetime.now()
            dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
            connection.insertion_date = dt_string
            connections.append(connection)
        return connections