コード例 #1
0
    def _convert_row_to_post(self, row):
        post = Post()

        claim_id = unicode(row['claim_id'])
        title = unicode(row['title'], errors='replace')
        post.content = title

        description = unicode(row['description'], errors='replace')
        post.description = description

        url = unicode(row['url'])
        post.url = url

        publication_date = row['publication_date']
        post.date = date(publication_date)

        post_guid = compute_post_guid(self._social_network_url, claim_id, publication_date)
        post.guid = post_guid
        post.post_id = post_guid
        post.domain = self._domain
        post.author = self._author_name
        author_guid = compute_author_guid_by_author_name(self._author_name)
        post.author_guid = author_guid
        post.post_osn_guid = post_guid

        keywords = unicode(row['keywords'])
        post.tags = keywords

        post_type = unicode(row['post_type'])
        post.post_type = post_type

        return post
コード例 #2
0
    def _parse_post(self, json_content):
        post = Post()
        content = json_content['postText'][0]
        post.content = content

        str_post_timestamp = json_content["postTimestamp"]
        post.created_at = str(str_post_timestamp)

        # post_timestamp = dateutil.parser.parse(str_post_timestamp)
        # str_post_date = date_to_str(post_timestamp)

        post_timestamp, str_post_date = self._get_str_and_date_formats(
            str_post_timestamp)
        post.date = post_timestamp

        post_media = json_content["postMedia"]
        if len(post_media) > 0:
            post.media_path = post_media[0]
        else:
            post.media_path = None

        post_id = json_content["id"]
        post.post_id = post_id

        post.author = post_id

        post_guid = compute_post_guid(self._social_network_url, post_id,
                                      str_post_date)
        post.guid = post_guid
        post.domain = self._domain
        post.author_guid = post_guid
        post.post_osn_guid = post_guid
        return post
コード例 #3
0
    def _create_post_by_row(self, record_dict):

        post = Post()

        post_id = self._convert_to_unicode_value(record_dict["post_id"])
        post.post_osn_id = post_id
        post.post_id = post_id

        author_name = self._convert_to_unicode_value(record_dict["tumblog_id"])
        post.author = author_name

        post_short_url = self._convert_to_unicode_value(
            record_dict["post_short_url"])
        self._set_post_url(post_short_url, author_name, post)

        post_creation_date = self._convert_to_unicode_value(
            record_dict["created_time_epoch"])
        post.created_at = post_creation_date
        if post_creation_date is not None:
            post_formatted_creation_date, str_post_formatted_creation_date = convert_epoch_timestamp_to_datetime(
                post_creation_date)
            post.date = post_formatted_creation_date
        else:
            str_post_formatted_creation_date = self._set_start_date()

        post.guid = compute_post_guid(post.url, author_name,
                                      str_post_formatted_creation_date)
        post.post_osn_guid = post.guid

        post.title = self._convert_to_unicode_value(record_dict["post_title"])

        post_content = record_dict["post_content"]
        if post_content != 'NULL':
            content = json.loads(post_content.decode("utf-8"))
            #content = eval(record_dict["post_content"])
            final_content = ""
            if 'title' in content.keys():
                title = content['title']
                final_content += title
            if 'text' in content.keys():
                text = content['text']
                final_content += text
            post.content = self._convert_to_unicode_value(final_content)
        post.domain = self._domain
        post.author_guid = compute_author_guid_by_author_name(author_name)
        post.post_type = self._convert_to_unicode_value(
            record_dict["post_type"])
        post.post_format = self._convert_to_unicode_value(
            record_dict["post_format"])
        post.reblog_key = self._convert_to_unicode_value(
            record_dict["post_reblog_key"])
        post.tags = self._convert_to_unicode_value(record_dict["post_tags"])
        post.state = self._convert_to_unicode_value(record_dict["post_state"])

        if post.post_osn_id not in self._post_dict:
            self._post_dict[post.post_osn_id] = post

        return post
コード例 #4
0
def convert_claim_to_post(claim):
    from DB.schema_definition import Post
    post = Post()
    post.post_id = claim.claim_id
    post.content = claim.title
    post.description = claim.description
    post.url = claim.url
    post.date = claim.verdict_date
    post.domain = 'Claim'
    post.author = 'no author'
    post.author_guid = 'no author'
    post.guid = compute_post_guid(claim.url, post.author,
                                  date_to_str(post.date))
    post.post_osn_guid = post.guid
    post.tags = claim.keywords
    post.post_type = claim.verdict
    return post
    def _create_post(self, original_liar_dataset_id, speaker, targeted_label,
                     statement):
        post = Post()

        post.post_id = str(original_liar_dataset_id)

        post_guid = compute_post_guid(self._social_network_url,
                                      original_liar_dataset_id,
                                      '2007-01-01 00:00:00')
        post.guid = post_guid
        post.domain = self._domain
        post.author = speaker
        author_guid = compute_author_guid_by_author_name(speaker)
        post.author_guid = author_guid
        post.post_osn_guid = post_guid
        post.date = date('2007-01-01 00:00:00')
        post.post_type = targeted_label

        post.content = statement

        return post