00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020 #ifndef _OMCSNET
00021
00022 #define _OMCSNET
00023
00024 #include <string>
00025
00026 #include "textid_map.h"
00027 #include "id_generator.h"
00028 #include "concept_map.h"
00029 #include "link_map.h"
00030 #include "link_list.h"
00031
00032 class CFindAnalogousConfig;
00033 class CAnalogousWeightNode;
00034 class CFindContextConfig;
00035 class CFindPathConfig;
00036
00037
00039 class COMCSNet
00040 {
00041 public:
00043 bool Load(const std::string &a_path)
00044 {
00045 FILE *l_fp;
00046
00047 l_fp = fopen(a_path.c_str(), "rb");
00048
00049 if (l_fp)
00050 {
00051 if (false ==
00052 m_conceptMap.Load(l_fp, m_textIDMap))
00053 {
00054 return false;
00055 }
00056
00057 if (false == m_linkMap.Load(l_fp, m_conceptMap))
00058 {
00059 return false;
00060 }
00061
00062
00063
00064 fclose(l_fp);
00065
00066 return true;
00067 }
00068
00069 return false;
00070 }
00071
00073 bool Save(const std::string &a_path)
00074 {
00075 FILE *l_fp;
00076
00077 l_fp = fopen(a_path.c_str(), "wb");
00078
00079 if (l_fp)
00080 {
00081 if (false == m_conceptMap.Save(l_fp))
00082 {
00083 return false;
00084 }
00085
00086 if (false == m_linkMap.Save(l_fp))
00087 {
00088 return false;
00089 }
00090
00091 fclose(l_fp);
00092
00093 return true;
00094 }
00095
00096 return false;
00097 }
00098
00100 bool LoadPredicateFile(const std::string &a_path);
00101
00103 std::string LookupString(const SemanticID a_id);
00104
00106 bool FindAnalogous(CFindAnalogousConfig &a_config);
00107
00109 bool FindContext(const std::string &a_conceptList,
00110 CFindContextConfig &a_config);
00111
00113 bool FindPathFromA_To_B(const std::string &a_src,
00114 const std::string &a_dst,
00115 CFindPathConfig &a_config);
00116
00118 CSemanticConcept *LookupConcept(const std::string &a_name)
00119 {
00120 SemanticID l_id;
00121
00122 l_id = m_textIDMap.Lookup(a_name);
00123
00124 if (SEMANTIC_ID_NONE != l_id)
00125 {
00126 return m_conceptMap.Lookup(l_id);
00127 }
00128
00129 return NULL;
00130 }
00131
00133 CSemanticConcept *LookupConcept(const SemanticID a_id)
00134 {
00135 return m_conceptMap.Lookup(a_id);
00136 }
00137
00139 COMCSNet() {}
00140
00142 ~COMCSNet() {}
00143
00144 private:
00146 bool p_AnalogousProcessLinkMap(CLinkMap *a_linkMap,
00147 CFindAnalogousConfig &a_config);
00148
00150 bool p_AnalogousProcessBackwardLinkMap(CLinkMap *a_linkMap,
00151 CFindAnalogousConfig &a_config,
00152 const RelationType a_relation);
00153
00155 void p_AnalogousProcessLink(CSemanticLink *a_link,
00156 CFindAnalogousConfig &a_config);
00157
00159 void p_AnalogousProcessBackwardLink(CSemanticLink *a_link,
00160 CFindAnalogousConfig &a_config,
00161 const RelationType a_relation);
00162
00164 void p_AnalogousProcessWeightedNode(
00165 CAnalogousWeightNode *a_node);
00166
00168 bool p_FindContextProcessLinkMap(
00169 CLinkMap *a_linkMap,
00170 CFindContextConfig &a_config,
00171 const float a_oldScore);
00172
00174 CTextIDMap m_textIDMap;
00175
00177 CSemanticIDGenerator m_idFactory;
00178
00180 CConceptMap m_conceptMap;
00181
00183 CLinkMap m_linkMap;
00184 };
00185
00186
00187 #endif
00188