Exemplo n.º 1
0
int32 CLogicThread::GetActionRoom(int64 ParentID,ClauseLogicSense* cls){
	   CppSQLite3Buffer SQL;
       char a[30],b[30];
	   
	   uint32 PartOfSpeech = 0;
//	   if(!RBrainHasTable(ID))return 0;

	   map<int64,MeaningPos>& RoomList = cls->ClauseMeaning;

	   ToRBrain(ParentID);

	   int64toa(ParentID,a);
	   int64toa(MEMORY_INSTINCT,b);
	   SQL.format("select %s,%s from \"%s\" where %s = \"%s\" ;",
						RB_SPACE_ID,
						RB_SPACE_VALUE,
			            a,
						RB_SPACE_TYPE,
						b
						);
	   CppSQLite3Table t = BrainDB.getTable(SQL);

	   for (int row = 0; row < t.numRows(); row++)
	   {
			t.setRow(row);
			int64 ID = t.getInt64Field(0);
			int64 Value = t.getInt64Field(1);
			MeaningPos Pos;
			Pos.RoomID = ID;
			Pos.ParamTokenPos = cls->NextTokenPos;
            RoomList[Value] = Pos;
	   }
	   return RoomList.size();	
}
Exemplo n.º 2
0
int32 CBrainMemory::GetAllPartOfSpeechRoom(int64 ParentID,map<int64,int64>& RoomList)
{
	   CppSQLite3Buffer SQL;
       char a[30],b[30],c[30];
	   
	   uint32 PartOfSpeech = 0;
//	   if(!RBrainHasTable(ID))return 0;

	   ToRBrain(ParentID);

	   int64toa(ParentID,a);
	   int64toa(PARTOFSPEECH_START,b); 
	   int64toa(PARTOFSPEECH_END,c);

	   SQL.format("select %s,%s from \"%s\" where %s > \"%s\" AND %s< \"%s\";",
						RB_SPACE_ID,
						RB_SPACE_TYPE,
			            a,
						RB_SPACE_TYPE,
						b,
                        RB_SPACE_TYPE,
						c
						);
	   CppSQLite3Table t = BrainDB.getTable(SQL);

	   for (int row = 0; row < t.numRows(); row++)
	   {
			t.setRow(row);
			int64 ID = t.getInt64Field(0);
			int64 Type = t.getInt64Field(1);
            RoomList[ID] = Type;
	   }
	   return RoomList.size();
}
Exemplo n.º 3
0
uint32 CBrainMemory::GetAllPartOfSpeech(int64 ParentID){
	   CppSQLite3Buffer SQL;
       char a[30],b[30],c[30];
	   
	   uint32 PartOfSpeech = 0;
//	   if(!RBrainHasTable(ID))return 0;

	   ToRBrain(ParentID);
	   int64toa(ParentID,a);
	   int64toa(PARTOFSPEECH_START,b);
	   int64toa(PARTOFSPEECH_END,c);

	   SQL.format("select %s from \"%s\" where %s > \"%s\" AND %s< \"%s\";",
						RB_SPACE_TYPE,
			            a,
						RB_SPACE_TYPE,
						b, 
                        RB_SPACE_TYPE,
						c
						);
	   CppSQLite3Table t = BrainDB.getTable(SQL);

	   for (int row = 0; row < t.numRows(); row++)
	   {
			t.setRow(row);
			int64 type = t.getInt64Field(0);
            PartOfSpeech |= (uint32)((type-PARTOFSPEECH_START));  
	   }
	   return PartOfSpeech;
}
Exemplo n.º 4
0
int64 CBrainMemory::HasMeaningRoom(int64 ParentTable,int64 Meaning,int64 MeaningType){
	CppSQLite3Buffer SQL;
	char a[30],b[30];
	   
	if(!RBrainHasTable(ParentTable))return 0;
	ToRBrain(ParentTable);

	int64toa(ParentTable,a);
	int64toa(MeaningType,b);
	SQL.format("select %s, %s  from \"%s\" where %s = \"%s\";",
		   RB_SPACE_ID,
		   RB_SPACE_VALUE,
		   a,
		   RB_SPACE_TYPE,
		   b
		   );
	CppSQLite3Table t = BrainDB.getTable(SQL);

	if(Meaning == 0){
		for (int row = 0; row < t.numRows(); row++)
		{
			t.setRow(row);
			int64 ID   = t.getInt64Field(0);
			int64 Value = t.getInt64Field(1);
            if(ID == Value){
				return ID; //已经记忆过了,直接返回
			}
		}
	}else{
		for (int row = 0; row < t.numRows(); row++)
		{
			t.setRow(row);
			int64 ID   = t.getInt64Field(0);
			int64 Value = t.getInt64Field(1);
            if(Value = Meaning){
				return ID; //已经记忆过了,直接返回
			}
		}	
	}
	return 0;
}