Package: russiannames
# Russian Namesrussiannamesis a Python 3 library dedicated to parse Russian names, surnames and midnames, identify person gender by fullname and how name is written. It uses MongoDB as backend to speed-up name parsing.## DocumentationDocumentation is built automatically and can be found onhttps://russiannames.readthedocs.org/en/latest/## InstallationTo install Python library usepip install russiannamesvia pip orpython setup.py installTo use database you need MongoDB instance.
Unpack db_data_bson.zip file fromhttps://github.com/datacoon/russiannames/blob/master/data/bson/db_dump_bson.zipand usemongorestorecommand to restorenamesdatabase with 3 collections: names, surnames and midnames## FeaturesDatabase of names used for identification375449 surnames - collection: surnames32134 first names - collection: names48274 midnames - collection: midnamesDetailed database statistics by gender and collectioncollection| total | males|females|universal or unidentified |— | — | — | — | — |names | 32134 | 19297 | 8278 | 1196 |midnames | 48274 | 30114 | 16143 | 0 |surnames | 375274 | 124662 | 111534 | 38827 |Supports 12 formats of Russian full names writing styleFormat | Example        | Description  |—— | ————– | ———— |f | Ольга | only first name |s | Петров | only surname |Fs | О. Сидорова | first letter of first name and full surname |sF | Николаев С. | full surname and first letter of surname |sf | Абрамов Семен | full surname and full first name |fs | Соня Камиуллина | full first name and full surname |fm | Иван Петрович | full first name and full middlename |SFM | М.Д.М. | first letters of surname, first name, middlename |FMs | А.Н. Егорова | first letters of first and middle name and full furname |sFM | Николаенко С.П. | full surname and first letters of first and middle names |sfM | Петракова Зинаида М. | full surname, first name and first letter of middle name |sfm | Казаков Ринат Артурович | full name as surname, first name and middle name |fms | Светлана Архиповна Волкова | full name as first name, middle name and surname |Supports names with following ethnics identification9 ethnic types in names, surnames and middle names supportedkey  | name (en) | name (rus)—- | ——— | ———-arab | Arabic     | Арабскоеarm  | Armenian     | Армянскоеgeor | Georgian     | Грузинскоеgerm | German     | Немецкиеgreek | Greek    | Греческиеjew  | Jew      | Еврейскиеpolsk | Polish    | Польскиеslav | Slavic (Russian) | Славянскиеtur  | Turkic | Тюркские (тюркоязычные)## Limitationsvery rare names, surnames or middlenames could be not parsedethnic identification is still on early stage## Speed optimizationpreconfigured and preindexed MongoDb collections used## Usage and Examples### Parse name and identify genderParses names and returns: format, surname, first name, middle name, parsed (True/False) and gender>>> from russiannames.parser import NamesParser
>>> parser = NamesParser()
>>> parser.parse('Нигматуллин Ринат Ахметович')
{'format': 'sfm', 'sn': 'Нигматуллин', 'fn': 'Ринат', 'mn': 'Ахметович', 'gender': 'm', 'text': 'Нигматуллин Ринат Ахметович', 'parsed': True}
>>> parser.parse('Петрова C.Я.')
{'format': 'sFM', 'sn': 'Петрова', 'fn_s': 'C', 'mn_s': 'Я', 'gender': 'f', 'text': 'Петрова C.Я.', 'parsed': True}Gender field could have one of following values:m: Malef: Femaleu: Unknown / unidentified-: Impossible to identify### Ethnic identification (experimental)
Parses surname, first name and middle name and tries to identify person ethic affilation of the person>>> from russiannames.parser import NamesParser
>>> parser = NamesParser()
>>> parser.classify('Нигматуллин', 'Ринат', 'Ахметович')
{'ethnics': ['tur'], 'gender': 'm'}
>>> parser.classify('Алексеева', 'Ольга', 'Ивановна')
{'ethnics': ['slav'], 'gender': 'f'}## Supported languages
* Russian## Requirements
* pymongo
* click## Acknowledgements