Ejemplo n.º 1
0
  @Test
  public void reverse() {
    System.out.println("reverse");
    LinkSpecification ls =
        new LinkSpecification(
            "tmp_is_started_by(x.beginsAtDateTime|endsAtDateTime,y.beginsAtDateTime|endsAtDateTime)",
            1.0);
    DynamicPlanner p = new DynamicPlanner(source, target);
    ExecutionEngine e = new SimpleExecutionEngine(source, target, "?x", "?y");
    AMapping m = e.execute(ls, p);
    System.out.println(m);
    //////////////////////////////////////////////////////////////////////////////////////////////////
    LinkSpecification ls2 =
        new LinkSpecification(
            "tmp_starts(x.beginsAtDateTime|endsAtDateTime,y.beginsAtDateTime|endsAtDateTime)", 1.0);
    AMapping m2 = e.execute(ls2, p);
    AMapping m3 = MappingFactory.createDefaultMapping();
    for (String s : m2.getMap().keySet()) {
      for (String t : m2.getMap().get(s).keySet()) {
        m3.add(t, s, 1);
      }
    }

    System.out.println(m3);
    assertTrue(m.equals(m3));
  }
Ejemplo n.º 2
0
 @Override
 public AMapping getMapping(
     ACache source,
     ACache target,
     String sourceVar,
     String targetVar,
     String expression,
     double threshold) {
   // Phase 0: Initialize
   List<String> properties;
   List<Set<String>> sourceIndex, targetIndex, small, big;
   properties = PropertyFetcher.getProperties(expression, threshold);
   sourceIndex = buildIndex(source, properties.get(0));
   targetIndex = buildIndex(target, properties.get(1));
   // Swap if necessary
   if (sourceIndex.size() > targetIndex.size()) {
     big = sourceIndex;
     small = targetIndex;
   } else {
     big = targetIndex;
     small = sourceIndex;
   }
   List<List<Set<String>>> possibleMatches = getPossibleMatches(small, big, threshold);
   AMapping result = MappingFactory.createDefaultMapping();
   for (int i = 0; i < possibleMatches.size(); i += 2) {
     List<Set<String>> s = possibleMatches.get(i);
     List<Set<String>> t = possibleMatches.get(i + 1);
     for (Set<String> setS : s) {
       for (Set<String> setT : t) {
         double score = fastSimCheck(setS, setT, threshold);
         if (score >= threshold) {
           result.add(
               ((NamedHashSet<String>) setS).getUri(),
               ((NamedHashSet<String>) setT).getUri(),
               score);
         }
       }
     }
   }
   return result;
 }
Ejemplo n.º 3
0
  @Test
  public void similarity() {
    System.out.println("similarity");
    LinkSpecification ls =
        new LinkSpecification(
            "tmp_is_started_by(x.beginsAtDateTime|endsAtDateTime,y.beginsAtDateTime|endsAtDateTime)",
            1.0);
    DynamicPlanner p = new DynamicPlanner(source, target);
    ExecutionEngine e = new SimpleExecutionEngine(source, target, "?x", "?y");
    AMapping m = e.execute(ls, p);
    System.out.println(m);

    AMapping m2 = MappingFactory.createDefaultMapping();
    for (Instance s : source.getAllInstances()) {
      for (Instance t : target.getAllInstances()) {
        IsStartedByMeasure measure = new IsStartedByMeasure();
        double sim =
            measure.getSimilarity(
                s, t, "beginsAtDateTime|endsAtDateTime", "beginsAtDateTime|endsAtDateTime");
        if (sim != 0) m2.add(s.getUri(), t.getUri(), sim);
      }
    }
    assertTrue(m.equals(m2));
  }