




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、疾病診斷小型專(zhuān)家系統(tǒng) 人工智能課程設(shè)計(jì)報(bào)告 智能1001班 傅寶林 0909101217 2013.6.181內(nèi)容提要 此系統(tǒng)采用專(zhuān)家系統(tǒng)的規(guī)則庫(kù)-推理機(jī)技術(shù)原理,以醫(yī)學(xué)診斷為背景,旨在作出一個(gè)簡(jiǎn)單的輔助診斷專(zhuān)家系統(tǒng)。系統(tǒng)的框架及界面采用的是java語(yǔ)言,調(diào)用xml里保存的知識(shí)庫(kù)和規(guī)則庫(kù)。此小型的專(zhuān)家系統(tǒng)以肺結(jié)核、哮喘、食管癌、骨折等疾病的診斷為例,展示了一個(gè)小型專(zhuān)家系統(tǒng)是如何構(gòu)建的。目錄1內(nèi)容提要22目的和意義43系統(tǒng)的主要內(nèi)容和功能54設(shè)計(jì)流程及描述65課程設(shè)計(jì)體會(huì)216參考文獻(xiàn)22 2目的和意義 (1)加深理解專(zhuān)家系統(tǒng)的結(jié)構(gòu)及開(kāi)發(fā)過(guò)程。(2)初步掌握知識(shí)獲取的基本方法。(3)掌握產(chǎn)生式規(guī)
2、則知識(shí)表示方法及其編程實(shí)現(xiàn)方法。(4)初步掌握知識(shí)庫(kù)的組建方法。3系統(tǒng)的主要內(nèi)容和功能 系統(tǒng)主要以問(wèn)答的形勢(shì)詢(xún)問(wèn)病情癥狀,操作者只需要回答yes或no。當(dāng)一趟詢(xún)問(wèn)完成后,系統(tǒng)會(huì)基于以上詢(xún)問(wèn)得出的事實(shí)推理出最終的診斷結(jié)果。 功能見(jiàn)以下截圖1、2. 圖1 問(wèn)詢(xún)界面 圖2 診斷結(jié)果界面 4設(shè)計(jì)流程及描述1) 需求分析 本設(shè)計(jì)需要用高級(jí)語(yǔ)言編寫(xiě)框架及調(diào)用外部的規(guī)則庫(kù)與知識(shí)庫(kù)。方便起見(jiàn),用java語(yǔ)言編寫(xiě)框架,用xml文件保存。2) 知識(shí)獲取與知識(shí)表示知識(shí)獲取通過(guò)醫(yī)學(xué)臨床專(zhuān)業(yè)的同學(xué)及醫(yī)學(xué)診斷專(zhuān)業(yè)書(shū)籍,確保專(zhuān)家系統(tǒng)的專(zhuān)家性。知識(shí)的表示采用的是xml語(yǔ)言,把事實(shí)與規(guī)則一條條保存。3) 知識(shí)庫(kù)的組建 知識(shí)庫(kù)分
3、事實(shí)庫(kù)和規(guī)則庫(kù)組建。疾病診斷因?yàn)橛械牟∮薪徊娴陌Y狀,所以邏輯上,從癥狀到診斷的過(guò)程是對(duì)一顆二叉樹(shù)的搜索,當(dāng)問(wèn)題回答的是yes時(shí),就進(jìn)行深度優(yōu)先搜索,當(dāng)回答no時(shí),就轉(zhuǎn)到兄弟節(jié)點(diǎn)。對(duì)于無(wú)關(guān)的疾病,則回到根節(jié)點(diǎn)重新對(duì)下一顆子樹(shù)進(jìn)行搜索。得到一種疾病的確診就是result,得到這個(gè)葉子節(jié)點(diǎn)前遍歷過(guò)的節(jié)點(diǎn)組成了reasons.4) 推理機(jī)制選擇/編制 采用的是問(wèn)題引導(dǎo)式推理。在規(guī)則庫(kù)里寫(xiě)的其實(shí)不是真正的規(guī)則。真正的規(guī)則蘊(yùn)含在問(wèn)題及前提里。為了不讓“專(zhuān)家”問(wèn)無(wú)用的問(wèn)題,每個(gè)問(wèn)題都是以某個(gè)問(wèn)題的答案為前提的。這樣組成了內(nèi)部的因果關(guān)系,所以真正的推理規(guī)則只與某一趟提問(wèn)的最后一個(gè)問(wèn)題的答案得出的事實(shí)有關(guān)。5)
4、 程序清單package 專(zhuān)家系統(tǒng)_v2;import java.awt.borderlayout;import java.awt.color;import java.awt.dimension;import java.awt.font;import java.awt.event.actionevent;import java.awt.event.actionlistener;import java.util.arraylist;import javax.swing.jbutton;import javax.swing.jframe;import javax.swing.jlabel;impo
5、rt javax.swing.jpanel;import javax.swing.jscrollpane;import javax.swing.jtextarea;import javax.swing.border.lineborder;public class mainframe extends jframe/* * 主界面類(lèi) * param args */public static void main(string args) mainframe main = new mainframe();main.myshow();private void myshow() exe = new exe
6、cution();exe.init();this.settitle(exe.expert_name+專(zhuān)家系統(tǒng));this.setsize(380, 250);this.setdefaultcloseoperation(3);this.setresizable(false);this.setlocationrelativeto(null);this.setlayout(new borderlayout();jpanel jp_center = new jpanel();jp_center.setbackground(color.white);jp_center.setpreferredsize(
7、new dimension(380,250);jp_center.setlayout(null);jl = new jlabel();jl.settext(請(qǐng)回答下列問(wèn)題:);jl.setfont(new font(font.dialog,font.bold,25);jl.setforeground(color.blue);jl.setbounds(10, 10, 200, 30);jta=new jtextarea();jscrollpane js=new jscrollpane(jta);jta.seteditable(false);jta.setborder(new lineborder
8、(color.black);jta.setlinewrap(true);jta.setfont(new font(font.dialog,font.bold,20);js.setbounds(20, 50, 330, 100);jb1 = new jbutton(yes);jb1.setbounds(100, 170, 60, 30);jb1.addactionlistener(l);jb2 = new jbutton(no);jb2.setbounds(200, 170, 60, 30);jb2.addactionlistener(l);jp_center.add(jl);jp_center
9、.add(js);jp_center.add(jb1);jp_center.add(jb2);this.add(jp_center,borderlayout.center);problem=this.initproblem();this.setvisible(true);private problem initproblem()for(int i=0;blems.size();i+)problem problem = blems.get(i);if(problem.getpremise()=null|problem.getpremise().isistrue()i
10、f(problem.getpremise()!=null)problem.getpremise().setistrue(false);jta.settext(problem.getcontext();blems.remove(problem);return problem;jb1.setenabled(false);jb2.setenabled(false);return null;private execution exe;private jbutton jb1,jb2;private jtextarea jta ;private jlabel jl;private probl
11、em problem;private action l = new action();class action implements actionlistenerpublic void actionperformed(actionevent e) if(yes.equals(e.getactioncommand()if(null!=problem.getanswer_yes()problem.getanswer_yes().setistrue(true);else if(no.equals(e.getactioncommand()system.out.println(aaa);if(null!
12、=problem.getanswer_no()system.out.println(aaa);problem.getanswer_no().setistrue(true);exe.allreasoning();problem=initproblem();if(problem=null)arraylist facts=exe.start();string result=;for(int i=0,n=1;ifacts.size();i+)string des = facts.get(i).getdescribe();if(!null.equals(des)result+=i+1+.+des+n;n
13、+;jl.settext(推理結(jié)果如下:);jta.settext(result);jb1.setenabled(false);jb2.setenabled(false);return;package 專(zhuān)家系統(tǒng)_v2;import java.io.file;import java.io.ioexception;import java.io.unsupportedencodingexception;import .urldecoder;import java.util.arraylist;import java.util.hashmap;import javax.swing.joptionpan
14、e;import javax.xml.parsers.documentbuilder;import javax.xml.parsers.documentbuilderfactory;import javax.xml.parsers.parserconfigurationexception;import org.w3c.dom.document;import org.w3c.dom.element;import org.w3c.dom.nodelist;import org.xml.sax.saxexception;public class execution public boolean in
15、it()try this.initxml(this.getpath(); catch (parserconfigurationexception e) e.printstacktrace(); catch (saxexception e) this.exit(e.getmessage(); catch (ioexception e) e.printstacktrace(); catch (nullpointerexception e)this.exit(找不到相應(yīng)的xml文件,請(qǐng)檢查xml文件名是否符合規(guī)范);return false;private void initxml(string f
16、ile) throws parserconfigurationexception, saxexception, ioexceptiondocumentbuilderfactory dbf = documentbuilderfactory.newinstance();documentbuilder builder = dbf.newdocumentbuilder();document doc=null;trydoc = builder.parse(new file(file);catch(exception e)this.exit(e.getmessage();element root = do
17、c.getdocumentelement(); / 獲取根元素expert_name=root.getattribute(name); /取得名字/獲取事實(shí)factnodelist allfacts = root.getelementsbytagname(facts);nodelist onefacts = (element)allfacts.item(0).getelementsbytagname(fact);for(int i=0;ionefacts.getlength();i+)element onefact = (element)onefacts.item(i);fact fact =
18、 new fact();tryfact.setname(onefact.getelementsbytagname(name).item(0).getfirstchild().getnodevalue();fact.setdescribe(onefact.getelementsbytagname(describe).item(0).getfirstchild().getnodevalue();catch(nullpointerexception e)this.exit(fact中缺少相應(yīng)標(biāo)簽);facts.put(fact.getname(), fact);/獲取推理reasoningnodel
19、ist allreasonings = root.getelementsbytagname(reasonings);nodelist onereasonings = (element)allreasonings.item(0).getelementsbytagname(reasoning);for(int i=0;ionereasonings.getlength();i+)element onereasoning = (element)onereasonings.item(i);reasoning reasoning = new reasoning();nodelist reasons = o
20、nereasoning.getelementsbytagname(reason);if(reasons.getlength()=0)this.exit(reasoning中不可以缺少reason標(biāo)簽);for(int j=0;jreasons.getlength();j+)string name=reasons.item(j).getfirstchild().getnodevalue();if(facts.get(name)!=null)reasoning.getreason().add(facts.get(name);elsethis.exit(reason標(biāo)簽內(nèi)容不正確,沒(méi)有對(duì)應(yīng)事實(shí));n
21、odelist results = onereasoning.getelementsbytagname(result);if(results.getlength()=0)this.exit(reasoning中不可以缺少result標(biāo)簽);for(int j=0;jresults.getlength();j+)string name=results.item(j).getfirstchild().getnodevalue();if(facts.get(name)!=null)reasoning.getresult().add(facts.get(name);elsethis.exit(resu
22、lt標(biāo)簽內(nèi)容不正確,沒(méi)有對(duì)應(yīng)事實(shí));reasonings.add(reasoning);/獲取問(wèn)題problemnodelist allproblems = root.getelementsbytagname(problems);nodelist oneproblems = (element)allproblems.item(0).getelementsbytagname(problem);for(int i=0;ioneproblems.getlength();i+)element oneproblem = (element)oneproblems.item(i);problem probl
23、em = new problem();problem.setcontext(oneproblem.getelementsbytagname(context).item(0).getfirstchild().getnodevalue();tryproblem.setpremise(facts.get(oneproblem.getelementsbytagname(premise).item(0).getfirstchild().getnodevalue();catch(exception e)tryproblem.setanswer_yes(facts.get(oneproblem.getele
24、mentsbytagname(answer_yes).item(0).getfirstchild().getnodevalue();catch(exception e)tryproblem.setanswer_no(facts.get(oneproblem.getelementsbytagname(answer_no).item(0).getfirstchild().getnodevalue();catch(exception e)problems.add(problem);public void allreasoning()boolean proceed=true;while(proceed
25、)proceed=false;for(reasoning reasoning:reasonings)reasoning.startreasoning();if(reasoning.startreasoning()proceed=true;public arraylist start()/this.allreasoning();arraylist reallyfacts = new arraylist();for(fact fact:facts.values()if(fact.isistrue()reallyfacts.add(fact);return reallyfacts;private v
26、oid exit(string passage)joptionpane.showmessagedialog(null, passage);system.exit(0);/查找當(dāng)前路徑private string getpath()string mypath=null;try mypath=urldecoder.decode(execution.class.getprotectiondomain().getcodesource().getlocation().getfile(), utf-8); catch (unsupportedencodingexception e) e.printstac
27、ktrace();string path=mypath.substring(1,mypath.lastindexof(/)+1)+xml/配置文件.xml;return path;public hashmap facts = new hashmap ();public arraylist reasonings = new arraylist();public arraylist problems = new arraylist();public string expert_name;package 專(zhuān)家系統(tǒng)_v2;/* * 存放事實(shí)的類(lèi) * author liguanyi * */public
28、 class fact private string name; /名字private boolean istrue=false; /是否成立private string describe; /事實(shí)相應(yīng)表述public string getname() return name;public void setname(string name) = name;public boolean isistrue() return istrue;public void setistrue(boolean istrue) this.istrue = istrue;public strin
29、g getdescribe() return describe;public void setdescribe(string describe) this.describe = describe;package 專(zhuān)家系統(tǒng)_v2;import java.util.arraylist;/表示推理public class reasoning private arraylist reason = new arraylist(); /前提事實(shí)private arraylist result = new arraylist(); /結(jié)果事實(shí)public arraylist getreason() retu
30、rn reason;public void setreason(arraylist reason) this.reason = reason;public arraylist getresult() return result;public void setresult(arraylist result) this.result = result;public boolean startreasoning()if(reason.size()=0)return false;for(fact fact:reason)if(!fact.isistrue()return false;for(fact
31、fact:reason)fact.setistrue(false);for(fact fact:result)fact.setistrue(true);return true;package 專(zhuān)家系統(tǒng)_v2;public class problem private fact premise;private string context;private fact answer_yes; /結(jié)果private fact answer_no; /結(jié)果public fact getpremise() return premise;public void setpremise(fact premise)
32、 this.premise = premise;public string getcontext() return context;public void setcontext(string context) this.context = context;public fact getanswer_yes() return answer_yes;public void setanswer_yes(fact answeryes) answer_yes = answeryes;public fact getanswer_no() return answer_no;public void setanswer_no(fact answerno) answer_no = answerno;以下是xml文件(保存事實(shí)庫(kù)和規(guī)則庫(kù))中部分內(nèi)容fact1咳嗽fact2胸痛fact3盜汗 fact4食欲不振 fact5消瘦 fact
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 制定員工職業(yè)發(fā)展規(guī)劃的方案計(jì)劃
- 建筑行業(yè)保安工作計(jì)劃
- 引導(dǎo)學(xué)生樹(shù)立正面價(jià)值觀計(jì)劃
- 關(guān)注心理健康與職場(chǎng)適應(yīng)能力計(jì)劃
- 保安工作總結(jié)計(jì)劃安全用品行業(yè)保安工作的產(chǎn)品推廣
- 提升企業(yè)形象的具體執(zhí)行計(jì)劃
- 小區(qū)儲(chǔ)藏室買(mǎi)賣(mài)合同
- 如何選擇適合自己的投資方式計(jì)劃
- 物流搬運(yùn)設(shè)備法規(guī)與標(biāo)準(zhǔn)考核試卷
- 咖啡館品牌長(zhǎng)期發(fā)展規(guī)劃考核試卷
- 【湛江】2025年中國(guó)熱帶農(nóng)業(yè)科學(xué)院農(nóng)產(chǎn)品加工研究所第一批招聘工作人員30人(第1號(hào))筆試歷年典型考題及考點(diǎn)剖析附帶答案詳解
- 成人重癥患者人工氣道濕化護(hù)理專(zhuān)家共識(shí) 解讀
- 腦干聽(tīng)覺(jué)誘發(fā)電位課件
- 幼兒園教學(xué)課件閃閃的紅星
- 中考英語(yǔ)任務(wù)型閱讀解題技巧課件
- 內(nèi)蒙古自治區(qū)醫(yī)療衛(wèi)生機(jī)構(gòu)藥品集中采購(gòu)購(gòu)銷(xiāo)合同
- 閉合導(dǎo)線計(jì)算表(帶公式)
- 中國(guó)移動(dòng)網(wǎng)絡(luò)運(yùn)行維護(hù)規(guī)程(2014版)
- 歐洲法國(guó)意大利簽證行程單
- 高老鼠和矮老鼠PPT
- 商業(yè)票據(jù)與核算
評(píng)論
0/150
提交評(píng)論