diff --git a/AI/Neo4j/N3_InputShiTi.py b/AI/Neo4j/N3_InputShiTi.py index 821e6d1e..b19dd8b0 100644 --- a/AI/Neo4j/N3_InputShiTi.py +++ b/AI/Neo4j/N3_InputShiTi.py @@ -293,16 +293,4 @@ if __name__ == '__main__': for q in test_cases: print("\n" + "=" * 60) analyzer = ProblemAnalyzer(q) - analyzer.execute() - - #query_question('6fff79108736') - #query_question('6fff79108736') - - ''' - MATCH (q:Question {id: '6fff79108736'}) - OPTIONAL MATCH (q)-[:REQUIRES_KNOWLEDGE]->(kp) - OPTIONAL MATCH (q)-[:DEVELOPS_LITERACY]->(lp) - RETURN q.content AS content, - collect(kp.name) AS knowledge, - collect(lp.title) AS literacy - ''' \ No newline at end of file + analyzer.execute() \ No newline at end of file diff --git a/AI/Neo4j/N4_PrintShiTi.py b/AI/Neo4j/N4_PrintShiTi.py new file mode 100644 index 00000000..6ee49bee --- /dev/null +++ b/AI/Neo4j/N4_PrintShiTi.py @@ -0,0 +1,62 @@ +from py2neo import Graph +import json +from Config import * + +def query_all_questions(): + # Neo4j连接配置 + neo4j_config = { + "uri": NEO4J_URI, # 从Config导入 + "auth": NEO4J_AUTH # 从Config导入 + } + + # 初始化图数据库连接 + graph = Graph(**neo4j_config) + + try: + # 获取所有试题ID + question_ids = graph.run( + "MATCH (q:Question) RETURN q.id AS question_id" + ).data() + + results = [] + + # 遍历每个试题 + for record in question_ids: + qid = record['question_id'] + # 执行查询 + data = graph.run(""" + MATCH (q:Question {id: $qid}) + OPTIONAL MATCH (q)-[:REQUIRES_KNOWLEDGE]->(kp:KnowledgePoint) + OPTIONAL MATCH (q)-[:DEVELOPS_LITERACY]->(lp:LiteracyNode) + RETURN + q.content AS content, + collect(DISTINCT kp.name) AS knowledge_points, + collect(DISTINCT lp.title) AS literacy_points + """, qid=qid).data() + + if data: + result = { + "question_id": qid, + "content": data[0]['content'], + "knowledge_points": data[0]['knowledge_points'], + "literacy_points": data[0]['literacy_points'] + } + results.append(result) + # 实时打印结果 + print(f"\n试题ID: {qid}") + print(f"内容: {result['content'][:50]}...") + print(f"知识点: {result['knowledge_points']}") + print(f"素养点: {result['literacy_points']}") + + # 保存结果到JSON文件 + with open('question_analysis.json', 'w', encoding='utf-8') as f: + json.dump(results, f, ensure_ascii=False, indent=2) + + print("\n✅ 所有试题分析结果已保存到 question_analysis.json") + + except Exception as e: + print(f"❌ 查询失败: {str(e)}") + + +if __name__ == '__main__': + query_all_questions() \ No newline at end of file diff --git a/AI/Neo4j/question_analysis.json b/AI/Neo4j/question_analysis.json new file mode 100644 index 00000000..f79e8d21 --- /dev/null +++ b/AI/Neo4j/question_analysis.json @@ -0,0 +1,168 @@ +[ + { + "question_id": "9d29e7ced4c1", + "content": "小明用50元买了3本笔记本每本8元还剩多少钱", + "knowledge_points": [ + "整数的乘法及应用" + ], + "literacy_points": [ + "运算策略(3-4年级)" + ] + }, + { + "question_id": "6fff79108736", + "content": "甲乙两车相距300公里甲车速度60kmh乙车40kmh几小时后相遇", + "knowledge_points": [ + "简单的行程问题" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + }, + { + "question_id": "3f626d219ddb", + "content": "一个长方形花坛长5米宽3米四周铺1米宽的小路求小路面积", + "knowledge_points": [ + "组合图形的面积" + ], + "literacy_points": [ + "空间观念", + "几何推理(5-6年级)" + ] + }, + { + "question_id": "33d8efe73553", + "content": "某班30人数学成绩90分以上占158089分占13求80分以下人数", + "knowledge_points": [ + "分数的四则混合运算", + "分数四则复合应用题" + ], + "literacy_points": [ + "灵活运算(5-6年级)", + "模型构建(5-6年级)" + ] + }, + { + "question_id": "6df3d2cff448", + "content": "鸡兔同笼头共10个脚共28只问鸡兔各多少", + "knowledge_points": [ + "假设法" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + }, + { + "question_id": "f5fabea3b0fb", + "content": "配制农药药液药粉和水的比例是3100现有水500kg需要多少药粉", + "knowledge_points": [ + "比的意义", + "比的应用" + ], + "literacy_points": [ + "数关系抽象(5-6年级)" + ] + }, + { + "question_id": "70c34156e0ea", + "content": "某物体做匀加速运动初速度2ms加速度05ms²写出速度v与时间t的关系式", + "knowledge_points": [ + "用字母表示数", + "方程的意义" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + }, + { + "question_id": "dd460b64e4cb", + "content": "圆柱形水桶底面半径04米高12米求它的容积π取314", + "knowledge_points": [ + "圆柱的特征", + "体积、容积及其单位", + "体积、容积进率及单位换算" + ], + "literacy_points": [ + "空间观念", + "几何推理(5-6年级)" + ] + }, + { + "question_id": "5b310a1df4d3", + "content": "掷两个骰子点数和为7的概率是多少", + "knowledge_points": [ + "简单事件发生的可能性求解" + ], + "literacy_points": [ + "数据分析(5-6年级)" + ] + }, + { + "question_id": "67af09ee2951", + "content": "甲队单独完成工程需20天乙队需30天两队合作需要多少天", + "knowledge_points": [ + "简单的工程问题" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + }, + { + "question_id": "7a3b312878ed", + "content": "用20米篱笆围矩形菜地怎样围面积最大最大面积是多少", + "knowledge_points": [ + "列方程解应用题", + "式与方程", + "方程的意义", + "长方形的周长", + "方程的解和解方程", + "用字母表示数", + "含字母式子的求值", + "长方形、正方形的面积" + ], + "literacy_points": [ + "模型构建(5-6年级)", + "建模能力" + ] + }, + { + "question_id": "e127ab5859b7", + "content": "本金10000元年利率35存3年到期本息合计多少", + "knowledge_points": [ + "存款利息与纳税相关问题" + ], + "literacy_points": [ + "数关系抽象(5-6年级)" + ] + }, + { + "question_id": "63be6846a6df", + "content": "等差数列首项5公差3求第10项的值", + "knowledge_points": [ + "数列中的规律" + ], + "literacy_points": [ + "数关系抽象(5-6年级)" + ] + }, + { + "question_id": "635de0d75104", + "content": "在比例尺15000的地图上2cm线段代表实际距离多少米", + "knowledge_points": [ + "图上距离与实际距离的换算" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + }, + { + "question_id": "9a18968fea32", + "content": "A说B在说谎B说C在说谎C说AB都在说谎问谁在说真话", + "knowledge_points": [ + "逻辑推理" + ], + "literacy_points": [ + "模型构建(5-6年级)" + ] + } +] \ No newline at end of file