/** * @param expressions * @return map with defined signatures as key and {@link SourceInfo} as value. * @throws ParserException */ protected Map<String, SourceInfo> getDefinedSignatures(Collection<DatabaseFormula> formulas) throws ParserException { CognitiveKR ckr = getCognitiveKR(); Map<String, SourceInfo> signatures = new LinkedHashMap<>(formulas.size()); for (DatabaseFormula formula : formulas) { for (String signature : ckr.getDefinedSignatures(formula)) { signatures.put(signature, formula.getSourceInfo()); } } return signatures; }
/** * Returns a filtered set of beliefs whose signature matches one of those in * filter. * * @param mentalState * @param filter * A list of predicate signatures. * @return all belief predicates from mentalState that are in the filter * list. * @throws MSTQueryException * @throws MSTDatabaseException */ private static Set<DatabaseFormula> filteredBeliefs(MentalStateWithEvents mentalState, Set<String> filter) throws MSTDatabaseException, MSTQueryException { Set<DatabaseFormula> beliefs = new HashSet<>(mentalState.getBeliefs()); Set<DatabaseFormula> remove = new LinkedHashSet<>(); // hack around #3057 to prevent ConcurrentModificationException List<DatabaseFormula> formulas = new ArrayList<>(beliefs); for (DatabaseFormula belief : formulas) { if (!filter.contains(belief.getSignature())) { remove.add(belief); } } beliefs.removeAll(remove); return beliefs; }
reportWarning(MASWarning.PREDICATE_UNUSED, belief.getSourceInfo(), belief.getSignature());
/** * @param formulas * @return map with all explicitly declared signatures as key and all * {@link SourceInfo} as value. * @throws ParserException */ protected Map<String, SourceInfo> getDeclaredSignatures(Collection<DatabaseFormula> formulas) throws ParserException { CognitiveKR ckr = getCognitiveKR(); Map<String, SourceInfo> signatures = new LinkedHashMap<>(formulas.size()); for (DatabaseFormula formula : formulas) { for (String signature : ckr.getDeclaredSignatures(formula)) { signatures.put(signature, formula.getSourceInfo()); } } return signatures; }
if (had.add(unused.getSignature())) { this.beliefsUnused.add(unused);
/** * Add predicates used in a clause as queries. */ public void addQuery(DatabaseFormula formula) { // we may assume the formula is a single term, so we can just // as well handle the inner term as a general term. addQuery(((PrologDBFormula) formula).getCompound(), formula.getSourceInfo()); }
@Override public Set<String> getDeclaredSignatures(DatabaseFormula formula) throws ParserException { return SemanticTools.getDeclaredSignatures(((PrologDBFormula) formula).getCompound(), formula.getSourceInfo()); }
@Override public Set<String> getDefinedSignatures(DatabaseFormula formula) throws ParserException { return SemanticTools.getDefinedSignatures(((PrologDBFormula) formula).getCompound(), formula.getSourceInfo()); }