-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sspace #61
base: main
Are you sure you want to change the base?
Sspace #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
add_subdirectory(identifiers-module) | ||
add_subdirectory(sections-module) | ||
add_subdirectory(sspace-search-module) | ||
add_subdirectory(utils-module) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add newline |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
file(GLOB SOURCES CONFIGURE_DEPENDS | ||
"*.c" "*.h" | ||
"*/*.c" "*/*.h" | ||
) | ||
|
||
add_library(sspace-search-module SHARED ${SOURCES}) | ||
target_link_libraries(sspace-search-module LINK_PUBLIC sc-kpm-common) | ||
target_include_directories(sspace-search-module | ||
PRIVATE "${CMAKE_CURRENT_LIST_DIR}" | ||
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/.." | ||
PUBLIC "${SC_MEMORY_SRC}" | ||
PUBLIC "${SC_KPM_SRC}" | ||
) | ||
|
||
if(${SC_CLANG_FORMAT_CODE}) | ||
target_clangformat_setup(sspace-search-module) | ||
endif() |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,134 @@ | ||||||
/* | ||||||
* This source file is part of an OSTIS project. For the latest info, see http://ostis.net | ||||||
* Distributed under the MIT License | ||||||
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) | ||||||
*/ | ||||||
|
||||||
#include "search_extensional_closure.h" | ||||||
#include "search_keynodes.h" | ||||||
#include "search_utils.h" | ||||||
#include "search_defines.h" | ||||||
#include "search.h" | ||||||
|
||||||
#include "sc-core/sc_helper.h" | ||||||
#include "sc-core/sc_memory_headers.h" | ||||||
#include <stdbool.h> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you need it? |
||||||
|
||||||
#define sc_type_arc_pos_const_temp (sc_type)(sc_type_const|sc_type_arc_access|sc_type_arc_pos|sc_type_arc_temp) | ||||||
#define sc_type_arc_pos_const (sc_type)(sc_type_const|sc_type_arc_access|sc_type_arc_pos) | ||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we need to define it in sc-machine? What do you think |
||||||
|
||||||
sc_result agent_search_extensional_closure(const sc_event * event, sc_addr arg) | ||||||
{ | ||||||
sc_addr question, answer; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
sc_iterator3 *it1, *it2; | ||||||
sc_bool sys_off = SC_TRUE; | ||||||
bool er = true; | ||||||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is it1, *it2 er sys_off? Make please full and understandable names. And declare them when you need to use them. Check everywhere |
||||||
|
||||||
printf("agent search extensional closure: enter\n"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove prints please |
||||||
|
||||||
if (!sc_memory_get_arc_end(s_default_ctx, arg, &question)) | ||||||
return SC_RESULT_ERROR_INVALID_PARAMS; | ||||||
|
||||||
// check question type | ||||||
if (sc_helper_check_arc( | ||||||
s_default_ctx, keynode_question_extensional_closure, question, sc_type_arc_pos_const_perm) == SC_FALSE) | ||||||
return SC_RESULT_ERROR_INVALID_TYPE; | ||||||
|
||||||
printf("agent search extensional closure: started\n"); | ||||||
|
||||||
answer = create_answer_node(); | ||||||
sc_addr front, back = sc_memory_node_new(s_default_ctx,sc_type_const); | ||||||
SYSTEM_ELEMENT(back); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to make it system element because you delete this node in the end of this agent. Also I am not sure if we need to make system elements in this agent everywhere |
||||||
// get operation argument | ||||||
it1 = sc_iterator3_f_a_a_new(s_default_ctx, question, sc_type_arc_pos_const_perm, 0); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Use some sc_type, not just int. Or add sc_type_unknown if you need it |
||||||
|
||||||
if (sc_iterator3_next(it1) == SC_TRUE) { | ||||||
printf("agent search extensional closure: found element\n"); | ||||||
if (sc_helper_check_arc(s_default_ctx,back,sc_iterator3_value(it1,2),sc_type_arc_pos_const_temp)!=SC_TRUE) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is the first usage of |
||||||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,back,sc_iterator3_value(it1,2)); | ||||||
SYSTEM_ELEMENT(arc); | ||||||
} | ||||||
|
||||||
sc_iterator3_free(it1); | ||||||
|
||||||
bool f = true; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename f |
||||||
while(f){ | ||||||
printf("agent search extensional closure: while started\n"); | ||||||
f = false; | ||||||
|
||||||
front = sc_memory_node_new(s_default_ctx,sc_type_const); | ||||||
SYSTEM_ELEMENT(front); | ||||||
|
||||||
it1 = sc_iterator3_f_a_a_new(s_default_ctx, back, sc_type_arc_pos_const_temp, 0); | ||||||
while (sc_iterator3_next(it1) == SC_TRUE) | ||||||
{ | ||||||
// if (IS_SYSTEM_ELEMENT(sc_iterator3_value(it1, 2))) | ||||||
// sys_off = SC_FALSE; | ||||||
|
||||||
appendIntoAnswer(answer, sc_iterator3_value(it1, 2)); | ||||||
// iterate output arcs and append them into answer | ||||||
it2 = sc_iterator3_f_a_a_new(s_default_ctx, sc_iterator3_value(it1, 2), sc_type_arc_pos, 0); | ||||||
while (sc_iterator3_next(it2) == SC_TRUE) | ||||||
{ | ||||||
// if (sys_off == SC_TRUE && | ||||||
// (IS_SYSTEM_ELEMENT(sc_iterator3_value(it2, 1)) || IS_SYSTEM_ELEMENT(sc_iterator3_value(it2, 2)))) | ||||||
// continue; | ||||||
|
||||||
/* if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,1),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||||||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,1),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||||||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,1)); | ||||||
SYSTEM_ELEMENT(arc); | ||||||
f = true; | ||||||
} | ||||||
*/ if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,2),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||||||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,2),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||||||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,2)); | ||||||
SYSTEM_ELEMENT(arc); | ||||||
f = true; | ||||||
// appendIntoAnswer(answer, sc_iterator3_value(it2, 1)); | ||||||
appendIntoAnswer(answer, sc_iterator3_value(it2, 2)); | ||||||
printf("agent search extensional closure: element added\n"); | ||||||
} | ||||||
|
||||||
} | ||||||
sc_iterator3_free(it2); | ||||||
|
||||||
it2 = sc_iterator3_a_f_a_new(s_default_ctx, 0, sc_iterator3_value(it1, 2), 0); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
if (sc_iterator3_next(it2) == SC_TRUE) { | ||||||
if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,0),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||||||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,0),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||||||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,0)); | ||||||
SYSTEM_ELEMENT(arc); | ||||||
f = true; | ||||||
appendIntoAnswer(answer, sc_iterator3_value(it2, 0)); | ||||||
printf("agent search extensional closure: beginning added\n"); | ||||||
} | ||||||
if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,2),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||||||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,2),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||||||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,2)); | ||||||
SYSTEM_ELEMENT(arc); | ||||||
f = true; | ||||||
appendIntoAnswer(answer, sc_iterator3_value(it2, 2)); | ||||||
printf("agent search extensional closure: ending added\n"); | ||||||
} | ||||||
|
||||||
} | ||||||
sc_iterator3_free(it2); | ||||||
|
||||||
} | ||||||
sc_memory_element_free(s_default_ctx,back); | ||||||
back = front; | ||||||
} | ||||||
sc_iterator3_free(it1); | ||||||
} else | ||||||
sc_iterator3_free(it1); | ||||||
|
||||||
sc_memory_element_free(s_default_ctx,back); | ||||||
connect_answer_to_question(question, answer); | ||||||
finish_question(question); | ||||||
|
||||||
printf("agent search extensional closure: leave\n"); | ||||||
|
||||||
return SC_RESULT_OK; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* This source file is part of an OSTIS project. For the latest info, see http://ostis.net | ||
* Distributed under the MIT License | ||
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
#ifndef _search_extensional_closure_h_ | ||
#define _search_extensional_closure_h_ | ||
|
||
#include "sc-core/sc_memory.h" | ||
|
||
/*! | ||
* Function that implement sc-agent to search all positive, constant and permanent | ||
* output arcs for specified sc-element | ||
*/ | ||
sc_result agent_search_extensional_closure(const sc_event * event, sc_addr arg); | ||
|
||
/*! Function that implemets sc-agent to search all positive, constant and permanent | ||
* output arcs with relations for specified sc-element | ||
*/ | ||
//sc_result agent_search_all_const_pos_output_arc_with_rel(const sc_event * event, sc_addr arg); | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* This source file is part of an OSTIS project. For the latest info, see http://ostis.net | ||
* Distributed under the MIT License | ||
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
#include "search_full-connected_closure.h" | ||
#include "search_keynodes.h" | ||
#include "search_utils.h" | ||
#include "search_defines.h" | ||
#include "search.h" | ||
|
||
#include "sc-core/sc_helper.h" | ||
#include "sc-core/sc_memory_headers.h" | ||
#include <stdbool.h> | ||
|
||
#define sc_type_arc_pos_const_temp (sc_type)(sc_type_const|sc_type_arc_access|sc_type_arc_pos|sc_type_arc_temp) | ||
#define sc_type_arc_pos_const (sc_type)(sc_type_const|sc_type_arc_access|sc_type_arc_pos) | ||
|
||
sc_result agent_search_fullconnected_closure(const sc_event * event, sc_addr arg) | ||
{ | ||
sc_addr question, answer; | ||
sc_iterator3 *it1, *it2; | ||
sc_bool sys_off = SC_TRUE; | ||
bool er = true; | ||
|
||
printf("agent search fullconnected closure: enter\n"); | ||
|
||
if (!sc_memory_get_arc_end(s_default_ctx, arg, &question)) | ||
return SC_RESULT_ERROR_INVALID_PARAMS; | ||
|
||
// check question type | ||
if (sc_helper_check_arc( | ||
s_default_ctx, keynode_question_fullconnected_closure, question, sc_type_arc_pos_const_perm) == SC_FALSE) | ||
return SC_RESULT_ERROR_INVALID_TYPE; | ||
|
||
printf("agent search fullconnected closure: started\n"); | ||
|
||
answer = create_answer_node(); | ||
sc_addr front, back = sc_memory_node_new(s_default_ctx,sc_type_const); | ||
SYSTEM_ELEMENT(back); | ||
// get operation argument | ||
it1 = sc_iterator3_f_a_a_new(s_default_ctx, question, sc_type_arc_pos_const_perm, 0); | ||
|
||
if (sc_iterator3_next(it1) == SC_TRUE) { | ||
printf("agent search fullconnected closure: found element\n"); | ||
if (sc_helper_check_arc(s_default_ctx,back,sc_iterator3_value(it1,2),sc_type_arc_pos_const_temp)!=SC_TRUE) { | ||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,back,sc_iterator3_value(it1,2)); | ||
SYSTEM_ELEMENT(arc); | ||
} | ||
|
||
sc_iterator3_free(it1); | ||
|
||
bool f = true; | ||
while(f){ | ||
printf("agent search fullconnected closure: while started\n"); | ||
f = false; | ||
|
||
front = sc_memory_node_new(s_default_ctx,sc_type_const); | ||
SYSTEM_ELEMENT(front); | ||
|
||
it1 = sc_iterator3_f_a_a_new(s_default_ctx, back, sc_type_arc_pos_const_temp, 0); | ||
while (sc_iterator3_next(it1) == SC_TRUE) | ||
{ | ||
// if (IS_SYSTEM_ELEMENT(sc_iterator3_value(it1, 2))) | ||
// sys_off = SC_FALSE; | ||
|
||
appendIntoAnswer(answer, sc_iterator3_value(it1, 2)); | ||
// iterate output arcs and append them into answer | ||
it2 = sc_iterator3_f_a_a_new(s_default_ctx, sc_iterator3_value(it1, 2), sc_type_arc_pos, 0); | ||
while (sc_iterator3_next(it2) == SC_TRUE) | ||
{ | ||
// if (sys_off == SC_TRUE && | ||
// (IS_SYSTEM_ELEMENT(sc_iterator3_value(it2, 1)) || IS_SYSTEM_ELEMENT(sc_iterator3_value(it2, 2)))) | ||
// continue; | ||
|
||
/* if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,1),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,1),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,1)); | ||
SYSTEM_ELEMENT(arc); | ||
f = true; | ||
} | ||
*/ if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,2),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,2),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,2)); | ||
SYSTEM_ELEMENT(arc); | ||
f = true; | ||
appendIntoAnswer(answer, sc_iterator3_value(it2, 1)); | ||
appendIntoAnswer(answer, sc_iterator3_value(it2, 2)); | ||
} | ||
|
||
} | ||
sc_iterator3_free(it2); | ||
|
||
it2 = sc_iterator3_a_f_a_new(s_default_ctx, 0, sc_iterator3_value(it1, 2), 0); | ||
if (sc_iterator3_next(it2) == SC_TRUE) { | ||
if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,0),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,0),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,0)); | ||
SYSTEM_ELEMENT(arc); | ||
f = true; | ||
appendIntoAnswer(answer, sc_iterator3_value(it2, 0)); | ||
} | ||
if ((sc_helper_check_arc(s_default_ctx,answer,sc_iterator3_value(it2,2),sc_type_arc_pos_const_perm)!=SC_TRUE) && | ||
(sc_helper_check_arc(s_default_ctx,front,sc_iterator3_value(it2,2),sc_type_arc_pos_const_temp)!=SC_TRUE)) { | ||
sc_addr arc = sc_memory_arc_new(s_default_ctx,sc_type_arc_pos_const_temp,front,sc_iterator3_value(it2,2)); | ||
SYSTEM_ELEMENT(arc); | ||
f = true; | ||
appendIntoAnswer(answer, sc_iterator3_value(it2, 2)); | ||
} | ||
|
||
} | ||
sc_iterator3_free(it2); | ||
|
||
} | ||
sc_memory_element_free(s_default_ctx,back); | ||
back = front; | ||
} | ||
sc_iterator3_free(it1); | ||
} else | ||
sc_iterator3_free(it1); | ||
|
||
sc_memory_element_free(s_default_ctx,back); | ||
connect_answer_to_question(question, answer); | ||
finish_question(question); | ||
|
||
printf("agent search fullconnected closure: leave\n"); | ||
|
||
return SC_RESULT_OK; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* This source file is part of an OSTIS project. For the latest info, see http://ostis.net | ||
* Distributed under the MIT License | ||
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
#ifndef _search_fullconnected_closure_h_ | ||
#define _search_fullconnected_closure_h_ | ||
|
||
#include "sc-core/sc_memory.h" | ||
|
||
/*! | ||
* Function that implement sc-agent to search all positive, constant and permanent | ||
* output arcs for specified sc-element | ||
*/ | ||
sc_result agent_search_fullconnected_closure(const sc_event * event, sc_addr arg); | ||
|
||
/*! Function that implemets sc-agent to search all positive, constant and permanent | ||
* output arcs with relations for specified sc-element | ||
*/ | ||
//sc_result agent_search_all_const_pos_output_arc_with_rel(const sc_event * event, sc_addr arg); | ||
|
||
#endif |
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.
I'd like to rename sspace to semantic-space everywhere, it would upgrade understanding. There is no need to save symbols.