Пример #1
0
/* loadQ:
        load qrels from a named file; sort by topic then docno
*/
static struct qrel *
loadQ (char *qrels, int *size)
{
  FILE *fp;
  char *line;
  struct qrel *q;
  int i,n = 0;

  if ((fp = fopen (qrels, "r")) == NULL)
    error ("cannot open qrels file \"%s\"\n", qrels);

  while (getLine (fp))
    n++;

  fclose (fp);

  if (n == 0)
    error ("qrel file \"%s\" is empty\n", qrels);

  q = localMalloc (n*sizeof (struct qrel));

  if ((fp = fopen (qrels, "r")) == NULL)
    error ("cannot open qrels file \"%s\"\n", qrels);

  while ((line = getLine (fp)))
    {
      char *a[4];
      int i, topic, rel;

      if (
        split (line, a, 4) != 4
        || (topic = naturalNumber (a[0])) < 0
        || (rel = naturalNumber (a[3])) < 0
      )
        error ("syntax error in qrel file \"%s\" at line %d\n", qrels, i + 1);
      else
        {
          q[i].docno = localStrdup (a[2]);
          q[i].topic = topic;
          if (rel > G)
            rel = G;
          q[i].rel = rel;
          i++;
        }
    }


  /* for each topic, verify that docnos have not been duplicated */
  sortQ (q, n);
  for (i = 1; i < n; i++)
    if (q[i].topic == q[i-1].topic && strcmp(q[i].docno,q[i-1].docno) == 0)
      error (
        "duplicate docno (%s) for topic %d in qrels file \"%s\"\n",
        q[i].docno, q[i].topic, qrels
      );

  *size = n;
  return q;
}
Пример #2
0
static void
setProgramName (char *argv0)
{
  char *pn;

  if (programName)
    localFree (programName);

  if (argv0 == (char *) 0)
    {
      programName = (char *) 0;
      return;
    }

  for (pn = argv0 + strlen (argv0); pn > argv0; --pn)
    if (*pn == '/')
      {
        pn++;
        break;
      }

  programName = localStrdup (pn);
}
Пример #3
0
/* loadRun:
        load a run from a named file; perform initial cleaning and sorting
*/
static struct result *
loadRun (char *run, int *size)
{
  FILE *fp;
  char *line, *runid;
  int i = 0, n = 0, needRunID = 1;
  struct result *r;

  if ((fp = fopen (run, "r")) == NULL)
    error ("cannot open run file \"%s\"\n", run);

  while (getLine (fp))
    n++;

  fclose (fp);

  if (n == 0)
    error ("run file \"%s\" is empty\n", run);

  r = localMalloc (n*sizeof (struct result));

  if ((fp = fopen (run, "r")) == NULL)
    error ("cannot open run file \"%s\"\n", run);

  while ((line = getLine (fp)))
    {
      char *a[6];
      int topic, rank;

      if (
        split (line, a, 6) != 6
        || (topic = naturalNumber (a[0])) < 0
        || (rank = naturalNumber (a[3])) < 0
      )
        error ("syntax error in run file \"%s\" at line %d\n", run, i + 1);
      else
        {
         if (needRunID)
            {
              runid = localStrdup (a[5]);
              needRunID = 0;
            }
          r[i].docno = localStrdup (a[2]);
          r[i].runid = runid;
          r[i].topic = topic;
          r[i].rank = rank;
          r[i].rankx = -1;
          r[i].rel = -1;
          sscanf (a[4],"%lf", &(r[i].score));
          i++;
        }
    }

  /* force ranks to be consistent with traditional TREC sort order */
  forceTraditionalRanks (r, n);

  /*
    apply depth cutoff
    (Why am I doing this work, if I now have a per-measure depth?)
  */
  n = applyCutoff (r, n, DEPTH);


  /* for each topic, verify that docnos have not been duplicated */
  resultSortByDocno (r, n);
  for (i = 1; i < n; i++)
    if (r[i].topic == r[i-1].topic && strcmp(r[i].docno,r[i-1].docno) == 0)
      error (
        "duplicate docno (%s) for topic %d in run file \"%s\"\n",
        r[i].docno, r[i].topic, run
      );

  *size = n;
  return r;
}
Пример #4
0
  StartupShutdownHandler() {

    char ** pcPortNames;
    LADSPA_PortDescriptor * piPortDescriptors;
    LADSPA_PortRangeHint * psPortRangeHints;
    
    initialise_sine_table();
    
    for (long lPluginIndex = 0; lPluginIndex < 4; lPluginIndex++) {
      
      g_psDescriptors[lPluginIndex] = new LADSPA_Descriptor;
      if (g_psDescriptors[lPluginIndex] == NULL)
	break;
      
      g_psDescriptors[lPluginIndex]->UniqueID
	= 1044 + lPluginIndex; /* 1044-1047. */
      g_psDescriptors[lPluginIndex]->Properties
	= LADSPA_PROPERTY_HARD_RT_CAPABLE;
      g_psDescriptors[lPluginIndex]->Maker
	= localStrdup("Richard Furse (LADSPA example plugins)");
      g_psDescriptors[lPluginIndex]->Copyright
	= localStrdup("None");
      g_psDescriptors[lPluginIndex]->PortCount 
	= 3;
      piPortDescriptors
	= new LADSPA_PortDescriptor[3];
      g_psDescriptors[lPluginIndex]->PortDescriptors 
	= (const LADSPA_PortDescriptor *)piPortDescriptors;
      piPortDescriptors[OSC_OUTPUT]
	= LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
      pcPortNames
	= new char_ptr[3];
      g_psDescriptors[lPluginIndex]->PortNames
	= (const char **)pcPortNames;
      pcPortNames[OSC_FREQUENCY]
	= localStrdup("Frequency (Hz)");
      pcPortNames[OSC_AMPLITUDE] 
	= localStrdup("Amplitude");
      pcPortNames[OSC_OUTPUT]
	= localStrdup("Output");
      psPortRangeHints 
	= new LADSPA_PortRangeHint[3];
      g_psDescriptors[lPluginIndex]->PortRangeHints
	= (const LADSPA_PortRangeHint *)psPortRangeHints;
      psPortRangeHints[OSC_FREQUENCY].HintDescriptor
	= (LADSPA_HINT_BOUNDED_BELOW
	   | LADSPA_HINT_BOUNDED_ABOVE
	   | LADSPA_HINT_SAMPLE_RATE
	   | LADSPA_HINT_LOGARITHMIC
	   | LADSPA_HINT_DEFAULT_440);
      psPortRangeHints[OSC_FREQUENCY].LowerBound 
	= 0;
      psPortRangeHints[OSC_FREQUENCY].UpperBound
	= 0.5;
      psPortRangeHints[OSC_AMPLITUDE].HintDescriptor
	= (LADSPA_HINT_BOUNDED_BELOW 
	   | LADSPA_HINT_LOGARITHMIC
	   | LADSPA_HINT_DEFAULT_1);
      psPortRangeHints[OSC_AMPLITUDE].LowerBound 
	= 0;
      psPortRangeHints[OSC_OUTPUT].HintDescriptor
	= 0;
      g_psDescriptors[lPluginIndex]->instantiate
	= instantiateSineOscillator;
      g_psDescriptors[lPluginIndex]->connect_port 
	= connectPortToSineOscillator;
      g_psDescriptors[lPluginIndex]->activate
	= activateSineOscillator;
      g_psDescriptors[lPluginIndex]->run_adding
	= NULL;
      g_psDescriptors[lPluginIndex]->set_run_adding_gain
	= NULL;
      g_psDescriptors[lPluginIndex]->deactivate
	= NULL;
      g_psDescriptors[lPluginIndex]->cleanup
	= cleanupSineOscillator;
      
      switch (lPluginIndex) {
      case 0:
	g_psDescriptors[lPluginIndex]->Label
	  = localStrdup("sine_faaa");
	g_psDescriptors[lPluginIndex]->Name 
	  = localStrdup("Sine Oscillator (Freq:audio, Amp:audio)");
	piPortDescriptors[OSC_FREQUENCY]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
	piPortDescriptors[OSC_AMPLITUDE]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
	g_psDescriptors[lPluginIndex]->run 
	  = runSineOscillator_FreqAudio_AmpAudio;
	break;
      case 1:
	g_psDescriptors[lPluginIndex]->Label
	  = localStrdup("sine_faac");
	g_psDescriptors[lPluginIndex]->Name 
	  = localStrdup("Sine Oscillator (Freq:audio, Amp:control)");
	piPortDescriptors[OSC_FREQUENCY]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
	piPortDescriptors[OSC_AMPLITUDE]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
	g_psDescriptors[lPluginIndex]->run 
	  = runSineOscillator_FreqAudio_AmpCtrl;
	break;
      case 2:
	g_psDescriptors[lPluginIndex]->Label
	  = localStrdup("sine_fcaa");
	g_psDescriptors[lPluginIndex]->Name 
	  = localStrdup("Sine Oscillator (Freq:control, Amp:audio)");
	piPortDescriptors[OSC_FREQUENCY]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
	piPortDescriptors[OSC_AMPLITUDE]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
	g_psDescriptors[lPluginIndex]->run 
	  = runSineOscillator_FreqCtrl_AmpAudio;
	break;
      case 3:
	g_psDescriptors[lPluginIndex]->Label
	  = localStrdup("sine_fcac");
	g_psDescriptors[lPluginIndex]->Name 
	  = localStrdup("Sine Oscillator (Freq:control, Amp:control)");
	piPortDescriptors[OSC_FREQUENCY]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
	piPortDescriptors[OSC_AMPLITUDE]
	  = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
	g_psDescriptors[lPluginIndex]->run 
	  = runSineOscillator_FreqCtrl_AmpCtrl;
	break;
      }
    }
  }