How to use starts_with method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

ili.py

Source:ili.py Github

copy

Full Screen

1'''2 ESP Health3 Notifiable Diseases Framework4 Influenza like illness Case Generator5@author: Carolina Chacin <cchacin@commoninf.com>6@organization: Commonwealth Informatics.7@contact: http://esphealth.org8@copyright: (c) 2012 Commonwealth Informatics9@license: LGPL10'''11# In most instances it is preferable to use relativedelta for date math. 12# However when date math must be included inside an ORM query, and thus will13# be converted into SQL, only timedelta is supported.14from datetime import timedelta15from dateutil.relativedelta import relativedelta16from django.db import transaction17from django.db.models import Avg, Count, F, Max, Min, Q, Sum18from ESP.utils import log19from ESP.hef.base import Event, BaseEventHeuristic,LabResultAnyHeuristic, PrescriptionHeuristic20from ESP.hef.base import Dose, LabResultPositiveHeuristic, LabOrderHeuristic, DiagnosisHeuristic, Dx_CodeQuery21from ESP.nodis.base import DiseaseDefinition, Case22from ESP.static.models import DrugSynonym23from ESP.emr.models import Encounter24class ili(DiseaseDefinition):25 '''26 Influenza like illness27 '''28 29 conditions = ['ili']30 31 uri = 'urn:x-esphealth:disease:commoninf:ili:v1'32 33 short_name = 'ili'34 35 # no tests for ili36 test_name_search_strings = [ ]37 38 timespan_heuristics = []39 40 FEVER_TEMPERATURE = 100.0 # Temperature in Fahrenheit41 42 43 @property44 def event_heuristics(self):45 heuristic_list = []46 47 #48 # Diagnosis Codes for fever49 # 50 heuristic_list.append( DiagnosisHeuristic(51 name = 'fever',52 dx_code_queries = [53 Dx_CodeQuery(starts_with='780.6', type='icd9'),54 Dx_CodeQuery(starts_with='780.31', type='icd9'),55 ]))56 57 #58 # Diagnosis Codes for ili59 # 60 heuristic_list.append( DiagnosisHeuristic(61 name = 'ili',62 dx_code_queries = [63 Dx_CodeQuery(starts_with='079.3', type='icd9'),64 Dx_CodeQuery(starts_with='079.89', type='icd9'),65 Dx_CodeQuery(starts_with='079.99', type='icd9'),66 Dx_CodeQuery(starts_with='460', type='icd9'),67 Dx_CodeQuery(starts_with='462', type='icd9'),68 Dx_CodeQuery(starts_with='464.00', type='icd9'),69 Dx_CodeQuery(starts_with='464.01', type='icd9'),70 Dx_CodeQuery(starts_with='464.10', type='icd9'),71 Dx_CodeQuery(starts_with='464.11', type='icd9'),72 Dx_CodeQuery(starts_with='464.20', type='icd9'),73 Dx_CodeQuery(starts_with='464.21', type='icd9'),74 Dx_CodeQuery(starts_with='465.0', type='icd9'),75 Dx_CodeQuery(starts_with='465.8', type='icd9'),76 Dx_CodeQuery(starts_with='465.9', type='icd9'),77 Dx_CodeQuery(starts_with='466.0', type='icd9'),78 Dx_CodeQuery(starts_with='466.19', type='icd9'),79 Dx_CodeQuery(starts_with='478.9', type='icd9'),80 Dx_CodeQuery(starts_with='480.8', type='icd9'),81 Dx_CodeQuery(starts_with='480.9', type='icd9'),82 Dx_CodeQuery(starts_with='481', type='icd9'),83 Dx_CodeQuery(starts_with='482.40', type='icd9'),84 Dx_CodeQuery(starts_with='482.41', type='icd9'),85 Dx_CodeQuery(starts_with='482.42', type='icd9'),86 Dx_CodeQuery(starts_with='482.49', type='icd9'),87 Dx_CodeQuery(starts_with='484.8', type='icd9'),88 Dx_CodeQuery(starts_with='485', type='icd9'),89 Dx_CodeQuery(starts_with='486', type='icd9'),90 Dx_CodeQuery(starts_with='487.0', type='icd9'),91 Dx_CodeQuery(starts_with='487.1', type='icd9'),92 Dx_CodeQuery(starts_with='487.8', type='icd9'),93 Dx_CodeQuery(starts_with='784.1', type='icd9'),94 Dx_CodeQuery(starts_with='786.2', type='icd9'), 95 ]96 ))97 98 99 return heuristic_list100 101 102 @transaction.commit_on_success103 def generate(self):104 log.info('Generating cases of %s' % self.short_name) 105 106 dx_ev_names = ['dx:ili',]107 dx_fever_ev_names = ['dx:fever',]108 109 # adding cases for each criterion separately because django generates 110 # bad sql when you use '|' to combine query sets.111 #112 # Criteria Set #b 113 # diagnosis of ili and no temperature measured but diagnosis of fever 114 #115 116 dx_ili_fever_qs = Event.objects.filter(117 name__in = dx_ev_names,118 patient__event__name__in = dx_fever_ev_names,119 patient__event__encounter__exact = (F('encounter')),120 encounter__temperature__isnull=True,121 ) 122 ili_criteria_qs1 = dx_ili_fever_qs123 ili_criteria_qs1 = ili_criteria_qs1.exclude(case__condition='ili')124 ili_criteria_qs1 = ili_criteria_qs1.order_by('date')125 all_event_names = dx_ev_names + dx_fever_ev_names 126 127 counter = self._create_cases_from_event_qs( 128 condition = 'ili', 129 criteria = 'Criteria #2: dx:ili and no temp measured and dx:fever', 130 recurrence_interval = 42,131 event_qs = ili_criteria_qs1, 132 relevant_event_names = all_event_names )133 134 #135 # Criteria Set #a 136 # diagnosis of ili and measured temperature >= 100137 #138 139 dx_ili_measured_fever_qs = Event.objects.filter(140 name__in = dx_ev_names,141 encounter__temperature__gte = self.FEVER_TEMPERATURE,142 )143 ili_criteria_qs2 = dx_ili_measured_fever_qs 144 ili_criteria_qs2 = ili_criteria_qs2.exclude(case__condition='ili')145 ili_criteria_qs2 = ili_criteria_qs2.order_by('date')146 all_event_names = dx_ev_names 147 148 counter += self._create_cases_from_event_qs( 149 condition = 'ili', 150 criteria = 'Criteria #1: dx:ili and measured temp >= 100', 151 recurrence_interval = 42,152 event_qs = ili_criteria_qs2, 153 relevant_event_names = all_event_names )154 155 156 157 log.debug('Generated %s new cases of ili' % counter)158 159 return counter # Count of new cases160 161 162 163#-------------------------------------------------------------------------------164#165# Packaging166#167#-------------------------------------------------------------------------------168ili_definition = ili()169def event_heuristics():170 return ili_definition.event_heuristics171def disease_definitions():...

Full Screen

Full Screen

Rule34Crawler.py

Source:Rule34Crawler.py Github

copy

Full Screen

1import requests2from bs4 import BeautifulSoup345class Rule34Crawler():67 def __init__(self):8 self.Prefix = 'https://rule34.paheal.net'9 self.Target_Tag_URL = [10 'https://rule34.paheal.net/tags', # 取得所有Tag網址 跟 A TAG 011 'https://rule34.paheal.net/tags?starts_with=.', # . Tag 112 'https://rule34.paheal.net/tags?starts_with=%2F', # / Tag 213 'https://rule34.paheal.net/tags?starts_with=%3A', #: Tag 314 'https://rule34.paheal.net/tags?starts_with=%40', # @ Tag 415 'https://rule34.paheal.net/tags?starts_with=%5B', # [ Tag 516 'https://rule34.paheal.net/tags?starts_with=0', # 0 Tag 617 'https://rule34.paheal.net/tags?starts_with=1', # 1 Tag 718 'https://rule34.paheal.net/tags?starts_with=2', # 2 Tag 819 'https://rule34.paheal.net/tags?starts_with=3', # 3 Tag 920 'https://rule34.paheal.net/tags?starts_with=4', # 4 Tag 1021 'https://rule34.paheal.net/tags?starts_with=5', # 5 Tag 1122 'https://rule34.paheal.net/tags?starts_with=6', # 6 Tag 1223 'https://rule34.paheal.net/tags?starts_with=7', # 7 Tag 1324 'https://rule34.paheal.net/tags?starts_with=8', # 8 Tag 1425 'https://rule34.paheal.net/tags?starts_with=9', # 9 Tag 1526 'https://rule34.paheal.net/tags?starts_with=a', # A Tag 1627 'https://rule34.paheal.net/tags?starts_with=b', # B Tag 1728 'https://rule34.paheal.net/tags?starts_with=c', # C Tag 1829 'https://rule34.paheal.net/tags?starts_with=d', # D Tag 1930 'https://rule34.paheal.net/tags?starts_with=e', # E Tag 2031 'https://rule34.paheal.net/tags?starts_with=f', # F Tag 2132 'https://rule34.paheal.net/tags?starts_with=g', # G Tag 2233 'https://rule34.paheal.net/tags?starts_with=h', # H Tag 2334 'https://rule34.paheal.net/tags?starts_with=i', # I Tag 2435 'https://rule34.paheal.net/tags?starts_with=k', # J Tag 2536 'https://rule34.paheal.net/tags?starts_with=k', # K Tag 2637 'https://rule34.paheal.net/tags?starts_with=l', # L Tag 2738 'https://rule34.paheal.net/tags?starts_with=m', # M Tag 2839 'https://rule34.paheal.net/tags?starts_with=n', # N Tag 2940 'https://rule34.paheal.net/tags?starts_with=o', # O Tag 3041 'https://rule34.paheal.net/tags?starts_with=p', # P Tag 3142 'https://rule34.paheal.net/tags?starts_with=q', # Q Tag 3243 'https://rule34.paheal.net/tags?starts_with=r', # R Tag 3344 'https://rule34.paheal.net/tags?starts_with=s', # S Tag 3445 'https://rule34.paheal.net/tags?starts_with=t', # T Tag 3546 'https://rule34.paheal.net/tags?starts_with=u', # U Tag 3647 'https://rule34.paheal.net/tags?starts_with=v', # V Tag 3748 'https://rule34.paheal.net/tags?starts_with=w', # W Tag 3849 'https://rule34.paheal.net/tags?starts_with=x', # X Tag 3950 'https://rule34.paheal.net/tags?starts_with=y', # Y Tag 4051 'https://rule34.paheal.net/tags?starts_with=z', # Z Tag 4152 ]5354 # ----------------------------------------------------------------------------------------------55 # 取得Start_with 裡的 Tag 返回 String56 def Get_Tag_Content_String(self):57 Total = ''5859 try:6061 Target_URL = self.Target_Tag_URL[0]62 rs = requests.session()63 res = rs.get(Target_URL)64 soup = BeautifulSoup(res.text, 'html.parser')6566 except Exception as Errr:67 raise Errr6869 if res.status_code == 200:7071 for index, data in enumerate(soup.select('div.blockbody a')):72 if ('starts_with' in data['href'] or 'tags' in data['href']73 or 'bad_ads' in data['href'] or 'wiki/rules' in data['href'] or 'hentaikey' in data['href']74 or 'idzone=' in data['href'] or 'palcomix' in data['href'] or data['href'].endswith('list')):75 continue76 Total += (self.Prefix + data['href']) + '\n'7778 return Total7980 # 取得Start_with 裡的 Tag 返回List81 def Get_Tag_Content_List(self):82 Total = []8384 try:8586 Target_URL = self.Target_Tag_URL[0]87 rs = requests.session()88 res = rs.get(Target_URL)89 soup = BeautifulSoup(res.text, 'html.parser')9091 except Exception as Errr:92 raise Errr9394 if res.status_code == 200:9596 for index, data in enumerate(soup.select('div.blockbody a')):97 if ('starts_with' in data['href'] or 'tags' in data['href']98 or 'bad_ads' in data['href'] or 'wiki/rules' in data['href'] or 'hentaikey' in data['href']99 or 'idzone=' in data['href'] or 'palcomix' in data['href'] or data['href'].endswith('list')):100 continue101 Total.append((self.Prefix + data['href']))102103 return Total104105 # ----------------------------------------------------------------------------------------------106 # 取得照片連結107 def Get_Photo(self, URL):108 Total = ''109110 try:111112 rs = requests.session()113 res = rs.get(URL)114 soup = BeautifulSoup(res.text, 'html.parser')115116 except Exception as Errr:117 raise Errr118119 if res.status_code == 200:120 for index, data in enumerate(soup.select('div.blockbody div.shm-image-list a.shm-thumb-link')):121 Total += (self.Prefix + data['href']) + '\n'122 ...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...9 with open("result.txt", "w", encoding="utf-8") as file:10 file.write(str(result))11 def no_of_words(self):12 return len(self.words)13 def starts_with(self, s):14 return len([w for w in self.words15 if w[:len(s)]==s])16 def no_with_length(self, n):17 return len([w for w in self.words18 if len(w)==n])19s = input("Введите текст: ")20analyse = Analyser(s)21print(analyse.words)22print("Кол-во слов:", analyse.no_of_words())23print("Кол-во слов, начинающихся с 'а':",24 analyse.starts_with('а'))25print("Кол-во слов, начинающихся с 'б':",26 analyse.starts_with('б'))27print("Кол-во слов, начинающихся с 'в':",28 analyse.starts_with('в'))29print("Кол-во слов, начинающихся с 'г':",30 analyse.starts_with('г'))31print("Кол-во слов, начинающихся с 'д':",32 analyse.starts_with('д'))33print("Кол-во слов, начинающихся с 'е':",34 analyse.starts_with('е'))35print("Кол-во слов, начинающихся с 'ё':",36 analyse.starts_with('ё'))37print("Кол-во слов, начинающихся с 'ж':",38 analyse.starts_with('ж'))39print("Кол-во слов, начинающихся с 'з':",40 analyse.starts_with('з'))41print("Кол-во слов, начинающихся с 'и':",42 analyse.starts_with('и'))43print("Кол-во слов, начинающихся с 'й':",44 analyse.starts_with('й'))45print("Кол-во слов, начинающихся с 'к':",46 analyse.starts_with('к'))47print("Кол-во слов, начинающихся с 'л':",48 analyse.starts_with('л'))49print("Кол-во слов, начинающихся с 'м':",50 analyse.starts_with('м'))51print("Кол-во слов, начинающихся с 'н':",52 analyse.starts_with('н'))53print("Кол-во слов, начинающихся с 'о':",54 analyse.starts_with('о'))55print("Кол-во слов, начинающихся с 'п':",56 analyse.starts_with('п'))57print("Кол-во слов, начинающихся с 'р':",58 analyse.starts_with('р'))59print("Кол-во слов, начинающихся с 'с':",60 analyse.starts_with('с'))61print("Кол-во слов, начинающихся с 'т':",62 analyse.starts_with('т'))63print("Кол-во слов, начинающихся с 'у':",64 analyse.starts_with('у'))65print("Кол-во слов, начинающихся с 'ф':",66 analyse.starts_with('ф'))67print("Кол-во слов, начинающихся с 'х':",68 analyse.starts_with('х'))69print("Кол-во слов, начинающихся с 'ц':",70 analyse.starts_with('ц'))71print("Кол-во слов, начинающихся с 'ч':",72 analyse.starts_with('ч'))73print("Кол-во слов, начинающихся с 'ш':",74 analyse.starts_with('ш'))75print("Кол-во слов, начинающихся с 'щ':",76 analyse.starts_with('щ'))77print("Кол-во слов, начинающихся с 'ъ':",78 analyse.starts_with('ъ'))79print("Кол-во слов, начинающихся с 'ы':",80 analyse.starts_with('ы'))81print("Кол-во слов, начинающихся с 'ь':",82 analyse.starts_with('ь'))83print("Кол-во слов, начинающихся с 'э':",84 analyse.starts_with('э'))85print("Кол-во слов, начинающихся с 'ю':",86 analyse.starts_with('ю'))87print("Кол-во слов, начинающихся с 'я':",88 analyse.starts_with('я'))89print("Количество слов из 4 букв:",90 analyse.no_with_length(4))...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful