feat(reasoner): support necessary rule expression (#531)

This commit is contained in:
wangshaofei 2025-03-20 16:47:09 +08:00 committed by GitHub
parent b449fa9a1b
commit 11be8cdbb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 2 deletions

View File

@ -84,4 +84,5 @@ If you use this software, please cite it as below:
[Apache License 2.0](LICENSE)
# OpenSPG Core Team
Lei Liang, Mengshu Sun, Zhengke Gui, Zhongshu Zhu, Zhouyu Jiang, Ling Zhong, Peilong Zhao, Zhongpu Bo, Jin Yang, Huaidong Xiong, Lin Yuan, Jun Xu, Zaoyang Wang, Zhiqiang Zhang, Wen Zhang, Huajun Chen, Wenguang Chen, Jun Zhou, Haofen Wang

View File

@ -83,5 +83,6 @@ OpenSPG核心能力模型包括
[Apache License 2.0](LICENSE)
# OpenSPG 核心团队
梁磊,孙梦姝,桂正科,朱仲书,江洲钰,钟玲,赵培龙,伯仲璞,阳进,熊怀东,袁琳,徐军,汪兆洋,张志强,张文,陈华钧,陈文光,周俊,王昊奋

View File

@ -543,6 +543,7 @@ REPEAT : 'repeat' ;
WHERE : ('W' | 'w')('H' | 'h')('E' | 'e')('R' | 'r')('E' | 'e') ;
MATCH : ('M' | 'm')('A' | 'a')('T' | 't')('C' | 'c')('H' | 'h') ;
RETURN : ('R' | 'r')('E' | 'e')('T' | 't')('U' | 'u')('R' | 'r')('N' | 'n') ;
PRIORITY : ('P' | 'p')('R' | 'r')('I' | 'i')('O' | 'o')('R' | 'r')('I' | 'i')('T' | 't')('Y' | 'y');
DEFINE_PRIORITY : 'DefinePriority' ;
DESCRIPTION : 'Description';
// rule 表达式
@ -718,6 +719,7 @@ double_solidus : '//' ;
underscore : '_' ;
vertical_bar : '|' ;
labmda_body_array : '=>' ;
necessary_symbol : '<=' ;
separator : ( comment|whitespace )+ ;
whitespace : WHITESPACE ;
@ -967,6 +969,7 @@ thinker_script: (
| define_rule_on_relation_to_concept
| define_proiority_rule_on_concept
| logical_deduce
| necessary_logical_deduce
)*;
/*
@ -983,12 +986,14 @@ Define (Med.drug)-[基本用药方案]->(药品/`ACEI+噻嗪类利尿剂`) {
*/
define_rule_on_relation_to_concept : define_rule_on_relation_to_concept_structure (description)?;
logical_deduce : deduce_premise labmda_body_array deduce_conclusion description?;
logical_deduce : deduce_premise labmda_body_array deduce_conclusion priority_assignment_statement? description?;
deduce_premise : logical_statement;
deduce_conclusion : logical_statement;
necessary_logical_deduce : deduce_premise necessary_symbol deduce_conclusion priority_assignment_statement? description?;
/*
DefinePriority(危险水平分层) {
超高危=100
@ -1037,4 +1042,6 @@ assiginment_structure : left_brace muliti_assignment_statement right_brace;
muliti_assignment_statement : assignment_statement*;
assignment_statement : identifier assignment_operator logical_statement;
assignment_statement : identifier assignment_operator logical_statement;
priority_assignment_statement : left_bracket PRIORITY assignment_operator oC_IntegerLiteral right_bracket;

View File

@ -33,4 +33,11 @@ object Convert2ScalaUtil {
jSet.asScala.toSet
}
def toJavaList[T](scalaList: List[T]): java.util.List[T] = {
if (scalaList == null || scalaList.isEmpty) {
return new java.util.ArrayList()
}
scalaList.asJava
}
}