<% // creem el cas query kateservlet.javakate.OneCaseServlet casQuery = new kateservlet.javakate.OneCaseServlet(request); // agafem l'instancia del cbr javakate.consultation.cbr.KCbr cbr = javakate.session.CBSession.getCbr(); // posem el pesos en el KATE kateservlet.javakate.CBRListOfWeightsServlet weightList = new kateservlet.javakate.CBRListOfWeightsServlet(request); weightList.setInKate(); // posem els constraints en el Kate kateservlet.javakate.ListOfConstraintsServlet constraintsList = new kateservlet.javakate.ListOfConstraintsServlet(request); cbr.setListOfConstraints(constraintsList); // Gravem el cas query en la sessio request.getSession().putValue("casQuery",casQuery); // engegem el cbr i agafem els resultats javakate.consultation.cbr.ListCBRCases listCbrCases = cbr.run(casQuery); // gravem el cbr en la sessio request.getSession().putValue("consultation",cbr); out.println(""); out.println(""); out.println(""); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(""); for(int index=0; index < listCbrCases.numberOfCases(); index++) { String result = ""; String resultRequest = ""; javakate.consultation.OneCase currentCase = listCbrCases.getOneCase(index); // mostrem la similaritud amb una imatge del % float sim = listCbrCases.getSimilarity(index); String nameImage = "0"; if(sim >= 0.05 && sim < 0.15) nameImage = "10"; if(sim >= 0.15 && sim < 0.25) nameImage = "20"; if(sim >= 0.25 && sim < 0.35) nameImage = "30"; if(sim >= 0.35 && sim < 0.45) nameImage = "40"; if(sim >= 0.45 && sim < 0.55) nameImage = "50"; if(sim >= 0.55 && sim < 0.65) nameImage = "60"; if(sim >= 0.65 && sim < 0.75) nameImage = "70"; if(sim >= 0.75 && sim < 0.85) nameImage = "80"; if(sim >= 0.85 && sim < 0.95) nameImage = "90"; if(sim >= 0.95 && sim <= 1) nameImage = "100"; out.println(" "); out.print(" "); out.println(" "); out.print(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); } %>
Has cercat:
"); String Request = ""; for(int indexClass=0; indexClass < javakate.casuel.KModel.getNbClass(); indexClass++) { javakate.casuel.KModelNode node = javakate.casuel.KModel.getNodeClass(indexClass); for(int indexSlot =0; indexSlot < node.getChildCount(); indexSlot++) { javakate.casuel.KModelNode slotNode = (javakate.casuel.KModelNode)node.getChildAt(indexSlot); String slotId = slotNode.getId(); if(slotNode.isSlot()) { javakate.consultation.caseValue cValue = casQuery.getValue(slotId); javakate.casuel.KValue kValue = cValue.getValue(); Request = kValue.getName(); if(!Request.equals("?") && !Request.equals("")) out.print(" " + Request + ","); } } } out.println("


Resultat de la cerca :
"); out.println("

"); out.println("
"); out.println("

"); out.print(javakate.userinterface.InterfaceProperties.showProba(listCbrCases.getSimilarity(index)*100) + "%"); out.println("

"); // mostrem el cas for(int indexClass=0; indexClass < javakate.casuel.KModel.getNbClass(); indexClass++) { javakate.casuel.KModelNode node = javakate.casuel.KModel.getNodeClass(indexClass); for(int indexSlot =0; indexSlot < node.getChildCount(); indexSlot++) { javakate.casuel.KModelNode slotNode = (javakate.casuel.KModelNode)node.getChildAt(indexSlot); String slotId = slotNode.getId(); if(slotNode.isSlot()) { // llegim el valor del cas javakate.consultation.caseValue cValue = currentCase.getValue(slotId); javakate.casuel.KValue kValue = cValue.getValue(); result = kValue.getName(); // llegim els valors del query javakate.consultation.caseValue cValueRequest = casQuery.getValue(slotId); javakate.casuel.KValue kValueRequest = cValueRequest.getValue(); resultRequest = kValueRequest.getName(); // comparar els diferents valors if(resultRequest.equals("?") || resultRequest.equals("")) out.print(" "); else { if(result.equals(resultRequest)) out.print(" "); else out.print(" "); } if(!result.equals("?") && !result.equals("")) out.print(" " + result + ","); else out.print(""); out.println(""); } } } out.println("

<%out.print(" " + listCbrCases.numberOfCases());%> productes que coincideixem amb la petició
Main page
Final project, Toni Martinez Arteaga 2000