Ejemplo n.º 1
0
void BBN_Prob::set_bn_probability(dlib::directed_graph<dlib::bayes_node>::kernel_1a_c* bn, dlib::assignment parent_state)
{
  BBN_Option* option = get_decision()->get_plot()->get_option(_option);

  if(option == 0x0)
  {
    throw(BBN_Exception("Could not find option '" + _option + "' for prob object in decision '" + get_decision()->get_name() + "'."));
  }
  else
  {
    dlib::bayes_node_utils::set_node_probability(*(get_decision()->get_plot()->get_bn()), option->get_decision()->get_id(),
        option->get_id(), parent_state, _probability);
  }
}
Ejemplo n.º 2
0
void process_data_head(struct data_head * dh, int method,int index)
{
    if (check_gk(dh))
        return;

    char * buffer = NULL;
    char ** request = NULL;
    int request_number=0;
    int isgk = 0;
    int i;

    //Wang Xuyang
    struct location_tuple *lt;
    lt = (struct location_tuple *) malloc(sizeof(struct location_tuple));
    if((buffer = get_buffer(dh, lt))!=NULL)
    	request = get_request(buffer, &request_number);

    //const char * pattern_nan = "album123456789";
    //const char * pattern_nan = "北京";
    const char * pattern_nan = "111e7f.jpg";

    //printf("===================loop=============\n");
    //printf("buffer=%s\n\n\npattern_nan=%s\n",buffer,pattern_nan); 
    //printf("===================loop=============\n");
    if (buffer != NULL && strstr(buffer, pattern_nan))
    {
        printf("\n\nget_buffer\n");
        printf("a_tcp:%d\n", dh->a_tcp);
        printf("buffer length=%d, get_buffer done\n",strlen(buffer));
        printf("buffer=\n%s\n",buffer);
        //wunn add
        for (i = 0; i < request_number; i++)
            printf("Req:%s\n", request[i]);
    }
   
    //Over

    for (i = 0; i < request_number; i++)
    {
        struct connection_info * c_info = NULL;
        //Zhong Yuan
        //printf("==================request %d =%s\n==================\n",i,request[i]);
        c_info = processhttp(request[i],strlen(request[i]));
        //if(c_info != NULL && c_info->p_type==PHOTO)printf("PHOTO URL=%s\n",c_info->url);
	//printf("url:%s\n", c_info->url);
        int status = get_decision(c_info, lt);
        //Over
      
	if (request[i] != NULL && strstr(request[i], pattern_nan))
        {
            //printf("\n\nRequest: %s\n", request[i]);
            if (c_info != NULL)
	    {
	    // sunpy
	    // for third party test
	        if (strlen(c_info->comment) >= 0) {
                printf("Thread Id =%d\n",index);
                printf("gk_status:%d\n", status);
                printf("c_info.userid:%s\n", c_info->user_id);
	        printf("c_info.s_id:%s\n", c_info->s_id);
	        printf("c_info.ptype:%d\n", c_info->p_type);
	        printf("c_info.r_id:%s\n", c_info->r_id);
	        printf("c_info.comment:%s\n", c_info->comment);
	        printf("c_info.url:%s\n", c_info->url);
	        printf("==================================\n\n");
		}
            }
	}

        if (status == 0 || status == -1)
        {
            if (c_info != NULL)
                free(c_info);
            continue;
        }

        //sent log

        set_gk(dh, method);
        isgk = 1;
        printf("Thread Id =%d\n",index);
        printf("\n\ngk_status:%d\n", status);
	printf("c_info.userid:%s\n", c_info->user_id);
	printf("c_info.s_id:%s\n", c_info->s_id);
	printf("c_info.ptype:%d\n", c_info->p_type);
	printf("c_info.r_id:%s\n", c_info->r_id);
	printf("c_info.comment:%s\n", c_info->comment);
	printf("c_info.url:%s\n", c_info->url);
        if (c_info != NULL)
            free(c_info);
	//printf("\n\n");

        break;
    }

    if (!isgk)
    {
        update_dh(dh, request, request_number);
	//printf("update_dh:%d\n", request_number);
    }
    if (lt != NULL)
        free(lt);
    if (buffer != NULL)
        free(buffer);
    for (i = 0; i < request_number; i++)
        if (NULL != request[i])
            free(request[i]);
    if (NULL != request)
        free(request);
}