-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c038445
commit e3bedc9
Showing
7 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#install header files | ||
INSTALL(FILES | ||
|
||
reduct.h | ||
|
||
DESTINATION | ||
|
||
"include/${PROJECT_NAME}/atomese/reduct" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** reduct.cc --- | ||
* | ||
* Copyright (C) 2018 OpenCog Foundation | ||
* | ||
* Author: Yidnekachew Wondimu <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License v3 as | ||
* published by the Free Software Foundation and including the exceptions | ||
* at http://opencog.org/wiki/Licenses | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program; if not, write to: | ||
* Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#include <moses/comboreduct/reduct/reduct.h> | ||
#include <moses/comboreduct/converter/combo_atomese.h> | ||
#include "reduct.h" | ||
|
||
namespace opencog { | ||
namespace atomese { | ||
|
||
Handle full_reduce(combo::combo_tree& tr) | ||
{ | ||
// combo::combo_tree& tr = combo::atomese_combo(to_reduce); | ||
reduct::full_reduce(tr); | ||
return combo::atomese_combo(tr); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** reduct.h --- | ||
* | ||
* Copyright (C) 2018 OpenCog Foundation | ||
* | ||
* Author: Yidnekachew Wondimu <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License v3 as | ||
* published by the Free Software Foundation and including the exceptions | ||
* at http://opencog.org/wiki/Licenses | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program; if not, write to: | ||
* Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#ifndef _OPENCOG_ATOMESE_REDUCT_H | ||
#define _OPENCOG_ATOMESE_REDUCT_H | ||
|
||
namespace opencog { | ||
namespace atomese { | ||
|
||
/** | ||
* Apply full_reduction on an atomese program. | ||
* | ||
* @param tr a combo_tree to be reduced. | ||
* @todo it should accept a Handle as an argument after the combo->atomese converter is done. | ||
* @return | ||
*/ | ||
Handle full_reduce(combo::combo_tree& tr); | ||
|
||
} | ||
} | ||
|
||
#endif //_OPENCOG_ATOMESE_REDUCT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ADD_SUBDIRECTORY (representation) | ||
ADD_SUBDIRECTORY (reduct) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
IF (HAVE_GUILE) | ||
ADD_CXXTEST(reductUTest) | ||
TARGET_LINK_LIBRARIES(reductUTest | ||
atomese | ||
${ATOMSPACE_LIBRARIES} | ||
${GUILE_LIBRARIES} | ||
) | ||
ENDIF (HAVE_GUILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <opencog/util/Logger.h> | ||
#include <moses/comboreduct/combo/combo.h> | ||
#include <moses/comboreduct/converter/combo_atomese.h> | ||
#include <opencog/atoms/base/Link.h> | ||
#include <opencog/atoms/base/Node.h> | ||
#include "moses/atomese/reduct/reduct.h" | ||
|
||
using namespace opencog; | ||
using namespace std; | ||
|
||
#define cl createLink | ||
#define cn createNode | ||
|
||
class reductUTest : public CxxTest::TestSuite | ||
{ | ||
public: | ||
reductUTest(); | ||
|
||
~reductUTest(); | ||
|
||
void test_full_reduce(); | ||
}; | ||
|
||
reductUTest::reductUTest() | ||
{ | ||
logger().set_level(Logger::DEBUG); | ||
logger().set_print_to_stdout_flag(true); | ||
} | ||
|
||
reductUTest::~reductUTest() | ||
{ | ||
// Erase the log file if no assertions failed. | ||
if (!CxxTest::TestTracker::tracker().suiteFailed()) | ||
std::remove(logger().get_filename().c_str()); | ||
} | ||
|
||
// test atomese full_reduction. | ||
void reductUTest::test_full_reduce() | ||
{ | ||
Handle X = cn(PREDICATE_NODE, "1"), | ||
Y = cn(PREDICATE_NODE, "2"); | ||
|
||
// TODO: this should be passed to atomese::full_reduce instead of a combo_tree. | ||
// Handle to_reduce = cl(OR_LINK, | ||
// cl(AND_LINK, X, X), | ||
// Y); | ||
|
||
combo::combo_tree tr = combo::str2combo_tree("or(and($1 $1) $2)", {}); | ||
|
||
Handle result = atomese::full_reduce(tr); | ||
|
||
Handle expected = cl(OR_LINK, X, Y); | ||
|
||
TS_ASSERT(content_eq(expected, result)); | ||
} |
e3bedc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per #21.
e3bedc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nil said: