Altshuller矛盾矩阵查询:基于python和streamlit

基于python和streamlit实现的Altshuller矛盾矩阵查询

import streamlit as st
import json# 加载数据
@st.cache_resource
def load_data():with open('parameter.json', encoding='utf-8') as f:parameters = json.load(f)with open('way.json', encoding='utf-8') as f:contradictions = json.load(f)with open('function.json', encoding='utf-8') as f:functions = json.load(f)return parameters, contradictions, functions# 自定义CSS样式
def inject_css():st.markdown("""<style>.card {background: #fff;border-radius: 10px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .2);padding: 12px;margin: 10px 0;}.title {font-size: 16px;color: #000000;border-bottom: 1px solid #e8eaec;padding-bottom: 8px;margin-bottom: 8px;}.content {font-size: 14px;color: #515a6e;}</style>""", unsafe_allow_html=True)def main():st.set_page_config(page_title="矛盾矩阵查询", layout="wide")inject_css()st.title("Altshuller矛盾矩阵查询")# 加载数据parameters, contradictions, functions = load_data()# 创建下拉选择框col1, col2 = st.columns(2)with col1:better_options = {p["key"]: f'{p["key"]}.{p["parameter"]}' for p in parameters}better_param = st.selectbox("改善参数",options=[""] + list(better_options.keys()),format_func=lambda x: "选择改善参数" if x == "" else better_options.get(x, x))with col2:worsen_options = {p["key"]: f'{p["key"]}.{p["parameter"]}' for p in parameters}worsen_param = st.selectbox("恶化参数",options=[""] + list(worsen_options.keys()),format_func=lambda x: "选择恶化参数" if x == "" else worsen_options.get(x, x))# 查询按钮if st.button("查询"):if not better_param or not worsen_param:st.warning("请选择改善参数和恶化参数")return# 查找矛盾contradiction = next((c for c in contradictions if c["worsen"] == worsen_param and c["better"] == better_param),None)if not contradiction:st.error("没有找到对应的矛盾信息")returnway = contradiction["way"]# 处理不同情况if way == "+":st.warning("产生的矛盾是物理矛盾")elif way == "-":st.info("没有找到合适的发明原理来解决问题,当然只是表示研究的局限,并不代表不能够应用发明原理。")elif way == "":st.info("没有找到发明原理。")else:# 显示发明原理function_keys = way.split(",")results = []for key in function_keys:func = next((f for f in functions if f["key"] == key), None)if func:html = f"""<div class="card"><div class="title">{func['key']}.{func['way']}原理</div><div class="content"><p>内容:{func['describe']}</p><p>例子:{func['examples']}</p></div></div>"""results.append(html)if results:st.markdown("".join(results), unsafe_allow_html=True)else:st.info("未找到对应的发明原理详细信息")if __name__ == "__main__":main()
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache,must-revalidate"><meta http-equiv="Cache" content="no-cache"><title>矛盾矩阵查询</title>
</head>
<style>.card {background: #fff;border-radius: 10px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .2);padding-bottom: 12px;margin-top: 16px;}#searchForm {padding-top: 16px;background: #fff;border-radius: 10px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .2);padding-bottom: 12px;margin-top: 16px;padding-left: 16px;padding-right: 16px;}.header {text-align: center;font-size: 20px;}select {display: inline-block;right: 0;margin-top: 2px;width: 100%;height: 30px;border-radius: 5px;}button {border: none;outline: none;display: inline-block;margin-top: 16px;width: 100%;border-radius: 5px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .2);height: 30px;background: #1890ff;color: #fff;}.card>p {padding-left: 16px;padding-right: 16px;color: #515a6e;font-size: 12px;}.title {border-bottom: 1px solid #e8eaec;padding: 14px 16px;line-height: 1;color: #000000;font-size: 15px;}.result {width: 95vw;margin: 2vw auto;}.result>div {margin-top: 2vw;}body {height: 100%;margin: 2vw;padding: 0;background-color: #f0f2f5;font-size: 15px;}
</style><body><div class="header">Altshuller矛盾矩阵查询</div><form id="searchForm"><label for="betterParam">改善参数:</label><select id="betterParam"><option value="">选择改善参数</option></select><br><label for="worsenParam">恶化参数:</label><select id="worsenParam"><option value="">选择恶化参数</option></select><br><button type="submit">查询</button></form><div id="result"></div><script>// 获取参数数据fetch('parameter.json').then(response => response.json()).then(parameters => {// 动态生成恶化参数选项const worsenParamSelect = document.getElementById('worsenParam');parameters.forEach(param => {const option = document.createElement('option');option.value = param.key;option.textContent = param.key + "." + param.parameter;worsenParamSelect.appendChild(option);});});// 获取发明原理数据fetch('parameter.json').then(response => response.json()).then(parameters => {// 动态生成改善参数选项const betterParamSelect = document.getElementById('betterParam');parameters.forEach(param => {const option = document.createElement('option');option.value = param.key;option.textContent = param.key + "." + param.parameter;betterParamSelect.appendChild(option);});});// 处理查询请求document.getElementById('searchForm').addEventListener('submit', function (e) {e.preventDefault(); // 阻止表单提交const worsenParamKey = document.getElementById('worsenParam').value;const betterParamKey = document.getElementById('betterParam').value;// 发起查询请求或执行其他操作console.log(worsenParamKey);console.log(betterParamKey);// 示例查询handleSearchRequest(worsenParamKey, betterParamKey);});// 查询请求处理函数function handleSearchRequest(worsenParamKey, betterParamKey) {return fetch('way.json').then(response => response.json()).then(contradictions => {return fetch('function.json').then(response => response.json()).then(functions => {const contradiction = contradictions.find(c => c.worsen === worsenParamKey && c.better === betterParamKey);if (contradiction) {console.log(contradiction.way)if (contradiction.way == "+") {alert("产生的矛盾是物理矛盾");return;}if (contradiction.way == "-") {alert("没有找到合适的发明原理来解决问题,当然只是表示研究的局限,并不代表不能够应用发明原理。");return;}if (contradiction.way == "") {alert("没有找到发明原理。");return;}const functionKeys = contradiction.way.split(",");let result = "";functionKeys.forEach(functionKey => {const func = functions.find(f => f.key === functionKey);if (func) {result += `<div class="card"><div class="title">${func.key + '.' + func.way + '原理'}</div><p>内容:${func.describe}</p><p>例子:${func.examples}</p></div>`;}});document.getElementById('result').innerHTML = result;return;} else {alert("未选择");return;}});});}</script></body></html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/76812.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Maven的下载配置及在Idea中的配置

编写项目管理中存在的问题 在大型Java项目开发中&#xff0c;依赖管理是一个极其复杂的挑战。传统方式下&#xff0c;开发者需要手动下载并引入数十甚至上百个JAR包到项目中&#xff0c;这一过程不仅繁琐低效&#xff0c;还存在诸多痛点&#xff1a; 依赖传递性问题&#xff1a…

来聊聊C++中的vector

一.vector简介 vector是什么 C 中的 vector 是一种序列容器&#xff0c;它允许你在运行时动态地插入和删除元素。 vector 是基于数组的数据结构&#xff0c;但它可以自动管理内存&#xff0c;这意味着你不需要手动分配和释放内存。 与 C 数组相比&#xff0c;vector 具有更多的…

WVP-GB28181摄像头管理平台存在弱口令

免责声明&#xff1a;本号提供的网络安全信息仅供参考&#xff0c;不构成专业建议。作者不对任何由于使用本文信息而导致的直接或间接损害承担责任。如涉及侵权&#xff0c;请及时与我联系&#xff0c;我将尽快处理并删除相关内容。 漏洞描述 攻击者可利用漏洞获取当前系统管…

讯飞语音听写(流式版)开发指南

语音交互大模型的功能越来越受到重视。讯飞语音听写&#xff08;流式版&#xff09;为开发者提供了一种高效、准确的语音识别解决方案。本文将基于 Home.vue、iat_xfyun.js 和 sparkChat.js 这三个文档&#xff0c;详细阐述讯飞语音听写&#xff08;流式版&#xff09;的开发逻…

基于kotlin native的C与kotlin互相调用

本文测试环境为ubuntu&#xff0c;没有使用IDE&#xff1b;从基本层面了解kotlin native环境中&#xff0c;C和kotlin的编译&#xff0c;互相调用。 1. kotlin 动态库 1.1 动态库编译 源码文件libktest.kt&#xff1a; //file name:libktest.kt OptIn(kotlin.experimental.…

【教学类-102-02】自制剪纸图案(留白边、沿线剪)02——Python+PS自动化添加虚线边框

背景需求: 01版本实现了对透明背景png图案边界线的扩展,黑线实线描边 【教学类-102-01】自制剪纸图案(留白边、沿线剪)01-CSDN博客文章浏览阅读974次,点赞15次,收藏7次。【教学类-102-01】自制剪纸图案(留白边、沿线剪)01https://blog.csdn.net/reasonsummer/article…

Python-函数参数

1. 参数基础 函数参数是向函数传递数据的主要方式&#xff0c;Python 提供了多种参数传递机制。 基本用法 def greet(name): # name 是形式参数print(f"Hello, {name}!")greet("Alice") # "Alice" 是实际参数使用场景&#xff1a;当函数需要…

《在 Ubuntu 22.04 上安装 CUDA 11.8 和 Anaconda,并配置环境变量》

安装 CUDA 11.8 和 Anaconda 并配置环境变量 在本教程中&#xff0c;我们将介绍如何在 Ubuntu 22.04 上安装 CUDA 11.8 和 Anaconda&#xff0c;并配置相应的环境变量。我们还将配置使用 阿里云镜像源 来加速软件包更新。以下是具体步骤。 步骤 1&#xff1a;更新软件源 首先…

Ubuntu环境基于Ollama部署DeepSeek+Open-Webui实现本地部署大模型-无脑部署

Ollama介绍 Ollama是一款简单好用的模型部署工具,不仅可以部署DeepSeek,市面上开源模型大部分都可以一键部署,这里以DeepSeek为例 官网 DeepSeek 版本硬件要求 安装Ollama 环境 sudo apt update sudo apt install curl sudo apt install lsof1.命令一键安装 在官网点击…

Angular 项目 PDF 批注插件库在线版 API 示例教程

本文章介绍 Angular 项目中 PDF 批注插件库 ElasticPDF 在线版 API 示例教程&#xff0c;API 包含 ① 导出批注后PDF数据&#xff1b;② 导出纯批注 json 数据&#xff1b;③ 加载旧批注&#xff1b;④ 切换文档&#xff1b;⑤ 切换用户&#xff1b;⑥ 清空批注 等数据处理功能…

Spring Boot 中利用 Jasypt 实现数据库字段的透明加密解密

1. 引言 1.1 什么是 Jasypt Jasypt(Java Simplified Encryption)是一个用于简化 Java 应用程序中加密操作的库。 1.2 为什么使用 Jasypt 简化加密操作:提供简单的 API 进行加密和解密。透明加密:自动处理加密和解密过程,无需手动干预。多种加密算法:支持多种加密算法,…

Linux的: /proc/sys/net/ipv6/conf/ 笔记250405

Linux的: /proc/sys/net/ipv6/conf/ /proc/sys/net/ipv6/conf/ 是 Linux 系统中用于 动态配置 IPv6 网络接口参数 的核心目录。它允许针对不同网络接口&#xff08;如 eth0、wlan0&#xff09;或全局设置&#xff08;all&#xff09;调整 IPv6 协议栈的行为。 它通过虚拟文件系…

Spring Cloud 框架为什么能处理高并发

Spring Cloud框架能够有效处理高并发场景&#xff0c;核心在于其微服务架构设计及多组件的协同作用&#xff0c;具体机制如下&#xff1a; 一、分布式架构设计支撑高扩展性 服务拆分与集群部署 Spring Cloud通过微服务拆分将单体系统解耦为独立子服务&#xff0c;每个服务可独…

无人机智慧路灯杆:智慧城市的‘全能助手’

在城市发展的进程中&#xff0c;智慧路灯杆作为智慧城市建设的关键载体&#xff0c;正逐步从传统的照明设备转型为集多种功能于一体的智能基础设施。无人机与智慧路灯杆的创新性融合&#xff0c;为城市管理和服务带来了全新的变革与机遇。 一、无人机智慧路灯杆的功能概述 照…

Libevent UDP开发指南

UDP 与 TCP 的核心区别 无连接:不需要建立/维护连接 不可靠:不保证数据包顺序和到达 高效:头部开销小,没有连接管理负担 支持广播/多播:可以向多个目标同时发送数据 一、基础UDP服务器实现 1. 创建 UDP 套接字 #include <event2/event.h> #include <event2/lis…

基于阿里云可观测产品构建企业级告警体系的通用路径与最佳实践

前言 1.1 日常生活中的告警 任何连续稳定运行的生产系统都离不开有效的监控与报警机制。通过监控&#xff0c;我们可以实时掌握系统和业务的运行状态&#xff1b;而报警则帮助我们及时发现并响应监控指标及业务中的异常情况。 在日常生活中&#xff0c;我们也经常遇到各种各样…

智能多媒体处理流水线——基于虎跃办公API的自动化解决方案

在内容爆炸的时代&#xff0c;多媒体文件处理&#xff08;图片压缩、视频转码、音频降噪&#xff09;已成为内容生产者的日常挑战。本文将演示如何基于虎跃办公的多媒体处理API&#xff0c;构建自动化处理流水线&#xff0c;实现&#xff1a; 批量文件智能分类格式自动转换质量…

01-STM32(介绍、工具准备、新建工程)p1-4

文章目录 工具准备和介绍硬件设备stm32简介和arm简介stm32简介STM32命名规则STM32选型STM32F103C8T6最小系统板引脚定义STM32启动配置STM32最小系统电路ARM简介 软件安装注册器件支持包安装ST-LINK驱动安装USB转串口驱动 新建工程创建stm32工程STM32工程编译和下载型号分类及缩…

【ABAP】REST/HTTP技术(一)

1、概念 1.1、SAP 如何提供 Http Service 如果要将 SAP 应用程序服务器 &#xff08;application server&#xff09;作为 http 服务提供者&#xff0c;需要定义一个类&#xff0c;这个类必须实现 IF_HTTP_EXTENSION 接口。IF_HTTP_EXTENSION 接口只有一个方法 HANDLE_REQUEST。…

[实战] linux驱动框架与驱动开发实战

linux驱动框架与驱动开发实战 Linux驱动框架与驱动开发实战一、Linux驱动框架概述1.1 Linux驱动的分类1.2 Linux驱动的基本框架 二、Linux驱动关键API详解2.1 模块相关API2.2 字符设备驱动API2.3 内存管理API2.4 中断处理API2.5 PCI设备驱动API 三、Xilinx XDMA驱动开发详解3.1…