EE308 LAB1-2
| The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZU202201 |
|---|---|
| The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/608734907 |
| The Aim of This Assignment | GitHub Using & Keywords Counting |
| MU STU ID and FZU STU ID | 20124805_832001130 |
| github | https://github.com/Blue-Ice03/EE308-LAB1_2 |
1. PSP TABLE
| · Estimate | · 估计这个任务需要多少时间 | ||
| · Analysis | · 需求分析 (包括学习新技术) | ||
| · Design Spec | · 生成设计文档 | ||
| · Design Review | · 设计复审 (和同事审核设计文档) | ||
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | ||
| · Design | · 具体设计 | ||
| · Coding | · 具体编码 | ||
| · Code Review | · 代码复审 | ||
| · Test | · 测试(自我测试,修改代码,提交修改) | ||
| · Test Report | · 测试报告 | ||
| · Size Measurement | · 计算工作量 | ||
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | ||
2. PROBLEM-SOLVING IDEAS
Subject Analysis
The questions have four levels of requirements, each of which increases in difficulty, and the latter level includes the requirements of the previous level. So the inspiration for me is that when coding, you can start at the front and gradually increase the code to achieve higher level requirements.Keyword Search
To retrieve the keyword content of a file, we read the file into a string or vector and use the string::find() function to retrieve the file. The key and most important issue is to make sure that the keyword retrieved is a keyword, that is, you cannot select the same part of the variable name, comment, function name as the keyword.Choice of Language —— Python
The first question is the choice of language. I briefly review the languages I have learned. I first learned Python, and then I learned C and C++. Among several languages, the one I am most familiar with is Python, because I have recently learned it and am proficient in using it. Another reason is that there are relatively many libraries to call in Python, and the code is relatively simple to implement.Fixed Structure Search
This is followed by quantitative lookups for switch-case, if-else, and if-elseif-else constructs.I learned pushing、 popping and so on, through the establishment of stack count.
3. THE FLOW CHART

4. CODE DESCRIPTION
Ⅰ. Read File
f = open(r"D:\daima.txt","r",encoding="utf-8") # open file
data = f.read() # read file
Ⅱ. Count the Number of Keywords
data = re.sub(r"\"[\S\s]*?\"", "", data) # Delete comments and quotes
data = re.sub(r"\/\*[\S\s]*?\*\/", "", data)
res = re.findall(r'\bdo\b',data) # Look up the list of do's from data
total += len(res) # count the number of DO's by LEN
Ⅲ. Count the Number of Switches
This part is same to the part 2
Ⅳ. Count the Number of Cases in each set of Switch Structures
Check Switch first and start checking cases and counting. If you encounter default or the next Switch or the file is finished, stop and save the number of cases.
i = 0
k = len(f.readlines()) # Total number of rows
f.seek(0)
for i in range(k):
data = f.readline().strip() # Read line by line
data = re.sub(r"\"[\S\s]*?\"", "", data)
data = re.sub(r"\/\*[\S\s]*?\*\/", "", data)
res = re.findall(r'\bswitch\b', data)
if flag == 1 and len(res) > 0: # The next switch structure is encountered
flag = 2
if len(res) > 0 and flag == 0: # Find the switch structure
flag = 1
if flag == 1:
res = re.findall(r'\bcase\b', data)
t2 = t2 + len(res)
res = re.findall(r'\bdefault\b', data)
if len(res) > 0: # exit at default
flag = 0
arva[x] = t2 # Save the number of case
x = x + 1
t2 = 0 # t2 reset
if flag == 2: # meet the next switch structure
flag = 1 # Prepare to count the number of cases for the next switch structure
arva[x] = t2 # Save the number of case
x = x + 1
t2 = 0 # t2 reset
if i == k - 1 and t2 != 0: # There is no default and switch
arva[x] = t2 # Save the number of case
x = x + 1
t2 = 0 # t2 reset
Ⅴ. Count the number of if-else structures and if-elseif-else structures
Met with elseif if 1 stack, stack 2, meet {stack 3, meet the else judge which structure belongs to the else, met} see whether ordinary braces can delete directly, or used to control the level of the level of finish can match the match can not match the delete to delete the curly braces.
res = re.findall(r'\bif\b', data)
res1 = re.findall(r'\belse\b', data)
res2 = re.findall(r'{', data)
res3 = re.findall(r'}', data)
if (len(res) > 0) and (len(res1) == 0): # Only if with NO else
st.push(1) # 1 push
if (len(res) > 0) and (len(res1) > 0): # if AND else
st.push(2) # 2 push
if (len(res1) > 0) and (len(res) == 0): #ONLY else NO if
if st.isEmpty() == False and st.peek() == 2:
t4 = t4 + 1
while st.peek() == 2: # delete all of the elseif
st.pop()
st.pop() # delete if
if st.isEmpty() == False and st.peek() == 1:
t3 = t3 + 1
st.pop() # delete if
if (len(res2) > 0):
st.push(3)
if (len(res3) > 0):
if st.isEmpty() == False and st.peek() == 3:
st.pop()
elif (st.isEmpty() == False and st.peek() == 2) or (st.isEmpty() == False and st.peek() == 1):
while st.peek() != 3:
st.pop()
st.pop()
5. PRESENT THE OUTCOME

6. SUMMARY
Compared with the simple coding tasks assigned by the teacher before, this experiment was a great challenge, because it was also the first time for me to try to complete a difficult programming task from beginning to end. I encountered many difficulties in the process, but I successfully solved them through continuous learning of relevant knowledge. I hope that I can keep this spirit of not afraid of difficulties in my future study, and keep learning and improving myself.
相关推荐
EE-308 LAB4 final version.7z
这是本次实验的压缩包
早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径.docx
早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径
科技服务机构促成校企合作时,需遵循哪些规范化操作流程?.docx
科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。
美国5435家医院CMS星级质量评级数据集
本数据集基于美国CMS官办的医院质量比较数据库整理加工,覆盖美国56个州和地区的5435家医院,每条记录包含53个字段。数据以医院名录为基础,融合质量评级与衍生分析字段:既有医院名称、地址、所在县州、邮编、电话等基础信息,也包含医院类型、所有制类型、是否提供急诊服务等分类属性,核心是官方发布的总体星级评级与死亡相关指标表现统计(更好、无差异、更差三类计数及脚注),并额外提供所有制分组、急症护理与产科友好标识、评级分档、指标覆盖率、更好更差比率、净指标得分、高评级标记以及各院在本州医院中的占比等衍生字段。其中3166家医院拥有总体评级,4501家提供急诊服务。适用人群:医疗政策研究者、卫生统计分析师、医疗质量管理人员、公共卫生专业师生以及数据科学爱好者。使用场景:适合开展医院质量与所有制关系研究、各州医疗资源与评级分布对比、急诊服务覆盖缺口分析、评级影响因素建模与预测、医院地理分布与可达性研究等课题。其他说明:文件为CSV格式,附带数据字典与说明文档,字段规整、注释完备,可直接导入Python、R、Excel、PowerBI等工具使用,适合课程作业、毕业设计与商业演示,也可作为医疗领域数据仓库建模的入门样例。
战国BC401年世界历史地图矢量文件SHP格式.zip
本资源为《战国BC401年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.26 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。


