Пример #1
0
 public String getMetricAdvice(int sessionId) {
   String metric = "";
   logger.info("" + sessionId);
   LimesUser lu = UserManager.getInstance().getUser(sessionId);
   System.out.println(lu);
   KBInfo sourceInfo = createKBInfo(lu.getSourceMap());
   KBInfo targetInfo = createKBInfo(lu.getTargetMap());
   if (sourceInfo.prefixes == null) sourceInfo.prefixes = new HashMap<String, String>();
   if (targetInfo.prefixes == null) targetInfo.prefixes = new HashMap<String, String>();
   //		sourceInfo.prefixes.put("rdf", PrefixHelper.getURI("rdf"));
   //		sourceInfo.prefixes.put("dbp", PrefixHelper.getURI("dbp"));
   //		sourceInfo.prefixes.put("rdfs", PrefixHelper.getURI("rdfs"));
   //		targetInfo.prefixes.put("rdf", PrefixHelper.getURI("rdf"));
   //		targetInfo.prefixes.put("dbp", PrefixHelper.getURI("dbp"));
   //		targetInfo.prefixes.put("rdfs", PrefixHelper.getURI("rdfs"));
   logger.info("getMetricAdvice(): Getting caches...");
   HybridCache sC = HybridCache.getData(sourceInfo);
   HybridCache tC = HybridCache.getData(targetInfo);
   logger.info("getMetricAdvice(): Start SelfConfig...");
   MeshBasedSelfConfigurator mbsc = new MeshBasedSelfConfigurator(sC, tC, 0.6, 0.5);
   List<SimpleClassifier> classifierList = mbsc.getBestInitialClassifiers();
   if (classifierList.size() > 0) {
     classifierList = mbsc.learnClassifer(classifierList);
   }
   ComplexClassifier compC = mbsc.getZoomedHillTop(5, 5, classifierList);
   metric = this.generateMetric(compC.classifiers, "", sourceInfo, targetInfo);
   lu.setNoUsageTime(0);
   logger.info("getMetricAdvice(): metric=\n" + metric);
   return metric;
 }
Пример #2
0
  private KBInfo createKBInfo(HashMap<String, Object> param) {
    KBInfo info = new KBInfo();
    info.endpoint = (String) param.get("endpoint");

    info.graph = (String) param.get("graph");
    info.var = (String) param.get("var");
    System.out.println(info.endpoint);
    info.restrictions = new ArrayList<String>();
    if (param.containsKey("class")) {
      String classRestrString =
          info.var + " rdf:type " + SPARQLHelper.wrapIfNecessary((String) param.get("class"));
      info.restrictions.add(classRestrString);
    }
    info.prefixes = (HashMap<String, String>) param.get("prefixes");
    System.out.println("PREFIXES: " + info.prefixes);
    info.functions = (HashMap<String, String>) param.get("properties");
    for (String prop : info.functions.keySet()) {
      info.properties.add(prop);
    }
    info.type = "SPARQL";
    info.id = (String) param.get("id");
    return info;
  }