示例#1
0
文件: med.c 项目: tonellotto/MED
static void
med (char *run1, char *run2, char *qrels)
{
  int i, j, n = 0;
  int topic1, topic2, size1, size2;
  struct result *r1, *r2;
  char *runid1, *runid2;
  double err_max = 0.0, err_tot = 0.0;
  double rbp_max = 0.0, rbp_tot = 0.0;
  double ndcg_max = 0.0, ndcg_tot = 0.0;

  printf ("run1,run2,topic,MED-nDCG@%d,MED-RBP,MED-ERR\n", NDCG_DEPTH);

  r1 = loadRun (run1, &size1);
  runid1 = r1[0].runid;
  r2 = loadRun (run2, &size2);
  runid2 = r2[0].runid;

  if (size1 <= 0 || size2 <= 0)
    {
      printf ("%s,%s,0.0,0.0,0.0\n", runid1, runid2);
      return;
    }

  if (qrels)
    {
      struct qrel *q;
      int sizeQ;

      q = loadQ (qrels, &sizeQ);
      labelQ (r1, size1, q, sizeQ);
      labelQ (r2, size2, q, sizeQ);
    }

  crossLabelRuns (r1, size1, r2, size2);

  /* sort results into rank order. */
  resultSortByRank (r1, size1);
  resultSortByRank (r2, size2);

  while (size1 > 0 && size2 > 0)
    {
      i = nextTopicSize (r1, size1, &topic1);
      j = nextTopicSize (r2, size2, &topic2);
      if (topic1 < topic2)
        {
          r1 += i;
          size1 -= i;
        }
      else if (topic1 > topic2)
        {
          r2 += j;
          size2 -= j;
        }
      else
        {
          ndcg_max = ndcgMaximize (r1, i, r2, j);
          ndcg_tot += ndcg_max;
          rbp_max = rbpMaximize (r1, i, r2, j);
          rbp_tot += rbp_max;
          err_max = errMaximize (r1, i, r2, j);
          err_tot += err_max;
          printf (
            "%s,%s,%d,%.5f,%.5f,%.5f\n",
            runid1, runid2, topic1, ndcg_max, rbp_max, err_max
          );
          n++;
          r1 += i;
          size1 -= i;
          r2 += j;
          size2 -= j;
        }
    }

    if (n > 0)
      printf (
        "%s,%s,amean,%.5f,%.5f,%.5f\n",
        runid1, runid2, ndcg_tot/n, rbp_tot/n, err_tot/n
      );
    else
      printf ("%s,%s,amean,0.00000,0.00000,0.00000\n", runid1, runid2);
}
示例#2
0
文件: main.c 项目: moomot/makefile
int main(int argc, char *argv[]) {
  if (argc > 1) {
    loadRun(argv[1]);
  }
  return 0;
}