Beispiel #1
0
    def search_person(self, card):
        query = self.make_query(card.title)
        failures = 0
        for officer in opencorporates_paginate('officers/search', 'officers',
                                               'officer', query):
            url = officer.get('opencorporates_url')
            score = text_score(officer.get('name'), list(card.aliases))
            if score < 70:
                failures += 1
                continue
            else:
                failures = 0

            if failures > 3:
                break

            corp_data = officer.get('company')
            position = officer.get('position')
            if not position:
                position = 'an officer'
            citation = '%s is %s of %s' % (officer.get('name'),
                                           position,
                                           corp_data.get('name'))
            self.make_ref(card, score, url, citation)
        return card
Beispiel #2
0
 def search_all(self, card):
     args = {'key': API_KEY, 'term': card.title}
     r = requests.get(URL + "api/search", params=args)
     idx = 1
     for match in r.json():
         score = text_score(match.get('Name'), list(card.aliases))
         if score < 50:
             continue
         args = {'key': API_KEY, 'id': match.get('ID')}
         r = requests.get(URL + "api/entity", params=args)
         for type_set in r.json().get('data'):
             for data in type_set['dataset_type']:
                 for type_, ds in data.items():
                     for item in ds:
                         for record in item.get('dataset'):
                             self.make_ref(card, match.get('ID'), score,
                                           type_, record, idx)
                             idx = idx + 1
     return card
Beispiel #3
0
 def search_all(self, card):
     args = {'key': API_KEY, 'term': card.title}
     r = requests.get(URL + "api/search", params=args)
     idx = 1
     for match in r.json():
         score = text_score(match.get('Name'), list(card.aliases))
         if score < 50:
             continue
         args = {'key': API_KEY, 'id': match.get('ID')}
         r = requests.get(URL + "api/entity", params=args)
         for type_set in r.json().get('data'):
             for data in type_set['dataset_type']:
                 for type_, ds in data.items():
                     for item in ds:
                         for record in item.get('dataset'):
                             self.make_ref(card, match.get('ID'),
                                           score, type_, record, idx)
                             idx = idx + 1
     return card
Beispiel #4
0
    def search_company(self, card):
        query = self.make_query(card.title)
        failures = 0
        for company in opencorporates_paginate('companies/search', 'companies',
                                               'company', query):
            url = company.get('opencorporates_url')
            score = text_score(company.get('name'), list(card.aliases))
            if score < 70:
                failures += 1
                continue
            else:
                failures = 0

            if failures > 3:
                break

            citation = 'Company record: %s' % company.get('name')
            self.make_ref(card, score, url, citation)
        return self.search_person(card)