class FeatureCollection(object): def __init__(self,geodatabase_path,ianadatabase_path,wfbdatabase_path): self.ip_location_extraction = IPLocationExtraction(geodatabase_path) self.tld_location_extraction = TLDLocationExtraction(ianadatabase_path, wfbdatabase_path) self.website_language_extraction = WebsiteLanguageExtraction() def get_features(self, article_name, url): #generate json from article_name and url article_url_dictionary = {} urls = [] urls.append(url) article_url_dictionary[article_name] = urls json_data = json.loads(json.dumps(article_url_dictionary)) ip_locations = self.ip_location_extraction.get_ip_locations(json_data) tld_locations = self.tld_location_extraction.get_tld_locations(json_data) website_languages = self.website_language_extraction.get_website_languages(json_data) features = {} if url in ip_locations: features["ip-location"] = ip_locations[url] if url in tld_locations: features["tld-location"] = tld_locations[url] if url in website_languages: features["website-language"] = website_languages[url] return features
def __init__(self,geodatabase_path,ianadatabase_path,wfbdatabase_path): self.ip_location_extraction = IPLocationExtraction(geodatabase_path) self.tld_location_extraction = TLDLocationExtraction(ianadatabase_path, wfbdatabase_path) self.website_language_extraction = WebsiteLanguageExtraction()