Skip to content

Commit

Permalink
refactor: change ScTypes on the new format
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarenkoAI committed Oct 30, 2024
1 parent c41db3f commit 407a73a
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ set(SOURCES
add_library(identifiers-module SHARED ${SOURCES})
target_link_libraries(identifiers-module
LINK_PUBLIC sc-memory
LINK_PUBLIC sc-core
LINK_PUBLIC sc-builder-lib
LINK_PUBLIC sc-agents-common
)
target_include_directories(identifiers-module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ScResult TranslateMainSystemIdtfsFromScToFileAgent::DoProgram(ScActionInitiatedE
std::stringstream streamIdtfs;

ScIterator3Ptr const & iterator3PtrEdgeBelongsToNrelSystemIdtf =
m_context.CreateIterator3(nrelSystemIdtf, ScType::EdgeAccessConstPosPerm, ScType::EdgeDCommonConst);
m_context.CreateIterator3(nrelSystemIdtf, ScType::ConstPermPosArc, ScType::ConstCommonArc);

ScAddr edgeBelongsToNrelSystemIdtf;
ScAddr sourceOfEdgeBelongsToNrelSystemIdtf;
Expand Down Expand Up @@ -91,9 +91,9 @@ std::string TranslateMainSystemIdtfsFromScToFileAgent::GetSystemIdtfAndVerifyNod
ScAddr identifierLink;
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_context.CreateIterator5(
node,
ScType::EdgeDCommonConst,
ScType::LinkConst,
ScType::EdgeAccessConstPosPerm,
ScType::ConstCommonArc,
ScType::ConstNodeLink,
ScType::ConstPermPosArc,
m_context.SearchElementBySystemIdentifier("nrel_system_identifier"));

if (iterator5PtrCheckOnlyOneIdtf->Next())
Expand All @@ -114,21 +114,21 @@ std::string TranslateMainSystemIdtfsFromScToFileAgent::GetMainIdtfAndVerifyNode(
ScAddr mainIdentifierLink;
ScAddr mainAnotherIdentifierLink;
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_context.CreateIterator5(
node, ScType::EdgeDCommonConst, ScType::LinkConst, ScType::EdgeAccessConstPosPerm, ScKeynodes::nrel_main_idtf);
node, ScType::ConstCommonArc, ScType::ConstNodeLink, ScType::ConstPermPosArc, ScKeynodes::nrel_main_idtf);

bool isLangRu;
while (iterator5PtrCheckOnlyOneIdtf->Next())
{
mainIdentifierLink = iterator5PtrCheckOnlyOneIdtf->Get(2);
isLangRu = m_context.CheckConnector(ScKeynodes::lang_ru, mainIdentifierLink, ScType::EdgeAccessConstPosPerm);
isLangRu = m_context.CheckConnector(ScKeynodes::lang_ru, mainIdentifierLink, ScType::ConstPermPosArc);

if (isLangRu)
{
while (iterator5PtrCheckOnlyOneIdtf->Next())
{
mainAnotherIdentifierLink = iterator5PtrCheckOnlyOneIdtf->Get(2);
isLangRu =
m_context.CheckConnector(ScKeynodes::lang_ru, mainAnotherIdentifierLink, ScType::EdgeAccessConstPosPerm);
m_context.CheckConnector(ScKeynodes::lang_ru, mainAnotherIdentifierLink, ScType::ConstPermPosArc);

if (isLangRu)
return identifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,61 @@ class TranslateMainSystemIdtfsFromScToFileAgent : public ScActionInitiatedAgent
{ScType::Var, "sc_node"},

{ScType::Node, "sc_node"},
{ScType::Link, "sc_link"},
{ScType::LinkClass, "sc_link"},
{ScType::NodeLink, "sc_link"},
{ScType::NodeLinkClass, "sc_link"},
{ScType::Unknown, "sc_node"},

{ScType::NodeConst, "sc_node"},
{ScType::NodeVar, "sc_node"},
{ScType::ConstNode, "sc_node"},
{ScType::VarNode, "sc_node"},

{ScType::LinkConst, "sc_link"},
{ScType::LinkVar, "sc_link"},
{ScType::ConstNodeLink, "sc_link"},
{ScType::VarNodeLink, "sc_link"},

{ScType::NodeStruct, "sc_node_struct"},
{ScType::NodeStructure, "sc_node_struct"},
{ScType::NodeTuple, "sc_node_tuple"},
{ScType::NodeRole, "sc_node_role_relation"},
{ScType::NodeNoRole, "sc_node_norole_relation"},
{ScType::NodeClass, "sc_node_class"},
{ScType::NodeMaterial, "sc_node_material"},

{ScType::NodeConstStruct, "sc_node_struct"},
{ScType::NodeConstTuple, "sc_node_tuple"},
{ScType::NodeConstRole, "sc_node_role_relation"},
{ScType::NodeConstNoRole, "sc_node_norole_relation"},
{ScType::NodeConstClass, "sc_node_class"},
{ScType::NodeConstMaterial, "sc_node_material"},
{ScType::ConstNodeStructure, "sc_node_struct"},
{ScType::ConstNodeTuple, "sc_node_tuple"},
{ScType::ConstNodeRole, "sc_node_role_relation"},
{ScType::ConstNodeNoRole, "sc_node_norole_relation"},
{ScType::ConstNodeClass, "sc_node_class"},
{ScType::ConstNodeMaterial, "sc_node_material"},

{ScType::NodeVarStruct, "sc_node_struct"},
{ScType::NodeVarTuple, "sc_node_tuple"},
{ScType::NodeVarRole, "sc_node_role_relation"},
{ScType::NodeVarNoRole, "sc_node_norole_relation"},
{ScType::NodeVarClass, "sc_node_class"},
{ScType::NodeVarMaterial, "sc_node_material"}};
{ScType::VarNodeStructure, "sc_node_struct"},
{ScType::VarNodeTuple, "sc_node_tuple"},
{ScType::ScType::VarNodeRole, "sc_node_role_relation"},
{ScType::VarNodeNoRole, "sc_node_norole_relation"},
{ScType::VarNodeClass, "sc_node_class"},
{ScType::VarNodeMaterial, "sc_node_material"}};

std::map<ScType, std::string> ScTypesOfEdgesWithSCsClasses = {
{ScType::EdgeUCommon, "sc_edge"},
{ScType::EdgeDCommon, "sc_edge_common"},

{ScType::EdgeUCommonConst, "<=>"},
{ScType::EdgeDCommonConst, "sc_edge_common"},

{ScType::EdgeAccess, "sc_edge_access"},

{ScType::EdgeAccessConstPosPerm, "sc_edge_main"},
{ScType::EdgeAccessConstNegPerm, "sc_edge_main"},
{ScType::EdgeAccessConstFuzPerm, "sc_edge_main"},
{ScType::EdgeAccessConstPosTemp, "sc_edge_main"},
{ScType::EdgeAccessConstNegTemp, "sc_edge_main"},
{ScType::EdgeAccessConstFuzTemp, "sc_edge_main"},

{ScType::EdgeUCommonVar, "_<=>"},
{ScType::EdgeDCommonVar, "sc_edge_common"},
{ScType::EdgeAccessVarPosPerm, "sc_edge_main"},
{ScType::EdgeAccessVarNegPerm, "sc_edge_main"},
{ScType::EdgeAccessVarFuzPerm, "sc_edge_main"},
{ScType::EdgeAccessVarPosTemp, "sc_edge_main"},
{ScType::EdgeAccessVarNegTemp, "sc_edge_main"},
{ScType::EdgeAccessVarFuzTemp, "sc_edge_main"}};
{ScType::CommonEdge, "sc_edge"},
{ScType::VarCommonArc, "sc_edge_common"},

{ScType::ConstCommonEdge, "<=>"},
{ScType::ConstCommonArc, "sc_edge_common"},

{ScType::ConstTempPosArc, "sc_edge_access"},

{ScType::ConstPermPosArc, "sc_edge_main"},
{ScType::ConstPermNegArc, "sc_edge_main"},
{ScType::ConstFuzArc, "sc_edge_main"},
{ScType::ConstTempPosArc, "sc_edge_main"},
{ScType::ConstTempNegArc, "sc_edge_main"},
{ScType::ConstFuzArc, "sc_edge_main"},

{ScType::VarCommonEdge, "_<=>"},
{ScType::VarCommonArc, "sc_edge_common"},
{ScType::VarPosArc, "sc_edge_main"},
{ScType::VarPermNegArc, "sc_edge_main"},
{ScType::VarFuzArc, "sc_edge_main"},
{ScType::VarTempPosArc, "sc_edge_main"},
{ScType::VarTempNegArc, "sc_edge_main"},
{ScType::VarFuzArc, "sc_edge_main"}};

private:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units
NAME identifiers-module-test-starter
DEPENDS sc-memory sc-core sc-builder-lib identifiers-module
INCLUDES ${SC_MEMORY_SRC}/tests/sc-memory/_test ${SC_TOOLS_SRC}
INCLUDES ${SC_TOOLS_SRC} ${SC_MEMORY_SRC} ${SC_BUILDER_PATH}
)

add_definitions(-DMODULE_TEST_SRC_PATH="${CMAKE_CURRENT_LIST_DIR}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "sc-builder/src/scs_loader.hpp"
#include "sc_test.hpp"
#include <gtest/gtest.h>
#include <sc-builder/scs_loader.hpp>
#include <sc-memory/test/sc_test.hpp>

#include "sc-agents-common/utils/CommonUtils.hpp"

#include "keynodes/identifiers_keynodes.hpp"
#include "agent/translate_main_system_idtfs_from_sc_to_file_agent.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/

#include "sc-agents-common/utils/IteratorUtils.hpp"
#include "sc-agents-common/utils/GenerationUtils.hpp"

#include "utils/set_utils.hpp"
Expand Down Expand Up @@ -73,21 +72,21 @@ ScAddr AddSectionAgent::GenerateSection(
newSection = sections_generator::GenerateSection(&m_context, sectionName, lang, true);
else
{
if (m_context.CheckConnector(decompositionTuple, newSection, ScType::EdgeAccessConstPosPerm)
if (m_context.CheckConnector(decompositionTuple, newSection, ScType::ConstPermPosArc)
|| parentSection == newSection)
return {};
}

ScAddr lastSection = sections_utils::GetLastSubSection(&m_context, decompositionTuple);
ScAddr newSectionArc = m_context.GenerateConnector(ScType::EdgeAccessConstPosPerm, decompositionTuple, newSection);
ScAddr newSectionArc = m_context.GenerateConnector(ScType::ConstPermPosArc, decompositionTuple, newSection);
if (m_context.IsElement(lastSection))
{
SC_AGENT_LOG_DEBUG("Last section system idtf is \"" + m_context.GetElementSystemIdentifier(lastSection) + "\".");
SC_AGENT_LOG_DEBUG("Last section system identifier is \"" + m_context.GetElementSystemIdentifier(lastSection) + "\".");
ScIterator5Ptr lastSectionIterator = m_context.CreateIterator5(
decompositionTuple,
ScType::EdgeAccessConstPosPerm,
ScType::ConstPermPosArc,
lastSection,
ScType::EdgeAccessConstPosTemp,
ScType::ConstTempPosArc,
SectionsKeynodes::rrel_last);
if (lastSectionIterator->Next())
{
Expand All @@ -97,14 +96,14 @@ ScAddr AddSectionAgent::GenerateSection(

utils::GenerationUtils::generateRelationBetween(
&m_context, previousSectionArc, newSectionArc, ScKeynodes::nrel_basic_sequence);
m_context.GenerateConnector(ScType::EdgeAccessConstPosTemp, SectionsKeynodes::rrel_last, newSectionArc);
m_context.GenerateConnector(ScType::ConstTempPosArc, SectionsKeynodes::rrel_last, newSectionArc);
}
}
else
{
SC_AGENT_LOG_DEBUG("Added section is new.");
m_context.GenerateConnector(ScType::EdgeAccessConstPosPerm, ScKeynodes::rrel_1, newSectionArc);
m_context.GenerateConnector(ScType::EdgeAccessConstPosTemp, SectionsKeynodes::rrel_last, newSectionArc);
m_context.GenerateConnector(ScType::ConstPermPosArc, ScKeynodes::rrel_1, newSectionArc);
m_context.GenerateConnector(ScType::ConstTempPosArc, SectionsKeynodes::rrel_last, newSectionArc);
}

sectionsModule::SetUtils::AddToSets(&m_context, parentSection, {SectionsKeynodes::non_atomic_section});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ ScAddrVector GetDecompositionAgent::GetDecomposition(ScAddr const & subjDomainAd
ScTemplate decompositionTemplate;
decompositionTemplate.Quintuple(
subjDomainAddr,
ScType::EdgeDCommonVar,
ScType::NodeVar >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm,
ScType::VarCommonArc,
ScType::VarNode >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::VarPermPosArc,
decompositionAddr);
decompositionTemplate.Quintuple(
sections_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm,
ScType::NodeVar >> sections_aliases::SECTION_NODE,
ScType::EdgeAccessVarPosPerm,
ScType::VarPermPosArc,
ScType::VarNode >> sections_aliases::SECTION_NODE,
ScType::VarPermPosArc,
ScKeynodes::rrel_1);
ScTemplateSearchResult result;
m_context.SearchByTemplate(decompositionTemplate, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ bool RemoveSectionAgent::RemoveSection(ScAddr const & section)

return true;
}
ScAddr edge = m_context.GenerateConnector(ScType::EdgeAccessConstPosPerm, SectionsKeynodes::removed_section, section);
ScAddr edge = m_context.GenerateConnector(ScType::ConstPermPosArc, SectionsKeynodes::removed_section, section);
return m_context.IsElement(edge);
}

Expand Down Expand Up @@ -154,7 +154,7 @@ void RemoveSectionAgent::HandleNeighboringSections(ScAddr const & tuple, ScAddr
if (!m_context.IsElement(currentSectionEdge))
{
ScIterator3Ptr currentSectionEdgeIterator =
m_context.CreateIterator3(tuple, ScType::EdgeAccessConstPosPerm, section);
m_context.CreateIterator3(tuple, ScType::ConstPermPosArc, section);
if (currentSectionEdgeIterator->Next())
{
currentSectionEdge = currentSectionEdgeIterator->Get(1);
Expand All @@ -172,13 +172,13 @@ void RemoveSectionAgent::HandleNeighboringSections(ScAddr const & tuple, ScAddr
// If current element is the last
if (m_context.IsElement(previousSection) && !m_context.IsElement(nextSection))
{
m_context.GenerateConnector(ScType::EdgeAccessConstPosTemp, SectionsKeynodes::rrel_last, previousSectionEdge);
m_context.GenerateConnector(ScType::ConstTempPosArc, SectionsKeynodes::rrel_last, previousSectionEdge);
}

// If current element is the first
if (!m_context.IsElement(previousSection) && m_context.IsElement(nextSection))
{
m_context.GenerateConnector(ScType::EdgeAccessConstPosPerm, ScKeynodes::rrel_1, nextSectionEdge);
m_context.GenerateConnector(ScType::ConstPermPosArc, ScKeynodes::rrel_1, nextSectionEdge);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,43 @@ void sections_builder::buildDecompositionTupleTemplate(
{
scTemplate.Quintuple(
parentSection,
ScType::EdgeDCommonVar,
ScType::NodeVar >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm,
ScType::VarCommonArc,
ScType::VarNode >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::VarPermPosArc,
SectionsKeynodes::nrel_entity_decomposition);
scTemplate.Triple(
sections_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm >> sections_aliases::EDGE_TO_DELETE,
ScType::VarPermPosArc >> sections_aliases::EDGE_TO_DELETE,
childSection);
}

void sections_builder::buildDecompositionTupleTemplate(ScTemplate & scTemplate, ScAddr const & section)
{
scTemplate.Quintuple(
ScType::NodeVar >> sections_aliases::PARENT_SECTION,
ScType::EdgeDCommonVar,
ScType::NodeVar >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm,
ScType::VarNode >> sections_aliases::PARENT_SECTION,
ScType::VarCommonArc,
ScType::VarNode >> sections_aliases::DECOMPOSITION_TUPLE,
ScType::VarPermPosArc,
SectionsKeynodes::nrel_entity_decomposition);
scTemplate.Triple(
sections_aliases::DECOMPOSITION_TUPLE, ScType::EdgeAccessVarPosPerm >> sections_aliases::EDGE_TO_DELETE, section);
sections_aliases::DECOMPOSITION_TUPLE, ScType::VarPermPosArc >> sections_aliases::EDGE_TO_DELETE, section);
}

void sections_builder::buildNextSectionTemplate(
ScTemplate & nextSectionTemplate,
ScAddr const & tuple,
ScAddr const & section)
{
nextSectionTemplate.Triple(tuple, ScType::EdgeAccessVarPosPerm >> sections_aliases::SECTION_EDGE, section);
nextSectionTemplate.Triple(tuple, ScType::VarPermPosArc >> sections_aliases::SECTION_EDGE, section);
nextSectionTemplate.Triple(
tuple,
ScType::EdgeAccessVarPosPerm >> sections_aliases::NEXT_SECTION_ARC,
ScType::NodeVar >> sections_aliases::SECTION_NODE);
ScType::VarPermPosArc >> sections_aliases::NEXT_SECTION_ARC,
ScType::VarNode >> sections_aliases::SECTION_NODE);
nextSectionTemplate.Quintuple(
sections_aliases::SECTION_EDGE,
ScType::EdgeDCommonVar >> sections_aliases::BASE_SEQUENCE_EDGE,
ScType::VarCommonArc >> sections_aliases::BASE_SEQUENCE_EDGE,
sections_aliases::NEXT_SECTION_ARC,
ScType::EdgeAccessVarPosPerm,
ScType::VarPermPosArc,
ScKeynodes::nrel_basic_sequence);
}

Expand All @@ -63,16 +63,16 @@ void sections_builder::buildPreviousSectionTemplate(
ScAddr const & tuple,
ScAddr const & section)
{
previousSectionTemplate.Triple(tuple, ScType::EdgeAccessVarPosPerm >> sections_aliases::SECTION_EDGE, section);
previousSectionTemplate.Triple(tuple, ScType::VarPermPosArc >> sections_aliases::SECTION_EDGE, section);
previousSectionTemplate.Triple(
tuple,
ScType::EdgeAccessVarPosPerm >> sections_aliases::PREVIOUS_SECTION_ARC,
ScType::NodeVar >> sections_aliases::SECTION_NODE);
ScType::VarPermPosArc >> sections_aliases::PREVIOUS_SECTION_ARC,
ScType::VarNode >> sections_aliases::SECTION_NODE);
previousSectionTemplate.Quintuple(
sections_aliases::PREVIOUS_SECTION_ARC,
ScType::EdgeDCommonVar >> sections_aliases::BASE_SEQUENCE_EDGE,
ScType::VarCommonArc >> sections_aliases::BASE_SEQUENCE_EDGE,
sections_aliases::SECTION_EDGE,
ScType::EdgeAccessVarPosPerm,
ScType::VarPermPosArc,
ScKeynodes::nrel_basic_sequence);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ ScAddr sections_generator::GenerateSection(
ScAddr const & lang,
bool isAtomic)
{
ScAddr section = context->GenerateNode(ScType::NodeConstClass);
ScAddr section = context->GenerateNode(ScType::ConstNodeClass);
utils::CommonUtils::setMainIdtf(context, section, sectionName, {lang});

ScTemplate sectionTemplate;
sectionTemplate.Triple(SectionsKeynodes::section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SectionsKeynodes::section, ScType::VarPermPosArc, section);
if (isAtomic)
sectionTemplate.Triple(SectionsKeynodes::atomic_section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SectionsKeynodes::atomic_section, ScType::VarPermPosArc, section);
else
sectionTemplate.Triple(SectionsKeynodes::non_atomic_section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SectionsKeynodes::not_enough_formed_structure, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SectionsKeynodes::non_atomic_section, ScType::VarPermPosArc, section);
sectionTemplate.Triple(SectionsKeynodes::not_enough_formed_structure, ScType::VarPermPosArc, section);
ScTemplateGenResult genResult;
context->GenerateByTemplate(sectionTemplate, genResult);

Expand Down
Loading

0 comments on commit 407a73a

Please sign in to comment.