def _skloninefio(self): if self.fio_head: fio = self.fio_head.split(' ') if len(fio) == 3: p = Petrovich() surname = fio[0] name = fio[1] lastname = fio[2] self.fio_head_rod_pad = p.lastname( surname, Case.GENITIVE) + ' ' + p.firstname( name, Case.GENITIVE) + ' ' + p.middlename( lastname, Case.GENITIVE) self.fio_head_dat_pad = p.lastname( surname, Case.DATIVE) + ' ' + p.firstname( name, Case.DATIVE) + ' ' + p.middlename( lastname, Case.DATIVE)
def convert_lastnames(self): json_data = json.load(codecs.open(self.lastnames_src, 'r', 'utf-8-sig')) p = Petrovich() for item in json_data: if item['PeoplesCount'] > 0 and item["PeoplesCount"] < 1000: m_data = { "id": item["ID"], "name": item["Surname"], "gender": item["Sex"], "count": item["PeoplesCount"] } f_data = { "id": item["ID"], "name": p.lastname(item["Surname"], Case.GENITIVE, Gender.MALE), "gender": item["Sex"], "count": item["PeoplesCount"] } m_file = "male_russian_lastnames.txt" f_file = "female_russian_lastnames.txt" self.dump_results(m_data, full_path(m_file)) self.dump_results(f_data, full_path(f_file))
# coding: utf-8 from petrovich.enums import Case from petrovich.main import Petrovich __author__ = 'damirazo <*****@*****.**>' if __name__ == '__main__': strings = [ (u'Алексеев', u'Алексей', u'Давыдович'), (u'Матвеев', u'Денис', u'Евгеньевич'), (u'Алимова', u'Алия', u'Маратовна'), ] petro = Petrovich() for (fname, iname, oname) in strings: for case in Case.CASES: print(u'{} {} {}'.format( petro.lastname(fname, case), petro.firstname(iname, case), petro.middlename(oname, case), ))
def write_surnames_initials(id_surname, id_name, id_patronymic): human_class = Petrovich() changed_surname = human_class.lastname(id_surname, Case.DATIVE) return str(changed_surname + ' ' + get_initials(id_name, id_patronymic) + '\n')
def dative_surname(id): FI = DB.get_person(id)[1].split(' ') petr = Petrovich() surname = petr.lastname(FI[0], Case.DATIVE) name = petr.firstname(FI[1], Case.DATIVE) return surname + ' ' + name