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 InstancePerishable extends SimpleTopLevelQuery {
00012
00013 public InstancePerishable(DialogModule mod) {
00014 super(mod);
00015 }
00016
00017 @Override
00018 public String match(String q) {
00019
00020 Matcher matcher = Pattern.compile("([i|I]s it perishable\\?)").matcher(q);
00021 if(matcher.find()) {
00022
00023 q=this.dialog_module.getCurrentObject();
00024 String query = "owl_subclass_of("+q+", knowrob:'Perishable'); owl_individual_of("+q+", knowrob:'Perishable')";
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 matcher = Pattern.compile("([i|I]s it heat sensitive\\?)").matcher(q);
00035 if(matcher.find()) {
00036
00037 q=this.dialog_module.getCurrentObject();
00038 String query = "owl_subclass_of('"+q+", knowrob:'HeatSensitive'); owl_individual_of("+q+", knowrob:'HeatSensitive')";
00039
00040 HashMap<String, Vector<PrologValue>> res = DialogModule.executeJSONPrologQuery(query);
00041
00042 if(res==null) {
00043 return "No.\n";
00044 } else {
00045 return "Yes.\n";
00046 }
00047 }
00048 matcher = Pattern.compile("([i|I]s it frozen\\?)").matcher(q);
00049 if(matcher.find()) {
00050
00051 q=this.dialog_module.getCurrentObject();
00052 String query = "owl_subclass_of('"+q+", knowrob:'Frozen'); owl_individual_of("+q+", knowrob:'Frozen')";
00053
00054 HashMap<String, Vector<PrologValue>> res = DialogModule.executeJSONPrologQuery(query);
00055
00056 if(res==null) {
00057 return "No.\n";
00058 } else {
00059 return "Yes.\n";
00060 }
00061 }
00062
00063 return null;
00064 }
00065
00066 }