def _convert_row_to_claim(self, row): claim = Claim() # claim_id = unicode(row['claim_id']) title = unicode(row['title'], errors='replace') claim.title = title description = unicode(row['description'], errors='replace') claim.description = description url = unicode(row['url']) claim.url = url verdict_date = row['verdict_date'] claim.verdict_date = date(verdict_date) post_guid = compute_post_guid(self._social_network_url, url, verdict_date) claim.claim_id = post_guid claim.domain = self._domain keywords = unicode(row['keywords']) claim.keywords = keywords verdict = unicode(row['verdict']) claim.verdict = verdict claim.category = unicode(row['main_category']) claim.sub_category = unicode(row['secondary_category']) return claim
def _convert_row_to_claim(self, row): claim = Claim() claim_id = unicode(row['claim_id']) title = unicode(row['title'], errors='replace') claim.title = title description = unicode(row['description'], errors='replace') claim.description = description url = unicode(row['url']) claim.url = url verdict_date = row['publication_date'] claim.verdict_date = date(verdict_date) post_guid = compute_post_guid(self._social_network_url, claim_id, verdict_date) claim.claim_id = post_guid claim.domain = self._domain keywords = unicode(row['keywords']) claim.keywords = keywords verdict = unicode(row['post_type']) claim.verdict = verdict return claim
def _add_claim(self, claim_id, content, date_str, post_type=None): claim = Claim() claim.claim_id = claim_id claim.verdict = post_type claim.title = claim_id claim.description = content claim.verdict_date = convert_str_to_unicode_datetime(date_str) claim.url = "claim url" self._db.addPost(claim)
def create_claim_from_record(self, series): claim = Claim() claim.title = str(series['title']) claim.description = str(series['description']) claim.url = str(series['url']) claim.verdict_date = str_to_date(series['verdict_date']) claim.verdict = str(series['verdict']) claim.category = str(series['main_category']) claim.keywords = str(series['keywords']) claim.domain = str(series['domain']) post_guid = compute_post_guid(self._social_network_url, claim.url, date_to_str(claim.verdict_date)) claim.claim_id = post_guid return claim
def _add_claim(self, claim_id, content, date_str=u"2017-06-14 05:00:00", keywords=u"", post_type=None): claim = Claim() claim.claim_id = claim_id claim.verdict = post_type claim.title = claim_id claim.description = content claim.verdict_date = convert_str_to_unicode_datetime(date_str) claim.keywords = keywords claim.url = u"claim url" self._db.addPost(claim) self._claim_dictionary[claim.claim_id] = claim
def _create_claim(self, original_liar_dataset_id, speaker, targeted_label, statement, subject): claim = Claim() osn_id = str(original_liar_dataset_id) claim.claim_id = compute_post_guid(self._social_network_url, osn_id, '2007-01-01 00:00:00') claim.domain = 'LiarLiar' claim.description = statement claim.title = statement claim.url = '' claim.category = 'Politic' claim.sub_category = subject claim.verdict = targeted_label claim.verdict_date = str_to_date('2007-01-01 00:00:00') claim.keywords = '' return claim
def get_claim_from_article(self, article, source): claim = Claim() claim.title = article['title'] claim.description = article['description'] claim.url = article['url'] try: publish_date = str_to_date(article['publishedAt'].split('+')[0], '%Y-%m-%dT%H:%M:%SZ') except: publish_date = str_to_date(article['publishedAt'].split('+')[0], '%Y-%m-%dT%H:%M:%S') claim.verdict_date = publish_date claim.domain = article['source'].get('id', str(source)) claim.verdict = True claim.claim_id = compute_post_guid(self._social_network_url, claim.url, date_to_str(claim.verdict_date)) claim.category = str(source) return claim
def import_to_db(self, file_path): with open(file_path, 'rb') as f: data = csv.reader(f) res = [] for row in data: try: c = Claim() c.title = str(row[3]) c.claim_id = str(uuid.uuid4().__str__()) c.description = str(row[0]) c.category = str(row[4]) c.verdict = str(row[1]) c.domain= "Claim" c.verdict_date = datetime.datetime.strptime(row[6],'%d %B %Y') c.url = str(row[2]) except Exception as e: continue res.append(c) print(','.join(row)) self._db.add_claims(res)
def _convert_row_to_claim(self, claim_row): claim = Claim() claim.claim_id = compute_author_guid_by_author_name( str(claim_row['social_id'])) claim.domain = str(claim_row['site']) claim.verdict = str(claim_row['ruling_val']) claim.verdict_date = datetime.datetime.fromtimestamp( claim_row['ruling_time']) self._claims.append(claim) attribute_name = self.__class__.__name__ + "_claim_type" author_feature = BaseFeatureGenerator.create_author_feature( attribute_name, claim.claim_id, claim.verdict, self._window_start, self._window_end) self._author_features.append(author_feature) attribute_name = self.__class__.__name__ + "_claim_id" author_feature = BaseFeatureGenerator.create_author_feature( attribute_name, claim.claim_id, claim.claim_id, self._window_start, self._window_end) self._author_features.append(author_feature)
def _convert_row_to_claim(self, row): claim = Claim() claim_id = unicode(row['campaign_id']) title = unicode(row['title'], errors='replace') claim.title = title try: verdict_date = datetime.datetime.strftime( datetime.datetime.strptime(row['date'], '%d-%m-%y'), '%Y-%m-%d %H:%M:%S') except: verdict_date = getConfig().eval(self.__class__.__name__, 'default_date') claim.verdict_date = date(verdict_date) post_guid = compute_post_guid(self._social_network_url, claim_id, verdict_date) claim.claim_id = post_guid claim.domain = self._domain keywords = unicode(row['category']) claim.keywords = keywords verdict = unicode(row['campaign_class']) claim.verdict = verdict #claim.claim_topic = unicode(row['category']) return claim
def _add_claim(self, claim_id): claim = Claim() claim.claim_id = claim_id self._db.addPosts([claim])