de.learnlib.api.query.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中de.learnlib.api.query.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:de.learnlib.api.query.Query
类名称:Query

Query介绍

暂无

代码示例

代码示例来源:origin: de.learnlib/learnlib-util

public static <I, D> void answerQueries(QueryAnswerer<I, D> answerer, Collection<? extends Query<I, D>> queries) {
  for (Query<I, D> query : queries) {
    Word<I> prefix = query.getPrefix();
    Word<I> suffix = query.getSuffix();
    D answer = answerer.answerQuery(prefix, suffix);
    query.answer(answer);
  }
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
  public int compare(Query<I, ?> o1, Query<I, ?> o2) {
    return -CmpUtil.lexCompare(o1.getInput(), o2.getInput(), alphabet);
  }
}

代码示例来源:origin: de.learnlib/learnlib-util

@Override
public String toString() {
  return originalQuery.toString();
}

代码示例来源:origin: de.learnlib/learnlib-equivalence-oracles

/**
 * Tests if the input word of the given {@link Query} consists entirely of symbols in {@code inputs}.
 *
 * @param query
 *         the query to test
 * @param inputs
 *         the set of allowed inputs
 *
 * @return {@code true} if the input word of {@code query} consists entirely of symbols in {@code inputs}, {@code
 * false} otherwise
 */
private static <I> boolean checkInputs(Query<I, ?> query, Collection<? extends I> inputs) {
  for (I sym : query.getPrefix()) {
    if (!inputs.contains(sym)) {
      return false;
    }
  }
  for (I sym : query.getSuffix()) {
    if (!inputs.contains(sym)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: de.learnlib/learnlib-counterexamples

/**
 * Returns all suffixes of the counterexample word as distinguishing suffixes, after stripping a maximal one-letter
 * extension of an access sequence, as suggested by Shahbaz.
 *
 * @param ceQuery
 *         the counterexample query
 * @param asTransformer
 *         the access sequence transformer
 *
 * @return all suffixes from the counterexample after stripping a maximal one-letter extension of an access
 * sequence.
 */
public static <I, D> List<Word<I>> findShahbaz(Query<I, D> ceQuery, AccessSequenceTransformer<I> asTransformer) {
  Word<I> queryWord = ceQuery.getInput();
  int queryLen = queryWord.length();
  Word<I> prefix = ceQuery.getPrefix();
  int i = prefix.length();
  while (i <= queryLen) {
    Word<I> nextPrefix = queryWord.prefix(i);
    if (!asTransformer.isAccessSequence(nextPrefix)) {
      break;
    }
    i++;
  }
  return queryWord.subWord(i).suffixes(false);
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public Word<I> getPrefix() {
  return origQuery.getPrefix();
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public void processQueries(Collection<? extends Query<I, Boolean>> queries) {
  List<ProxyQuery<I>> misses = new ArrayList<>();
  cacheLock.lock();
  try {
    for (Query<I, Boolean> qry : queries) {
      Word<I> input = qry.getInput();
      Boolean answer = cache.get(input);
      if (answer != null) {
        qry.answer(answer);
      } else {
        misses.add(new ProxyQuery<>(qry));
      }
    }
  } finally {
    cacheLock.unlock();
  }
  delegate.processQueries(misses);
  cacheLock.lock();
  try {
    for (ProxyQuery<I> miss : misses) {
      cache.put(miss.getInput(), miss.getAnswer());
    }
  } finally {
    cacheLock.unlock();
  }
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public Word<I> getSuffix() {
  return origQuery.getSuffix();
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public void answer(Boolean output) {
  origQuery.answer(output);
  this.answer = output;
}

代码示例来源:origin: de.learnlib/learnlib-util

@Override
@Nonnull
public Word<I> getPrefix() {
  return originalQuery.getPrefix();
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public void processQueries(Collection<? extends Query<I, Boolean>> queries) {
  List<ProxyQuery<I>> unanswered = new ArrayList<>();
  incDfaLock.lock();
  try {
    for (Query<I, Boolean> q : queries) {
      Acceptance acc = incDfa.lookup(q.getInput());
      if (acc != Acceptance.DONT_KNOW) {
        q.answer(acc.toBoolean());
      } else {
        unanswered.add(new ProxyQuery<>(q));
      }
    }
  } finally {
    incDfaLock.unlock();
  }
  delegate.processQueries(unanswered);
  incDfaLock.lock();
  try {
    for (ProxyQuery<I> q : unanswered) {
      incDfa.insert(q.getInput(), q.getAnswer());
    }
  } finally {
    incDfaLock.unlock();
  }
}

代码示例来源:origin: de.learnlib/learnlib-util

@Override
@Nonnull
public Word<I> getSuffix() {
  return originalQuery.getSuffix();
}

代码示例来源:origin: de.learnlib/learnlib-util

@Override
public void answer(Word<O> output) {
  if (output == null) {
    throw new IllegalArgumentException("Query answer words must not be null");
  }
  originalQuery.answer(output.isEmpty() ? null : output.lastSymbol());
}

代码示例来源:origin: de.learnlib/learnlib-membership-oracles

private static <I, O> void processQueries(SUL<I, O> sul, Collection<? extends Query<I, Word<O>>> queries) {
  for (Query<I, Word<O>> q : queries) {
    Word<O> output = answerQuery(sul, q.getPrefix(), q.getSuffix());
    q.answer(output);
  }
}

代码示例来源:origin: de.learnlib/learnlib-counterexamples

/**
 * Returns all suffixes of the counterexample word as distinguishing suffixes, as suggested by Maler &amp; Pnueli.
 *
 * @param ceQuery
 *         the counterexample query
 *
 * @return all suffixes of the counterexample input
 */
public static <I, D> List<Word<I>> findMalerPnueli(Query<I, D> ceQuery) {
  return ceQuery.getInput().suffixes(false);
}

代码示例来源:origin: de.learnlib/learnlib-cache

@Override
public String toString() {
  return origQuery.toString();
}

代码示例来源:origin: de.learnlib/learnlib-util

public static <I, D> void answerQueriesParallel(QueryAnswerer<I, D> answerer,
                        Collection<? extends Query<I, D>> queries) {
  queries.parallelStream().forEach(q -> {
    Word<I> prefix = q.getPrefix();
    Word<I> suffix = q.getSuffix();
    D answer = answerer.answerQuery(prefix, suffix);
    q.answer(answer);
  });
}

代码示例来源:origin: de.learnlib/learnlib-counterexamples

/**
 * Transforms a suffix index returned by a {@link LocalSuffixFinder} into a list of distinguishing suffixes. This
 * list always contains the corresponding local suffix. Since local suffix finders only return a single suffix,
 * suffix-closedness of the set of distinguishing suffixes might not be preserved. Note that for correctly
 * implemented local suffix finders, this does not impair correctness of the learning algorithm. However, without
 * suffix closedness, intermediate hypothesis models might be non-canonical, if no additional precautions are taken.
 * For that reasons, the <tt>allSuffixes</tt> parameter can be specified to control whether or not the list returned
 * by {@link GlobalSuffixFinder#findSuffixes(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle)} of
 * the returned global suffix finder should not only contain the single suffix, but also all of its suffixes,
 * ensuring suffix-closedness.
 */
public static <I, D> List<Word<I>> suffixesForLocalOutput(Query<I, D> ceQuery,
                             int localSuffixIdx,
                             boolean allSuffixes) {
  if (localSuffixIdx == -1) {
    return Collections.emptyList();
  }
  Word<I> suffix = ceQuery.getInput().subWord(localSuffixIdx);
  if (!allSuffixes) {
    return Collections.singletonList(suffix);
  }
  return suffix.suffixes(false);
}

代码示例来源:origin: de.learnlib/learnlib-cache

private void answerSlave(Query<I, Word<O>> slave) {
  int start = slave.getPrefix().length();
  int end = start + slave.getSuffix().length();
  slave.answer(answer.subWord(start, end));
}

代码示例来源:origin: de.learnlib/learnlib-cache

Word<I> ref = q.getInput();
    Word<I> curr = q.getInput();
    if (!curr.isPrefixOf(ref)) {
      master = createMasterQuery(curr);

相关文章