예제 #1
0
void ParserCKYBest::process_internal_rules(Chart& chart) const
{
  unsigned sent_size=chart.get_size();
  for (unsigned span = 2; span <= sent_size; ++span) {
    unsigned end_of_begin=sent_size-span;
    for (unsigned begin=0; begin <= end_of_begin; ++begin) {
    	unsigned end = begin + span -1;

      //      std::cout << "begin: " << begin << ", end: " << end << std::endl;

    	Cell& result_cell = chart.access(begin,end);

    	if(!result_cell.is_closed()) {
    		// look for all possible new edges
    		for (unsigned m = begin; m < end; ++m) {
    			const Cell& left_cell = chart.access(begin,m);
    			if(!left_cell.is_closed()) {
    				const Cell& right_cell = chart.access(m+1,end);
    				if( !right_cell.is_closed())
    					get_candidates(left_cell,right_cell,result_cell);
    			}
    		}
    		// std::cout << result_cell << std::endl;

    		add_unary(result_cell, span == sent_size);

	//	result_cell.apply_beam();
      }
      // std::cout << result_cell << std::endl;
    }
  }
}
예제 #2
0
void
PrimeSession::segment_reconvert (PrimeCandidates &candidates)
{
    bool success = send_command (PRIME_SEGMENT_RECONVERT);

    if (success) {
        get_candidates (candidates);
    } else {
        // error
    }
}
예제 #3
0
void
PrimeSession::conv_convert (PrimeCandidates &candidates, String method)
{
    bool success = send_command (PRIME_CONV_CONVERT);

    if (success) {
        get_candidates (candidates);
    } else {
        // error
    }
}
예제 #4
0
void
PrimeSession::modify_get_candidates (PrimeCandidates &candidates,
                                     int &index)
{
    bool success = send_command (PRIME_MODIFY_GET_CANDIDATES);

    if (success) {
        get_candidates (candidates);
    } else {
        // error
    }
}
예제 #5
0
int
main (int argc, char **argv)
{
  GHashTable *candidates;
  gchar *dir;
  gchar *base;
  gchar *highest = NULL;
  gchar *binary;                /* actual binary we're going to run */
  gchar *path = NULL;           /* and its path */
  gchar *desc;
  GOptionContext *ctx;
  GError *err = NULL;

  /* detect stuff */
  dir = get_dir_of_binary (argv[0]);
  base = g_path_get_basename (argv[0]);

  /* parse command line options */
  desc = g_strdup_printf ("wrapper to call versioned %s", base);
  ctx = g_option_context_new (desc);
  g_free (desc);
  g_option_context_set_ignore_unknown_options (ctx, TRUE);
  g_option_context_add_main_entries (ctx, wrapper_options, GETTEXT_PACKAGE);
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    exit (1);
  }
  g_option_context_free (ctx);

  /* unmangle libtool if necessary */
  unmangle_libtool (&dir, &base);

#ifdef G_OS_WIN32
  /* remove .exe suffix, otherwise we'll be looking for gst-blah.exe-*.* */
  if (strlen (base) > 4 && g_str_has_suffix (base, ".exe")) {
    base[strlen (base) - 4] = '\0';
  }
#endif

  /* get all candidate binaries */
  candidates = get_candidates (dir, base);
  g_free (dir);

  /* only look for 0.10, we don't want 0.11 tools to be picked up accidentally
   * (and from 0.11 on the unversioned tools are discontinued anyway) */
  if (_arg_mm == NULL)
    _arg_mm = GST_MAJORMINOR;

  if (_arg_mm) {
    /* if a version was forced, look it up in the hash table */
    dir = g_hash_table_lookup (candidates, _arg_mm);
    if (!dir) {
      g_print ("ERROR: Major/minor %s of tool %s not found.\n", _arg_mm, base);
      return 1;
    }
    binary = g_strdup_printf ("%s-%s", base, _arg_mm);
  } else {
    highest = NULL;

    /* otherwise, just look up the highest version */
    if (candidates) {
      g_hash_table_foreach (candidates, (GHFunc) find_highest_version,
          &highest);
    }

    if (highest == NULL) {
      g_print ("ERROR: No version of tool %s found.\n", base);
      return 1;
    }
    dir = g_hash_table_lookup (candidates, highest);
    binary = g_strdup_printf ("%s-%s", base, highest);
  }

  g_free (base);

  path = g_build_filename (dir, binary, NULL);
  g_free (binary);

  /* print out list of major/minors we found if asked for */
  /* FIXME: do them in order by creating a GList of keys and sort them */
  if (_arg_list_mm) {
    g_hash_table_foreach (candidates, (GHFunc) hash_print_key, NULL);
    g_hash_table_destroy (candidates);
    return 0;
  }

  /* print out command line if asked for */
  argv[0] = path;
  if (_print) {
    int i;

    for (i = 0; i < argc; ++i) {
      g_print ("%s", argv[i]);
      if (i < argc - 1)
        g_print (" ");
    }
    g_print ("\n");
  }

  /* execute */
  if (execv (path, argv) == -1) {
    g_warning ("Error executing %s: %s (%d)", path, g_strerror (errno), errno);
  }
  g_free (path);

  return 0;
}