InstanceQualitativePosition.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 de.tum.in.fipm.kipm.gui.visualisation.applets.CommunicationVisApplet;
00009 
00010 
00011 import edu.tum.cs.ias.knowrob.json_prolog.PrologValue;
00012 import edu.tum.cs.ias.knowrob.mod_dialog.DialogModule;
00013 
00014 public class InstanceQualitativePosition extends SimpleTopLevelQuery {
00015 
00016         public InstanceQualitativePosition(DialogModule mod) {
00017                 super(mod);
00018         }
00019 
00020         @Override
00021         public String match(String q) {
00022                 
00023 
00024                 Matcher matcher = Pattern.compile("([w|W]here is ([a-zA-Z0-9]*?)\\?)").matcher(q);
00025                 if(matcher.find()) {
00026                         q=matcher.group(2);
00027                         q=DialogModule.toProlog(q);
00028                         dialog_module.setCurrentObject(q);
00029 
00030                         // visualize communication
00031                         String shortquery = "rdf_has(Prop, subPropertyOf, topologicalRelations)," +
00032                         "rdf_triple(A, "+q+", O)";
00033                 CommunicationVisApplet.visualizeCommunication(shortquery, null, null, "rosie.png");
00034         
00035                         
00036                         String query = "rdf_has(Prop, rdfs:subPropertyOf, knowrob:topologicalRelations)," +
00037                         "rdf_triple(A, "+q+", O)";
00038 
00039                         HashMap<String, Vector<PrologValue>> res = DialogModule.executeJSONPrologQuery(query);
00040 
00041                         if(res.get("Prop")==null || res.get("O")==null)
00042                                 return null;
00043                         
00044                         String prop = res.get("Prop").toString();
00045                         String obj  = res.get("O").toString();
00046                         
00047                         // visualize communication
00048                 CommunicationVisApplet.visualizeCommunication(null, prop + ": " + obj, null, "rosie.png");
00049                         
00050                         return prop + " "+obj+".\n"; 
00051                 }
00052                 
00053                 return null;
00054         }
00055 
00056 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


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