Best Python code snippet using selene_python
rule.py
Source:rule.py
...6from Lab2.constants import *7SIMPLE_CITIES = [city.lower() for city in city_test if city.find('-') == -1 and city.find(' ') == -1]8COMPLEX_CITIES = [city.lower() for city in city_test if city.find('-') != -1 or city.find(' ') != -1]9Address = fact('Address', get_address_schema())10CITY_NAME = or_(rule(dictionary(SIMPLE_CITIES)), morph_pipeline(COMPLEX_CITIES)).interpretation(Address.city)11SIMPLE = and_(true(), or_(get_noun_gram(), get_adjective_gram()))12COMPLEX = or_(rule(SIMPLE, is_dash().optional(), SIMPLE),13 rule(true(), is_dash().optional(), caseless('на'), is_dash().optional(), true()))14PERSON_RULE = or_(rule(SIMPLE), COMPLEX)15MAYBE_CITY_NAME = or_(PERSON_RULE, rule(PERSON_RULE, '-', get_int_type())).interpretation(Address.city)16CITY_WORDS = or_(rule(normalized('гоÑод')), rule(caseless('г'), is_dot().optional())).interpretation(17 Address.city_type.const('гоÑод'))18CITY = or_(rule(CITY_NAME), rule(CITY_WORDS, CITY_NAME), rule(CITY_NAME, CITY_WORDS)).interpretation(Address)19SHORT_MODIFIER_WORDS = rule(in_caseless({*ex_word}), is_dash().optional())20MODIFIER_WORDS = or_(SHORT_MODIFIER_WORDS)21LET_WORDS = or_(rule(caseless('леÑ')), rule(is_dash().optional(), caseless('леÑиÑ')))22LET = rule(get_int_type(), LET_WORDS)23MONTH_WORDS = dictionary({*months})24DAY = and_(get_int_type(), gte(1), lte(31))25YEAR = and_(get_int_type(), gte(1), lte(2100))26YEAR_WORDS = normalized('год')27DATE = or_(rule(DAY, MONTH_WORDS), rule(get_adjective_gram(), normalized('дней')), rule(YEAR, YEAR_WORDS))28TITLE_RULE = and_(29 true(),30 not_(get_int_type()),31 not_(get_intj_type()),32 not_(length_eq(3)),33 not_(normalized('пÑоезд')),34 not_(normalized('виднÑй')),35 not_(normalized('кÑÑлова')),36 not_(normalized('пиÑеÑ'))37)38PART = and_(TITLE_RULE, or_(gram('Name'), gram('Surn')))39MAYBE_FIO = or_(rule(gram('Surn')), rule(gram('Name')), rule(TITLE_RULE, PART), rule(PART, TITLE_RULE))40POSITION_WORDS = or_(rule(dictionary(roles_test)))41MAYBE_PERSON = or_(MAYBE_FIO, rule(POSITION_WORDS, MAYBE_FIO))42IMENI_WORDS = or_(rule(caseless('им'), is_dot().optional()), rule(caseless('имени')))43IMENI = rule(IMENI_WORDS.optional(), MAYBE_PERSON)44SIMPLE = and_(or_(get_adjective_gram(), and_(get_noun_gram(), get_genitive())), TITLE_RULE)45COMPLEX = or_(rule(and_(get_adjective_gram(), TITLE_RULE), get_noun_gram()),46 rule(TITLE_RULE, is_dash().optional(), TITLE_RULE))47EXCEPTION = dictionary({'аÑбаÑ', 'ваÑваÑка'})48MAYBE_NAME = or_(rule(SIMPLE), rule(EXCEPTION))49MAIL_STREET = rule(get_int_type(), get_adjective_gram(), get_noun_gram())50LET_NAME = or_(MAYBE_NAME, LET, DATE, IMENI)51MODIFIER_NAME = rule(MODIFIER_WORDS, get_noun_gram())52PERSON_RULE = or_(LET_NAME, MODIFIER_NAME, MAIL_STREET)53ADDR_NAME = PERSON_RULE54SPB_SHORT = rule(normalized('пиÑеÑ')).interpretation(Address.city.const('ÑанкÑ-пеÑеÑбÑÑг'))55SBP_NAME = LET_NAME.interpretation(Address.street)56SPB_STREET = rule(SPB_SHORT, SBP_NAME).interpretation(Address)57STREET_NAME = ADDR_NAME.interpretation(Address.street)58STREET_WORDS = or_(rule(normalized('ÑлиÑа')), rule(normalized('ÑлиÑа'), normalized('знаÑиÑ')),59 rule(caseless('Ñл'), is_dot().optional())60 ).interpretation(Address.street_type.const('ÑлиÑа'))61STREET = or_(rule(STREET_WORDS, STREET_NAME), rule(STREET_NAME, STREET_WORDS)).interpretation(Address)62BOULEVARD_WORDS = or_(rule(caseless('б'), '-', caseless('Ñ')),63 rule(caseless('бÑл'), is_dot().optional())).interpretation(Address.street_type.const('бÑлÑваÑ'))64BOULEVARD_NAME = ADDR_NAME.interpretation(Address.street)65BOULEVARD = or_(rule(BOULEVARD_WORDS, BOULEVARD_NAME), rule(BOULEVARD_NAME, BOULEVARD_WORDS)).interpretation(Address)66HIGHWAY_WORDS = or_(rule(caseless('Ñ'), is_dot()), rule(normalized('ÑоÑÑе'))).interpretation(67 Address.street_type.const('ÑоÑÑе'))68HIGHWAY_NAME = ADDR_NAME.interpretation(Address.street)69HIGHWAY = or_(rule(HIGHWAY_WORDS, HIGHWAY_NAME), rule(HIGHWAY_NAME, HIGHWAY_WORDS)).interpretation(Address)70TRACT_WORDS = or_(rule(caseless('ÑÑ'), is_dot()), rule(normalized('ÑÑакÑ'))).interpretation(71 Address.street_type.const('ÑÑакÑ'))72TRACT_NAME = ADDR_NAME.interpretation(Address.street)73TRACT = or_(rule(TRACT_WORDS, TRACT_NAME), rule(TRACT_NAME, TRACT_WORDS)).interpretation(Address)74GAI_WORDS = rule(normalized('гай'))75GAI_NAME = ADDR_NAME76GAI = or_(rule(GAI_WORDS, GAI_NAME), rule(GAI_NAME, GAI_WORDS)).interpretation(Address.street)77VAL_WORDS = rule(normalized('вал'))78VAL_NAME = ADDR_NAME79VAL = or_(rule(VAL_WORDS, VAL_NAME), rule(VAL_NAME, VAL_WORDS)).interpretation(Address.street)80ALLEY_WORDS = rule(normalized('аллеи')).interpretation(Address.street_type.const('аллеи'))81ALLEY_NAME = ADDR_NAME.interpretation(Address.street)82ALLEY = rule(ALLEY_NAME, ALLEY_WORDS).interpretation(Address)83AVENUE_WORDS = or_(rule(in_caseless({'пÑ', 'пÑоÑп'}), is_dot().optional()),84 rule(caseless('пÑ'), '-', in_caseless({'кÑ', 'Ñ'}), is_dot().optional()),85 rule(normalized('пÑоÑпекÑ'))).interpretation(Address.street_type.const('пÑоÑпекÑ'))86AVENUE_NAME = ADDR_NAME.interpretation(Address.street)87AVENUE = or_(rule(AVENUE_WORDS, AVENUE_NAME), rule(AVENUE_NAME, AVENUE_WORDS)).interpretation(Address)88DISTRICT_WORDS = or_(rule(in_caseless({'мк', 'мкÑ'}), is_dot().optional()),89 rule(caseless('мк'), '-', in_caseless({'Ñн', 'н'}), is_dot().optional()),90 ).interpretation(Address.street_type.const('микÑоÑайон'))91DISTRICT_NAME = ADDR_NAME.interpretation(Address.street)92DISTRICT = or_(rule(DISTRICT_WORDS, DISTRICT_NAME), rule(DISTRICT_NAME, DISTRICT_WORDS)).interpretation(Address)93DRIVEWAY_WORDS = or_(rule(normalized('пÑоезд')), rule(caseless('пÑ'), is_dot().optional())).interpretation(94 Address.street_type.const('пÑоезд'))95DRIVEWAY_NAME = ADDR_NAME.interpretation(Address.street)96DRIVEWAY = or_(rule(DRIVEWAY_NAME, DRIVEWAY_WORDS), rule(DRIVEWAY_WORDS, DRIVEWAY_NAME)).interpretation(Address)97ALLEYWAY_WORDS = or_(rule(caseless('п'), is_dot()), rule(caseless('пеÑ'), is_dot().optional()), ).interpretation(98 Address.street_type.const('пеÑеÑлок'))99ALLEYWAY_NAME = ADDR_NAME.interpretation(Address.street)100ALLEYWAY = or_(rule(ALLEYWAY_WORDS, ALLEYWAY_NAME), rule(ALLEYWAY_NAME, ALLEYWAY_WORDS)).interpretation(Address)101SQUARE_WORDS = or_(rule(caseless('пл'), is_dot().optional())).interpretation(Address.street_type.const('плоÑадÑ'))102SQUARE_NAME = ADDR_NAME.interpretation(Address.street)103SQUARE = or_(rule(SQUARE_WORDS, SQUARE_NAME), rule(SQUARE_NAME, SQUARE_WORDS)).interpretation(Address)104EMBANKMENT_WORDS = or_(rule(caseless('наб'), is_dot().optional())).interpretation(105 Address.street_type.const('набеÑежнаÑ'))106EMBANKMENT_NAME = ADDR_NAME.interpretation(Address.street)107EMBANKMENT = or_(rule(EMBANKMENT_WORDS, EMBANKMENT_NAME), rule(EMBANKMENT_NAME, EMBANKMENT_WORDS)).interpretation(108 Address)109LETTER = in_(ru)110QUOTE = in_(QUOTES)111LETTER = or_(rule(LETTER), rule(QUOTE, LETTER, QUOTE))112SEP = in_(r' /\-')113VALUE = or_(rule(get_int_type(), SEP, LETTER), rule(get_int_type(), LETTER),114 rule(get_int_type(), is_whitespace(), LETTER), rule(get_int_type()),115 rule(get_int_type(), SEP, get_int_type()))116ADDR_VALUE = rule(eq('â').optional(), VALUE)117HOUSE_WORDS = or_(rule(normalized('номеÑ')), rule(normalized('дом')), rule(caseless('д'), is_dot())).interpretation(118 Address.house_type.const('дом'))119HOUSE_VALUE = ADDR_VALUE.interpretation(Address.house)120HOUSE = rule(HOUSE_WORDS, HOUSE_VALUE).interpretation(Address)121APARTMENT_WORDS = or_(rule(in_caseless('кв'), is_dot().optional()), rule(normalized('кваÑÑиÑа'))).interpretation(122 Address.corpus_type.const('коÑпÑÑ'))123APARTMENT_VALUE = ADDR_VALUE.interpretation(Address.apartment)124APARTMENT = or_(rule(APARTMENT_WORDS, APARTMENT_VALUE), rule(APARTMENT_VALUE, APARTMENT_WORDS)).interpretation(Address)125corpus_words_const = {'к', 'коÑп', 'коÑ', 'коÑпÑÑ'}126CORPUS_WORDS = or_(rule(in_caseless(corpus_words_const), is_dot().optional())).interpretation(127 Address.corpus_type.const('коÑпÑÑ'))128CORPUS_VALUE = ADDR_VALUE.interpretation(Address.corpus)129CORPUS = rule(CORPUS_WORDS, CORPUS_VALUE).interpretation(Address)130building_words_const = {'ÑÑ', 'ÑÑÑоение'}131BUILDING_WORDS = or_(132 rule(in_caseless(building_words_const), is_dot().optional())).interpretation(133 Address.building_type.const('ÑÑÑоение'))134BUILDING_VALUE = ADDR_VALUE.interpretation(Address.building)135BUILDING = rule(BUILDING_WORDS, BUILDING_VALUE).interpretation(Address)136STREET_HOUSE_CORPUS = rule(137 CITY.optional(),138 or_(HIGHWAY, STREET, STREET_NAME, AVENUE,139 DRIVEWAY, TRACT, SQUARE, EMBANKMENT, ALLEY,140 BOULEVARD, DISTRICT, GAI, VAL, ALLEYWAY),141 HOUSE_WORDS.optional(),142 HOUSE_VALUE,143 CORPUS_WORDS,144 CORPUS_VALUE145).interpretation(Address)146HOUSE_CORPUS = rule(HOUSE_VALUE, CORPUS_WORDS, CORPUS_VALUE).interpretation(Address)147HOUSE_BUILDING = rule(148 CITY.optional(),149 or_(HIGHWAY, STREET, STREET_NAME, AVENUE,150 DRIVEWAY, TRACT, SQUARE, EMBANKMENT, ALLEY,151 BOULEVARD, DISTRICT, GAI, VAL, ALLEYWAY),152 HOUSE_WORDS.optional(),153 HOUSE_VALUE,154 BUILDING_WORDS,155 BUILDING_VALUE156).interpretation(Address)157HOUSE_STREET = rule(158 CITY.optional(),159 or_(HIGHWAY, STREET, STREET_NAME, AVENUE,160 DRIVEWAY, TRACT, SQUARE, EMBANKMENT, ALLEY,161 BOULEVARD, DISTRICT, GAI, VAL, ALLEYWAY),162 HOUSE_WORDS.optional(),163 HOUSE_VALUE164).interpretation(Address)165VALUE_HOUSE = rule(get_int_type()).interpretation(Address.house)166NUMBER_HOUSE = rule(rule(normalized('номеÑ')), VALUE_HOUSE).interpretation(Address)167TRIPLE_HOUSE = rule(rule(normalized('дом')), VALUE_HOUSE).interpretation(Address)168DOM_APARTMENT = rule(HOUSE_VALUE, APARTMENT_VALUE).interpretation(Address)169ADDRESS_RULE = or_(170 SPB_STREET, CITY, NUMBER_HOUSE, HOUSE_CORPUS, HOUSE_BUILDING, TRIPLE_HOUSE,171 HOUSE_STREET, DOM_APARTMENT, STREET, DRIVEWAY, ALLEYWAY, SQUARE, HIGHWAY, TRACT, EMBANKMENT, VAL, GAI, ALLEY, HOUSE,172 STREET_HOUSE_CORPUS, HOUSE_BUILDING, BOULEVARD, DISTRICT, CORPUS, APARTMENT, BUILDING173).interpretation(Address)174Name = fact('Name', name)175name = and_(gram('Name'), not_(get_abbr_gram()), get_len())176patronymic = and_(gram('Patr'), not_(get_abbr_gram()), get_len())177surname = and_(gram('Surn'), get_len())178FIRST = name.interpretation(Name.first)179FIRST_ABBR = and_(get_abbr_gram(), true()).interpretation(Name.first)180LAST = surname.interpretation(Name.last)181MAYBE_LAST = and_(true(), not_(get_abbr_gram()), get_len()).interpretation(Name.last)182MIDDLE = patronymic.interpretation(Name.middle)183MIDDLE_SHORT = and_(get_abbr_gram(), true()).interpretation(Name.middle)184FIRST_LAST = rule(FIRST, MAYBE_LAST)185LAST_FIRST = rule(MAYBE_LAST, FIRST)186LAST_ABBR_FIRST = rule(MAYBE_LAST, FIRST_ABBR, is_dot())187LAST_ABBR_FIRST_MIDDLE = rule(MAYBE_LAST, FIRST_ABBR, is_dot(), MIDDLE_SHORT, is_dot())188FIRST_MIDDLE = rule(FIRST, MIDDLE)189MIDDLE_FIRST = rule(MIDDLE, FIRST)190FIRST_MIDDLE_LAST = rule(FIRST, MIDDLE, LAST)191LAST_FIRST_MIDDLE = rule(LAST, FIRST, MIDDLE)192SHORT_FIRST_MIDDLE_LAST = rule(FIRST_ABBR, is_dot(), MIDDLE_SHORT, is_dot(), MAYBE_LAST)193SHORT_FIRST_LAST = rule(FIRST_ABBR, is_dot(), MAYBE_LAST)194PERSON_RULE = or_(LAST_FIRST_MIDDLE, FIRST_MIDDLE_LAST, FIRST_MIDDLE, FIRST_LAST, LAST_FIRST, SHORT_FIRST_LAST,...
search.py
Source:search.py
...74 Job.job_id)75 a["results"] += games_and["results"] + companies_and["results"] + jobs_and["results"]76 # contains OR77 print("PARTIAL OR")78 games_queries_or = OrderedDict([("name", or_(* [Game.name.ilike("%" + x + "%") for x in terms])),79 ("deck", or_(* [Game.deck.ilike("%" + x + "%") for x in terms])),80 ("description", or_(* [Game.description.ilike("%" + x + "%") for x in terms]))])81 companies_queries_or = OrderedDict([("name", or_(* [Company.name.ilike("%" + x + "%") for x in terms])),82 ("deck", or_(* [Company.deck.ilike("%" + x + "%") for x in terms])),83 ("description", or_(* [Company.description.ilike("%" + x + "%") for x in terms]))])84 jobs_queries_or = OrderedDict([("job_title", or_(* [Job.job_title.ilike("%" + x + "%") for x in terms])),85 ("description", or_(* [Job.description.ilike("%" + x + "%") for x in terms])),86 ("location", or_(* [Job.location.ilike("%" + x + "%") for x in terms])),87 ("company_name", or_(* [Job.company_name.ilike("%" + x + "%") for x in terms]))])88 games_or = search_models(a, request.args["s"], Game, "games", "partial match OR", "OR", games_queries_or, Game.name,89 Game.game_id)90 companies_or = search_models(a, request.args["s"], Company, "companies", "partial match OR", "OR", companies_queries_or,91 Company.name, Company.company_id)92 jobs_or = search_models(a, request.args["s"], Job, "jobs", "partial match OR", "OR",93 jobs_queries_or, Job.job_title, Job.job_id)94 a["results"] += games_or["results"] + companies_or["results"] + jobs_or["results"]95 return a96# search_string, filter, entities97def search_models(temp_result, search_string, model, type, match_type, result_type, queries, *entities):98 result = {}99 result["results"] = []100 terms = search_string.rsplit(" ")101 for q in queries:...
results.py
Source:results.py
...33avg std min max3496706.3 2651.17 80156 9806235100318 1131.11 91302 10094036100649 1752.85 87910 10176237and_(or_(and_(IN9, or_(IN5, IN3)), and_(or_(and_(or_(and_(IN13, IN12), not_(not_(IN8))), IN16), and_(or_(and_(not_(not_(IN8)), or_(IN2, IN4)), or_(and_(and_(or_(and_(IN7, or_(IN3, IN3)), IN10), or_(and_(and_(not_(not_(IN8)), and_(or_(and_(IN7, or_(and_(IN7, or_(IN3, IN3)), not_(IN8))), IN10), or_(IN5, IN4))), IN16), IN2)), IN16), and_(or_(and_(not_(not_(IN1)), or_(IN2, and_(IN7, or_(or_(IN3, IN5), or_(and_(IN2, IN4), IN10))))), IN15), or_(IN12, and_(IN6, IN11))))), or_(IN2, and_(IN7, or_(or_(IN3, IN5), or_(and_(IN2, IN4), IN10)))))), or_(and_(or_(and_(IN7, or_(and_(IN7, or_(IN3, IN3)), or_(and_(IN6, IN8), IN10))), IN10), or_(IN5, IN4)), and_(or_(and_(or_(IN4, not_(not_(IN8))), IN16), and_(or_(and_(not_(not_(IN8)), or_(IN7, IN4)), IN15), or_(not_(not_(and_(IN13, IN3))), and_(IN6, IN11)))), IN12)))), or_(and_(or_(or_(and_(IN2, IN4), IN10), IN15), or_(not_(not_(and_(IN13, IN12))), and_(IN6, IN11))), or_(and_(and_(or_(and_(IN7, or_(IN3, IN3)), IN10), or_(and_(and_(or_(and_(IN7, or_(IN3, IN3)), IN13), and_(or_(and_(IN7, or_(and_(IN7, or_(IN3, IN3)), not_(IN8))), IN10), or_(and_(or_(and_(IN7, or_(and_(IN7, or_(IN3, IN3)), not_(IN8))), IN10), or_(IN5, IN4)), IN4))), IN16), IN2)), IN16), and_(or_(and_(not_(not_(IN1)), or_(IN2, and_(IN7, or_(or_(IN3, IN5), or_(and_(IN2, IN4), IN10))))), IN15), or_(not_(not_(IN8)), and_(IN6, IN11))))))3898445.8 491.316 95088 988623992616.2 2998.54 74400 938804096612.7 3473.9 73164 984344196469.9 1417.88 87818 976344298469.3 2206.32 87930 996764397442.4 2274.31 83064 98402...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!