Пример #1
0
def GetURIField(uri, field):
    """
  Retrieves information of URIs or words according to the index of Freebase.
  URIs that are prefixed with "!" are stripped to remove that operator.
  """
    if field == 'numFound':
        try:
            assert IsConnectionAlive()
            words = [] if uri == '<total>' else [uri]
            num_docs = GetNumDocsFound(words)
        except ValueError:
            num_docs = 0
        return num_docs
    if field.startswith('uri_type'):
        arg = field.split('|')[1]
        return GetURIType(uri, arg)
    if not IsString(uri):
        return None
    if field == 'role':
        return GetURIRole(uri)
    elif field == 'text':
        return GetURIText(uri)
    try:
        uri_field = GetFieldFromURI(uri, field)
    except ValueError:
        uri_field = None
    return uri_field
Пример #2
0
 def test_PredicatePersonManager(self):
     uri = 'fb:soccer.football_team_management_tenure.manager'
     self.assertEqual("person", GetURIType(uri))
Пример #3
0
 def test_PredicatePersonCrewmember(self):
     uri = 'fb:film.film_crew_gig.crewmember'
     self.assertEqual("person", GetURIType(uri))
Пример #4
0
 def test_EntityPersonProfessor(self):
     uri = 'fb:en.professor'
     self.assertEqual("person", GetURIType(uri))
Пример #5
0
 def test_PredicateDatePublicationDate(self):
     uri = 'fb:book.written_work.date_of_first_publication'
     self.assertEqual("date", GetURIType(uri))
Пример #6
0
 def test_PredicateNumberHeight(self):
     uri = 'fb:architecture.structure.height_meters'
     self.assertEqual("number", GetURIType(uri))
Пример #7
0
 def test_PredicateNumberAmount(self):
     uri = 'fb:measurement_unit.dated_money_value.amount'
     self.assertEqual("number", GetURIType(uri))
Пример #8
0
 def test_PredicateNumberYears(self):
     uri = 'fb:games.game.minimum_age_years'
     self.assertEqual("number", GetURIType(uri))
Пример #9
0
 def test_PredicateLocationRegions(self):
     uri = 'fb:finance.stock_exchange.primary_regions'
     self.assertEqual("location", GetURIType(uri))
Пример #10
0
 def test_PredicateLocationInstitution(self):
     uri = 'fb:location.mailing_address.citytown'
     self.assertEqual("location", GetURIType(uri))
Пример #11
0
 def test_PredicateLocationInstitution(self):
     uri = 'fb:education.academic_post.institution'
     self.assertEqual("location", GetURIType(uri))
Пример #12
0
 def test_PredicatePersonAcademicPerson(self):
     uri = 'fb:education.academic_post.person'
     self.assertEqual("person", GetURIType(uri))
Пример #13
0
 def test_PredicateDateFoundedDate(self):
     uri = 'fb:organization.organization.date_founded'
     self.assertEqual("date", GetURIType(uri))
Пример #14
0
 def test_PredicateDateLastEruption(self):
     uri = 'fb:geography.mountain.last_eruption'
     self.assertEqual("date", GetURIType(uri))
Пример #15
0
 def test_PredicatePersonPractitioner(self):
     uri = 'fb:martial_arts.martial_art.well_known_practitioner'
     # from pudb import set_trace; set_trace()
     self.assertEqual("person", GetURIType(uri))
Пример #16
0
 def test_PredicatePersonNoFuel(self):
     uri = 'fb:engineering.engine.energy_source'
     # from pudb import set_trace; set_trace()
     self.assertNotEqual("person", GetURIType(uri))
Пример #17
0
 def test_PredicateNumberIssueNumber(self):
     uri = 'fb:comic_books.comic_book_issue.issue_number'
     self.assertEqual("number", GetURIType(uri))
Пример #18
0
 def test_PredicateNumberDuration(self):
     uri = 'fb:amusement_parks.ride.duration'
     self.assertEqual("number", GetURIType(uri))
Пример #19
0
 def test_PredicatePersonSurvivors(self):
     uri = 'fb:event.disaster.survivors'
     # from pudb import set_trace; set_trace()
     self.assertEqual("person", GetURIType(uri))
Пример #20
0
 def test_PredicateNumberTemperature(self):
     uri = 'fb:travel.travel_destination_monthly_climate.average_max_temp_c'
     self.assertEqual("number", GetURIType(uri))
Пример #21
0
 def test_PredicatePersonCelebrity(self):
     uri = 'fb:celebrities.rehab.celebrity'
     self.assertEqual("person", GetURIType(uri))
Пример #22
0
 def test_PredicateDateCompletedOn(self):
     uri = 'fb:law.constitutional_amendment.ratification_completed_on'
     self.assertEqual("date", GetURIType(uri))
Пример #23
0
 def test_PredicatePersonPlayer(self):
     uri = 'fb:american_football.football_roster_position.player'
     self.assertEqual("person", GetURIType(uri))
Пример #24
0
 def test_PredicateDateDuringPeriod(self):
     uri = 'fb:geology.geological_formation.formed_during_period'
     self.assertEqual("date", GetURIType(uri))
Пример #25
0
 def test_PredicatePersonEmploymentPerson(self):
     uri = 'fb:business.employment_tenure.person'
     self.assertEqual("person", GetURIType(uri))