第二次作业3121001738
git仓库链接
PSP表格
PSP2.1 |
Personal Software Process Stages |
预计耗时(分钟) |
实际耗时(分钟) |
planning |
计划 |
20 |
35 |
· Estimate |
· 估计这个任务需要多少时间 |
650 |
750 |
Development |
开发 |
60 |
90 |
· Analysis |
· 需求分析 (包括学习新技术) |
200 |
250 |
· Design Spec |
· 生成设计文档 |
30 |
30 |
· Design Review |
· 设计复审 |
20 |
25 |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
20 |
35 |
· Design |
· 具体设计 |
30 |
60 |
· Coding |
· 具体编码 |
80 |
100 |
· Code Review |
· 代码复审 |
10 |
20 |
· Test |
· 测试(自我测试,修改代码,提交修改) |
45 |
60 |
Reporting |
报告 |
20 |
35 |
· Test Repor |
· 测试报告 |
10 |
15 |
· Size Measurement |
· 计算工作量 |
5 |
10 |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
10 |
20 |
· 合计 |
|
645 |
785 |
代码设计
import sys
original_file_path = sys.argv[1]
plagiarized_file_path = sys.argv[2]
output_file_path = sys.argv[3]
def extract_keywords(text):
words = jieba.cut(text)
keywords = [word for word in words if word not in stop_words]
return " ".join(keywords)
def calculate_cosine_similarity(text1, text2):
vectorizer = CountVectorizer().fit_transform([text1, text2])
vectors = vectorizer.toarray()
return cosine_similarity(vectors[0].reshape(1, -1), vectors[1].reshape(1, -1))[0][0]
性能分析

代码比较简单,时间大部分在命令行输入上,可以考虑一下内置文本可能会更高效一点
异常处理
if len(sys.argv) != 4:
print("Usage: python main.py <original_text_file> <plagiarized_text_file> <output_file>")
sys.exit(1)
else:
print("输入错误")
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步