<commit_before>/* dlvhex -- Answer-Set Programming with external interfaces.
 * Copyright (C) 2005, 2006, 2007 <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 Component.cpp
 * @author <NAME>
 * @date Mon Sep 19 13:14:56 CEST 2005
 *
 * @brief Conponent and Subgraph Class.
 *
 *
 */

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

#ifdef DLVHEX_DEBUG
#include <boost/date_time/posix_time/posix_time.hpp>
#endif // DLVHEX_DEBUG

#include "dlvhex/Component.h"
#include "dlvhex/ProgramBuilder.h"
#include "dlvhex/ASPsolver.h"
#include "dlvhex/globals.h"
#include "dlvhex/PrintVisitor.h"
#include "dlvhex/EvaluateExtatom.h"


DLVHEX_NAMESPACE_BEGIN

Component::Component()
    : evaluated(false)
{
}


Component::~Component()
{
}


bool
Component::isSolved() const
{
    return evaluated;
}


void
Component::addAtomNode(const AtomNodePtr atomnode)
{
    atomnodes.push_back(atomnode);
}



const std::vector<AtomNodePtr>&
Component::getNodes() const
{
    return atomnodes;
}


Program
Component::getBottom() const
{
    Program program;

    //
    // go through all nodes
    //
    std::vector<AtomNodePtr>::const_iterator node = atomnodes.begin();

    while (node != atomnodes.end())
    {
        const std::vector<Rule*>& rules = (*node)->getRules();

        //
        // add all rules from this node to the component
        //
        for (std::vector<Rule*>::const_iterator ri = rules.begin();
                ri != rules.end();
                ++ri)
        {
            program.addRule(*ri);
        }

        ++node;
    }

    return program;
}


void
Component::getResult(std::vector<AtomSet>& r)
{
    r = result;
}


bool
Component::isInComponent(const Atom* at) const
{
    bool belongsToComp = false;

    std::vector<AtomNodePtr>::const_iterator nodeit = atomnodes.begin();

    while (nodeit != atomnodes.end())
    {
        if ((*nodeit++)->getAtom().get() == at)
        {
            belongsToComp = true;

            break;
        }
    }

    return belongsToComp;
}


ProgramComponent::ProgramComponent(const std::vector<AtomNodePtr>& nodes,<commit_msg>(Component::isInComponent): Beautify.<commit_after>/* dlvhex -- Answer-Set Programming with external interfaces.
 * Copyright (C) 2005, 2006, 2007 <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 Component.cpp
 * @author <NAME>
 * @date Mon Sep 19 13:14:56 CEST 2005
 *
 * @brief Conponent and Subgraph Class.
 *
 *
 */

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

#ifdef DLVHEX_DEBUG
#include <boost/date_time/posix_time/posix_time.hpp>
#endif // DLVHEX_DEBUG

#include "dlvhex/Component.h"
#include "dlvhex/ProgramBuilder.h"
#include "dlvhex/ASPsolver.h"
#include "dlvhex/globals.h"
#include "dlvhex/PrintVisitor.h"
#include "dlvhex/EvaluateExtatom.h"


DLVHEX_NAMESPACE_BEGIN

Component::Component()
    : evaluated(false)
{
}


Component::~Component()
{
}


bool
Component::isSolved() const
{
    return evaluated;
}


void
Component::addAtomNode(const AtomNodePtr atomnode)
{
    atomnodes.push_back(atomnode);
}



const std::vector<AtomNodePtr>&
Component::getNodes() const
{
    return atomnodes;
}


Program
Component::getBottom() const
{
    Program program;

    //
    // go through all nodes
    //
    std::vector<AtomNodePtr>::const_iterator node = atomnodes.begin();

    while (node != atomnodes.end())
    {
        const std::vector<Rule*>& rules = (*node)->getRules();

        //
        // add all rules from this node to the component
        //
        for (std::vector<Rule*>::const_iterator ri = rules.begin();
                ri != rules.end();
                ++ri)
        {
            program.addRule(*ri);
        }

        ++node;
    }

    return program;
}


void
Component::getResult(std::vector<AtomSet>& r)
{
    r = result;
}


bool
Component::isInComponent(const Atom* at) const
{
  for (std::vector<AtomNodePtr>::const_iterator nodeit = atomnodes.begin();
       nodeit != atomnodes.end();
       ++nodeit)
    {
      if ((*nodeit)->getAtom().get() == at)
        {
	  return true;
        }
    }
  
  return false;
}


ProgramComponent::ProgramComponent(const std::vector<AtomNodePtr>& nodes,
{'fraction_non_alphanumeric': 0.1190138346931536, 'fraction_numerical': 0.01312522170982618, 'mean_word_length': 3.1281112737920935, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '4705815', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1747, 'n_words': 519}