📄 begdeduce.cs
字号:
using System;
using System.Messaging;
namespace createDeduce
{
/// <summary>
/// BegDeduce 的摘要说明。
/// </summary>
///
public class BegDeduce
{
private Rule rules;
private Real reals;
public BegDeduce(Rule ru,Real re)
{
rules=ru;
reals=re;
}
public void beginDeduce()
{
while(!IsEnd())
{
Rule rp=RuleWarehouse.FirstRule.nextRule;
while(rp!=null)
{
if(!rp.IsVisit&&martch(rp.Condition))
{
RealWarehouse.addReal(rp.Dicision,rp.RuleFlag);
rp.IsVisit=true;
break;
}
rp=rp.nextRule;
}
}
}
public bool IsEnd()
{
Rule rp=RuleWarehouse.FirstRule.nextRule;
Real cp=RealWarehouse.FirstReal.nextReal;
while(rp!=null)
{
if(!rp.IsVisit&&martch(rp.Condition))
return false;
rp=rp.nextRule;
}
return true;
}
public bool judge()
{
Real x=reals.nextReal;
while(x!=null)
{
if(x.RealFlag==true)
return true;
x=x.nextReal;
}
return false;
}
public static bool IsEqual(string str,string sub)
{
char []ch=sub.ToCharArray();
bool flag=true;
for(int i=0;i<ch.Length;i++)
{
if(str.IndexOf(ch[i])==-1)
{
flag=false;
break;
}
}
if(flag&&(str.IndexOf("无")!=-1||str.IndexOf("没有")!=-1||str.IndexOf("未")!=-1||str.IndexOf("不")!=-1||str.IndexOf("否")!=-1)&&(sub.IndexOf("无")==-1&&sub.IndexOf("没有")==-1&&sub.IndexOf("未")==-1&&sub.IndexOf("不")==-1&&sub.IndexOf("否")==-1))
flag=false;
return flag;
}
public bool martch(string stri)
{
Real Cindex=reals.nextReal;
string str=stri;
string ss=str;
bool flag=true;
while(str.Length!=0)
{
Cindex=reals.nextReal;
int index=str.IndexOf(",");
if(index!=-1)
{
ss=str.Substring(0,index);
str=str.Remove(0,index+1);
}
else
{
ss=str;
str="";
}
while(Cindex!=null)
{
if(!IsEqual(ss,Cindex.Condition))
//if(ss!=Cindex.Condition)
{
Cindex=Cindex.nextReal;
flag=false;
continue;
}
else
{
flag=true;
break;
}
}
if(flag==false)
return false;
}
return flag;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -