def handle_data(self, data):
     if self.inside_date:
         locale.setlocale(locale.LC_TIME, "es_ES.UTF-8")
         self.death_date = datetime.strptime(data, "%d de %B de %Y")
         self.inside_date = False
     if self.inside_description:
         self.location, self.age = sp_age_location_colector(data)
Esempio n. 2
0
 def handle_data(self, data):
     if self.located:
         self.located = False
         #TODO the way is originally performed comes to this check several times and overwrites one by another, is correct?
         locationD, ageD = sp_age_location_colector(data)
         if locationD: self.location = locationD
         if ageD: self.age = ageD
Esempio n. 3
0
 def test_basic_colector(self):
     '''
     Test the operation of the colector
     '''
     assert(sp_age_location_colector("Falleció en Santander, el día 22 de febrero de 1567, a los 61 años de edad, habiendo") == ("Santander", 61))
     assert(sp_age_location_colector("Falleció el día 8 de marzo de 2013, a los 64 años de edad,")== (None, 64))
     assert(sp_age_location_colector("en Madrid") == ("Madrid", None))
     assert(sp_age_location_colector("en Barcelona a los 67 años")== ("Barcelona", 67))
     assert(sp_age_location_colector(" Ha fallecido cristianamente en Barcelona, a la edad de 93 años, el")== ("Barcelona", 93))
     
     assert(sp_age_location_colector("Saez Doctor en medicina. Endocrinólogo Ha fallecido en Barcelona, a la edad de 70 años, el día ")== ("Barcelona", 70))
     #With detection
     assert(sp_age_location_colector(" Ha mort a Barcelona, a l'edat de 99 anys, el dia 24 de febrer", detect_lan = True)== ("Barcelona", 99))
Esempio n. 4
0
 def handle_data(self, data):
     if self.inside_data:
         self.location, self.age = sp_age_location_colector(data, detect_lan = True)
         self.inside_data = False
     if "Publicado en EnMemoria" in data:
         #This means we are at the end of the profile.
         self.inside_profile = False
         prof_record = gen_profile(self.name, self.surname)
         prof_record.setWebReference(self.web_link)
         prof_record.setCheckedDate("death", self.death_date.year, self.death_date.month,self.death_date.day,"EXACT")
         if (self.age):
             prof_record.setCheckedDate("birth", self.death_date.year - self.age, accuracy="ABOUT")
         if (self.location):
             prof_record.setPlaces("death", self.location, language="es" )
         self.profiles.append(prof_record)
         self.initiate_data()