InstanceEdible.java
Go to the documentation of this file.
00001 package edu.tum.cs.ias.knowrob.mod_dialog.queries;
00002 
00003 import java.util.HashMap;
00004 import java.util.Vector;
00005 import java.util.regex.Matcher;
00006 import java.util.regex.Pattern;
00007 
00008 import edu.tum.cs.ias.knowrob.json_prolog.PrologValue;
00009 import edu.tum.cs.ias.knowrob.mod_dialog.DialogModule;
00010 
00011 public class InstanceEdible extends SimpleTopLevelQuery {
00012 
00013         public InstanceEdible(DialogModule mod) {
00014                 super(mod);
00015         }
00016 
00017         @Override
00018         public String match(String q) {
00019                 
00020                 Matcher matcher = Pattern.compile("([c|C]an you eat it\\?)").matcher(q);
00021                 if(matcher.find()) {
00022                         
00023                         q=this.dialog_module.getCurrentObject();
00024                         String query = "owl_subclass_of('"+q+"', knowrob:'Food'); owl_individual_of('"+q+"', knowrob:'Food')";
00025                         
00026                         HashMap<String, Vector<PrologValue>> res = DialogModule.executeJSONPrologQuery(query);
00027 
00028                         if(res==null) {
00029                                 return "No.\n";                         
00030                         } else {
00031                                 return "Yes.\n";
00032                         }
00033                 }
00034 
00035                 matcher = Pattern.compile("([c|C]an you drink it\\?)").matcher(q);
00036                 if(matcher.find()) {
00037                         
00038                         q=this.dialog_module.getCurrentObject();
00039                         String query = "owl_subclass_of('"+q+"', knowrob:'Drink'); owl_individual_of('"+q+"', knowrob:'Drink')";
00040 
00041                         HashMap<String, Vector<PrologValue>> res = DialogModule.executeJSONPrologQuery(query);
00042 
00043                         if(res==null) {
00044                                 return "No.\n";                         
00045                         } else {
00046                                 return "Yes.\n";
00047                         } 
00048                 }
00049                 
00050                 return null;
00051         }
00052         
00053 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


mod_dialog
Author(s): Moritz Tenorth
autogenerated on Tue Apr 16 2013 00:38:25