Example #1
0
char * EXPORT_CALL
lou_findTable(const char * query)
{
  if (!tableIndex)
    {
      char * searchPath;
      List * tables;
      const char ** tablesArray;
      logMessage(LOG_WARN, "Tables have not been indexed yet. Indexing LOUIS_TABLEPATH.");
      searchPath = getTablePath();
      tables = listFiles(searchPath);
      tablesArray = list_toArray(tables, NULL);
      lou_indexTables(tablesArray);
      free(searchPath);
      list_free(tables);
      free(tablesArray);
    }
  List * queryFeatures = parseQuery(query);
  int bestQuotient = 0;
  char * bestMatch = NULL;
  List * l;
  for (l = tableIndex; l; l = l->tail)
    {
      TableMeta * table = l->head;
      int q = matchFeatureLists(queryFeatures, table->features, 0);
      if (q > bestQuotient)
	{
	  bestQuotient = q;
	  bestMatch = strdup(table->name);
	}
    }
  if (bestMatch)
     {
       logMessage(LOG_INFO, "Best match: %s (%d)", bestMatch, bestQuotient);
       return bestMatch;
     }
  else
    {
      logMessage(LOG_INFO, "No table could be found for query '%s'", query);
      return NULL;
    }
}
Example #2
0
int snns_process(stEval *args, stEval *result, void *instance) {
  stEvalListHead *head = STLIST(&args[0]);
  float *params = (float*)STLIST(&args[1]);
  int numParams = STINT(&args[2]);
  FlintTypeParam *array_ptr;
  double *returnarray_ptr;
  double *iterator;
  int quant;
  int i;
  int n;
  int *n_ptr;
  krui_err errCode;
  char *errMsg;
  stEvalListHead *result_head = STLIST(result); 
  array_ptr = list_toArray(head);
  iterator = array_ptr;
  quant = krui_getNoOfUnits();
  
  i = 1;
  n = 0;
  
  for(i=1;i <= quant; i++){
	if(krui_getUnitTType(i)==INPUT){
		krui_setUnitActivation(i, *iterator);
		iterator++;
		n++;
	}
  }
  
  krui_updateNet(params, numParams);
  
 free(array_ptr);   //at the moment no space is allocated in list_toArray so commenting out this will result in a delay of the seg fault.
  
  i=0;
  n=0;
  
 
  for(i=1;i <= quant; i++){
	if(krui_getUnitTType(i)==OUTPUT){
		n++;
	}
  }

  returnarray_ptr = slMalloc(sizeof(double)*n);
  iterator = returnarray_ptr;
  i=1;
  
  
  for(i=1;i <= quant; i++){
	  if(krui_getUnitTType(i)==OUTPUT){
		  *iterator = krui_getUnitOutput(i);
		  //		  printf("Got output of %d\n", (*iterator));
		  *(iterator++);
	  }
  }
  
  
  result->values.listValue = array_toList(returnarray_ptr, n);
  result->type = AT_LIST;
  
  free(returnarray_ptr); 

  return EC_OK;

}