<commit_before>/* dlvhex -- Answer-Set Programming with external interfaces.
 * Copyright (C) 2005-2007 <NAME>
 * Copyright (C) 2006-2015 <NAME>
 * Copyright (C) 2009-2015 <NAME>
 * Copyright (C) 2011-2015 <NAME>
 *
 * This file is part of dlvhex.
 *
 * dlvhex is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * dlvhex is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with dlvhex; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 */

/**
 * @file   PluginInterface.cpp
 * @author <NAME>
 * @date   Mon Oct 17 14:37:07 CEST 2005
 *
 * @brief Definition of Classes PluginAtom, PluginRewriter,
 * and PluginInterface.
 *
 *
 */

#include "dlvhex2/PluginInterface.h"

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include "dlvhex2/Registry.h"
#include "dlvhex2/ProgramCtx.h"
#include "dlvhex2/GenuineSolver.h"
#include "dlvhex2/Term.h"
#include "dlvhex2/ID.h"
#include "dlvhex2/Term.h"
#include "dlvhex2/ID.h"
#include "dlvhex2/Benchmarking.h"
#include "dlvhex2/HexParser.h"
#include "dlvhex2/ExternalLearningHelper.h"

DLVHEX_NAMESPACE_BEGIN

#if 0
bool PluginAtom::Query::operator<(const Query& other) const
{
    /*
    return
      ( interpretation < other.interpretation ) ||
      ( interpretation == other.interpretation &&
        input < other.input ) ||
      ( interpretation == other.interpretation &&
        input == other.input &&
        pattern < other.pattern );
        */
}
#endif

bool PluginAtom::Query::operator==(const Query& other) const
{
    return
        (input == other.input) &&
        (pattern == other.pattern) &&
        (
        (interpretation == other.interpretation) ||
        (interpretation != 0 && other.interpretation != 0 &&
        *interpretation == *other.interpretation) &&
        // Equivalence of the predicateInputMask in the current and the cached query is required for the reason described in method retrieveCached.
        // Because for the same external atom the mask can only increase over time (when new ground atoms are added to registry) but never decrease,
        // comparing the number of atoms suffices.
        (predicateInputMask->getStorage().count == other.predicateInputMask->getStorage().count);
        );
}


// hash function for QueryAnswerCache
std::size_t hash_value(const PluginAtom::Query& q)
{<commit_msg>update Query::operator==() and add a comment<commit_after>/* dlvhex -- Answer-Set Programming with external interfaces.
 * Copyright (C) 2005-2007 <NAME>
 * Copyright (C) 2006-2015 <NAME>
 * Copyright (C) 2009-2015 <NAME>
 * Copyright (C) 2011-2015 <NAME>
 *
 * This file is part of dlvhex.
 *
 * dlvhex is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * dlvhex is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with dlvhex; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 */

/**
 * @file   PluginInterface.cpp
 * @author <NAME>
 * @date   Mon Oct 17 14:37:07 CEST 2005
 *
 * @brief Definition of Classes PluginAtom, PluginRewriter,
 * and PluginInterface.
 *
 *
 */

#include "dlvhex2/PluginInterface.h"

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include "dlvhex2/Registry.h"
#include "dlvhex2/ProgramCtx.h"
#include "dlvhex2/GenuineSolver.h"
#include "dlvhex2/Term.h"
#include "dlvhex2/ID.h"
#include "dlvhex2/Term.h"
#include "dlvhex2/ID.h"
#include "dlvhex2/Benchmarking.h"
#include "dlvhex2/HexParser.h"
#include "dlvhex2/ExternalLearningHelper.h"

DLVHEX_NAMESPACE_BEGIN

#if 0
bool PluginAtom::Query::operator<(const Query& other) const
{
    /*
    return
      ( interpretation < other.interpretation ) ||
      ( interpretation == other.interpretation &&
        input < other.input ) ||
      ( interpretation == other.interpretation &&
        input == other.input &&
        pattern < other.pattern );
        */
}
#endif

bool PluginAtom::Query::operator==(const Query& other) const
{
    return
        (input == other.input) &&
        (pattern == other.pattern) &&
        (
        (interpretation == other.interpretation) ||
        (interpretation != 0 && other.interpretation != 0 &&
        *interpretation == *other.interpretation) &&
        // Equivalence of the predicateInputMask in the current and the cached query is required for the reason described in method retrieveCached.
        // Because for the same external atom the mask can only increase over time (when new ground atoms are added to registry) but never decrease,
        // comparing the number of atoms suffices.
        (predicateInputMask->getStorage().count() == other.predicateInputMask->getStorage().count());
        );
}


// hash function for QueryAnswerCache
std::size_t hash_value(const PluginAtom::Query& q)
{
{'fraction_non_alphanumeric': 0.10668538340059659, 'fraction_numerical': 0.024916652044218283, 'mean_word_length': 3.4740973312401886, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1968025', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1656, 'n_words': 581}