def clean_text( self, text: str, fuzzy: bool = False, format: Optional[str] = None, proxy: Optional["EntityProxy"] = None, ) -> Optional[str]: """The classic: date parsing, every which way.""" if format is not None: return parse_format(text, format).text return parse(text).text
def parse_foreign_persons(context, entity, text): while "," in text: text, section = text.rsplit(",", 1) fragment = section.strip() if not len(fragment): continue date = parse_format(fragment, "%d.%m.%Y г. р.") if date.text is not None: entity.add("birthDate", date) continue entity.add("notes", fragment) parse_name(entity, text)
def parse_russian_persons(context, entity, text): while "," in text: text, section = text.rsplit(",", 1) fragment = section.strip() if not len(fragment): continue date = parse_format(fragment, "%d.%m.%Y г.р.") if date.text is not None: entity.add("birthDate", date) continue if fragment.startswith("("): fragment = fragment.replace(")", "") entity.add("alias", fragment) continue obj = h.make_address(context, full=fragment, country_code="ru") h.apply_address(context, entity, obj) parse_name(entity, text)
def parse_russian_orgs(context: Context, entity, text): while "," in text: text, section = text.rsplit(",", 1) fragment = section.strip() if not len(fragment): continue date = parse_format(fragment, "%d.%m.%Y") if date.text is not None: entity.add("incorporationDate", date) continue if fragment.startswith("ИНН:"): entity.add("innCode", fragment.replace("ИНН:", "")) continue if fragment.startswith("ОГРН:"): entity.add_cast("Company", "ogrnCode", fragment.replace("ОГРН:", "")) continue text = f"{text},{section}" break parse_name(entity, text)