예제 #1
0
  /**
   * Returns true if it was cleaned, or false if the clause was unsatisfiable
   *
   * @param sample
   * @return
   */
  public static ValueSet<NodeValue> toValueSet(Sample<NodeValue> sample) {
    if (sample.getPositives().size() > 1
        || (!sample.getPositives().isEmpty()
            && sample.getNegatives().containsAll(sample.getPositives()))) {
      /**
       * If there are .) multiple positive constants in a clause, such as in [?x = a, ?x = b] .) or
       * the negatives contain the positive, such as in [?x = a, !(?x = a)] then the clause is
       * unsatisfiable and no value contraint can be derived
       */
      return ValueSet.create();
    }

    if (!sample.getPositives().isEmpty()) {
      /**
       * Just in case deal with the case [?x = a, !(?x = b)] ---> [?x = a]
       *
       * <p>So positive takes precedence over negative
       */
      sample.getNegatives().clear();
    }

    return sample.getPositives().isEmpty()
        ? ValueSet.create(sample.getNegatives(), false)
        : ValueSet.create(sample.getPositives(), true);
  }