textx_model
介绍
以textX为基础构建出可运行条件规则语句然后输出结果的模型
条件规则语句(例):"(current_medical_program = '白细胞计数') and (specimen_type = '全血') and "
"(medicine_projects in '[1,2,3]') and (time < 6)"
-
当里面变量是:"current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 5;"
结果输出: True
-
当里面变量是:"current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 8;"
结果输出: False
功能介绍
包含两个模型:通用模型(general_model)和 case when 专用模型(cs_model),它们处理的条件规则语句不同。
包含一个工具:字典转字符串工具(dict_to_str)
-
通用模型
能处理的条件规则语句(例):"(current_medical_program = '白细胞计数') and (specimen_type = '全血') and "
"(medicine_projects in '[1,2,3]') and (time < 6)"使用通用模型: from textx_model import general_model
-
case when 专用模型
能处理的条件规则语句(例):"case when (current_medical_program = '白细胞计数') and (specimen_type = '全血') and "
"(medicine_projects in '[1,2,3]') and (time < 6) then '提醒消息:白细胞计数的消息' else ''"使用case when 专用模型
from textx_model import cs_model
-
字典转字符串工具
from textx_tools import dict_to_str
安装教程
- pip install textx-model
使用说明
-
通用模型
from textx_model import general_model
rule = "(current_medical_program = '白细胞计数') and (specimen_type = '全血') and "
"(medicine_projects in '[1,2,3]') and (time < 6)"true_example = "current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 5;"
false_example = "current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 8;"
gm = general_model(true_example, rule)
print(gm.run()) # 预期结果:True
gm = general_model(false_example, rule)
print(gm.run()) # 预期结果:False
-
case when 专用模型
from textx_model import cs_model
rule = "case when (current_medical_program = '白细胞计数') and (specimen_type = '全血') and "
"(medicine_projects in '[1,2,3]') and (time < 6) then '提醒消息:白细胞计数的消息' else ''"true_example = "current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 5;"
false_example = "current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 8;"
cs = cs_model(true_example, rule)
print(cs.run()) # 预期结果:提醒消息:白细胞计数的消息
cs = cs_model(false_example, rule)
print(cs.run()) # 预期结果:''
-
字典转字符串工具
from textx_tools import dict_to_str
data_dict = { 'current_medical_program': '白细胞计数', 'specimen_type': '全血', 'medicine_projects': '2', 'time': 8, '_list': [1, 2, 3] }
""" 预期结果: "current_medical_program = '白细胞计数';specimen_type = '全血';medicine_projects = '2';time = 8;_list = '[1,2,3]';" """
print(dict_to_str(data_dict))
Metadata
Release files for textx-model 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| textx-model-0.0.5.tar.gz | 8.9 kB | Without provenance | Details for textx-model-0.0.5.tar.gz |
Release files / textx-model-0.0.5.tar.gz
| Download URL | textx-model-0.0.5.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfacb21984f8cb6cfd94b3fe5396ff885bf012f12699ed60477172e2b3986775
|
|
BLAKE2b-256 checksum How to use checksums |
795e1683dc24fc92cc1b12f738986c2d66a6ea4cf1984323d3f845a05a58a210
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Security for textx-model 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.