• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dict_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dict_init函数的典型用法代码示例。如果您正苦于以下问题:C++ dict_init函数的具体用法?C++ dict_init怎么用?C++ dict_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dict_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: void

/**** Global functions definitions.   ****/
TA_Dict *TA_DictAlloc( TA_Libc *libHandle,
                       unsigned int flags,                       
                       void (*freeValueFunc)( TA_Libc *libHandle, void *) )
{
   TA_PrivDictInfo *theDict;

   if( !libHandle )
      return NULL;

   /* Alloc the structure used as an handle for this dictionary. */
   theDict = (TA_PrivDictInfo *) TA_Malloc( libHandle, sizeof( TA_PrivDictInfo ) );

   if( !theDict )
      return NULL;

   theDict->flags = flags;

   /* Create the Kazlib dictionary. */
   if( flags & TA_DICT_KEY_ONE_STRING )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_S );
   else if( flags & TA_DICT_KEY_TWO_STRING )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_S );
   else if( flags & TA_DICT_KEY_INTEGER )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_I );

   /* Keep a copy of the freeValueFunc pointer for later use. */
   theDict->freeValueFunc = freeValueFunc;

   /* Remember to which memory context we belong. */
   theDict->libHandle = libHandle;

   return (TA_Dict *)theDict;
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:34,代码来源:ta_dict.c


示例2: main

int
main(int argc, char *argv[])
{
	bin_mdef_t *mdef;
	dict_t *dict;
	cmd_ln_t *config;

	int i;
	char buf[100];

	TEST_ASSERT(config = cmd_ln_init(NULL, NULL, FALSE,
						   "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
						   "-fdict", MODELDIR "/en-us/en-us/noisedict",
						   NULL));

	/* Test dictionary in standard fashion. */
	TEST_ASSERT(mdef = bin_mdef_read(NULL, MODELDIR "/en-us/en-us/mdef"));
	TEST_ASSERT(dict = dict_init(config, mdef, NULL));

	printf("Word ID (CARNEGIE) = %d\n",
	       dict_wordid(dict, "CARNEGIE"));
	printf("Word ID (ASDFASFASSD) = %d\n",
	       dict_wordid(dict, "ASDFASFASSD"));

	TEST_EQUAL(0, dict_write(dict, "_cmu07a.dic", NULL));
	TEST_EQUAL(0, system("diff -uw " MODELDIR "/en-us/cmudict-en-us.dict _cmu07a.dic"));

	dict_free(dict);
	bin_mdef_free(mdef);

	/* Now test an empty dictionary. */
	TEST_ASSERT(dict = dict_init(NULL, NULL, NULL));
	printf("Word ID(<s>) = %d\n", dict_wordid(dict, "<s>"));
	TEST_ASSERT(BAD_S3WID != dict_add_word(dict, "FOOBIE", NULL, 0));
	TEST_ASSERT(BAD_S3WID != dict_add_word(dict, "BLETCH", NULL, 0));
	printf("Word ID(FOOBIE) = %d\n", dict_wordid(dict, "FOOBIE"));
	printf("Word ID(BLETCH) = %d\n", dict_wordid(dict, "BLETCH"));
	TEST_ASSERT(dict_real_word(dict, dict_wordid(dict, "FOOBIE")));
	TEST_ASSERT(dict_real_word(dict, dict_wordid(dict, "BLETCH")));
	TEST_ASSERT(!dict_real_word(dict, dict_wordid(dict, "</s>")));
	dict_free(dict);

	/* Test to add 500k words. */
	TEST_ASSERT(dict = dict_init(NULL, NULL, NULL));
	for (i = 0; i < 500000; i++) {
	    sprintf(buf, "word_%d", i);
    	    TEST_ASSERT(BAD_S3WID != dict_add_word(dict, buf, NULL, 0));
	}
	dict_free(dict);

	cmd_ln_free_r(config);

	return 0;
}
开发者ID:EvgenyAnisimoff,项目名称:pocketsphinx,代码行数:54,代码来源:test_dict.c


示例3: node_new

Node* node_new(int type)
{
  Node* node = mem_new(Node);
  node->type = type;
  node->filename = NULL;
  node->line = -1;
  array_init( &(node->children), Node*);
  dict_init( &(node->props_strings), sizeof(char*), sizeof(char*),
             dict_hash_string, dict_equal_string );
  dict_init( &(node->props_nodes), sizeof(char*), sizeof(Node*),
             dict_hash_string, dict_equal_string );
  return node;
}
开发者ID:merolle,项目名称:ripe,代码行数:13,代码来源:astnode.c


示例4: models_init

/*
 * Load and cross-check all models (acoustic/lexical/linguistic).
 */
static void models_init ( void )
{
    dict_t *dict;
    
    /* HMM model definition */
    mdef = mdef_init ((char *) cmd_ln_access("-mdeffn"));

    /* Dictionary */
    dict = dict_init ((char *) cmd_ln_access("-dictfn"),
		      (char *) cmd_ln_access("-fdictfn"));

    /* HACK!! Make sure SILENCE_WORD, START_WORD and FINISH_WORD are in dictionary */
    silwid = dict_wordid (SILENCE_WORD);
    startwid = dict_wordid (START_WORD);
    finishwid = dict_wordid (FINISH_WORD);
    if (NOT_WID(silwid) || NOT_WID(startwid) || NOT_WID(finishwid)) {
	E_FATAL("%s, %s, or %s missing from dictionary\n",
		SILENCE_WORD, START_WORD, FINISH_WORD);
    }
    if ((dict->filler_start > dict->filler_end) || (! dict_filler_word (silwid)))
	E_FATAL("%s must occur (only) in filler dictionary\n", SILENCE_WORD);
    /* No check that alternative pronunciations for filler words are in filler range!! */

    /* LM */
    lm_read ((char *) cmd_ln_access("-lmfn"), "");

    /* Filler penalties */
    fillpen_init ((char *) cmd_ln_access("-fillpenfn"),
		  dict->filler_start, dict->filler_end);
}
开发者ID:phillipstanleymarbell,项目名称:sunflower-simulator,代码行数:33,代码来源:dag-main.c


示例5: index_storage_get_dict

static int
index_storage_get_dict(struct mailbox *box, enum mail_attribute_type type,
		       struct dict **dict_r, const char **mailbox_prefix_r)
{
	struct mail_storage *storage = box->storage;
	struct mail_namespace *ns;
	struct mailbox_metadata metadata;
	struct dict_settings set;
	const char *error;

	if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0)
		return -1;
	*mailbox_prefix_r = guid_128_to_string(metadata.guid);

	ns = mailbox_get_namespace(box);
	if (type == MAIL_ATTRIBUTE_TYPE_PRIVATE) {
		/* private attributes are stored in user's own dict */
		return index_storage_get_user_dict(storage, storage->user, dict_r);
	} else if (ns->user == ns->owner) {
		/* user owns the mailbox. shared attributes are stored in
		   the same dict. */
		return index_storage_get_user_dict(storage, storage->user, dict_r);
	} else if (ns->owner != NULL) {
		/* accessing shared attribute of a shared mailbox.
		   use the owner's dict. */
		return index_storage_get_user_dict(storage, ns->owner, dict_r);
	}

	/* accessing shared attributes of a public mailbox. no user owns it,
	   so use the storage's dict. */
	if (storage->_shared_attr_dict != NULL) {
		*dict_r = storage->_shared_attr_dict;
		return 0;
	}
	if (*storage->set->mail_attribute_dict == '\0') {
		mail_storage_set_error(storage, MAIL_ERROR_NOTPOSSIBLE,
				       "Mailbox attributes not enabled");
		return -1;
	}
	if (storage->shared_attr_dict_failed) {
		mail_storage_set_internal_error(storage);
		return -1;
	}

	memset(&set, 0, sizeof(set));
	set.username = storage->user->username;
	set.base_dir = storage->user->set->base_dir;
	if (mail_user_get_home(storage->user, &set.home_dir) <= 0)
		set.home_dir = NULL;
	if (dict_init(storage->set->mail_attribute_dict, &set,
		      &storage->_shared_attr_dict, &error) < 0) {
		mail_storage_set_critical(storage,
			"mail_attribute_dict: dict_init(%s) failed: %s",
			storage->set->mail_attribute_dict, error);
		storage->shared_attr_dict_failed = TRUE;
		return -1;
	}
	*dict_r = storage->_shared_attr_dict;
	return 0;
}
开发者ID:nikwrt,项目名称:dovecot-core,代码行数:60,代码来源:index-attribute.c


示例6: models_init

static void
models_init(void)
{

    mdef = mdef_init(cmd_ln_str_r(config, "-mdef"), 1);

    dict = dict_init(mdef,
                     cmd_ln_str_r(config, "-dict"),
                     cmd_ln_str_r(config, "-fdict"),
		     cmd_ln_boolean_r(config, "-lts_mismatch"),
		     cmd_ln_boolean_r(config, "-mdef_fillers"),
		     FALSE, TRUE);

    lmset = lmset_init(cmd_ln_str_r(config, "-lm"),
                       cmd_ln_str_r(config, "-lmctlfn"),
                       cmd_ln_str_r(config, "-ctl_lm"),
                       cmd_ln_str_r(config, "-lmname"),
                       cmd_ln_str_r(config, "-lmdumpdir"),
                       cmd_ln_float32_r(config, "-lw"),
                       cmd_ln_float32_r(config, "-wip"),
                       cmd_ln_float32_r(config, "-uw"), dict,
                       logmath);

    /* Filler penalties */
    fpen = fillpen_init(dict, cmd_ln_str_r(config, "-fillpen"),
                        cmd_ln_float32_r(config, "-silprob"),
                        cmd_ln_float32_r(config, "-fillprob"),
                        cmd_ln_float32_r(config, "-lw"),
                        cmd_ln_float32_r(config, "-wip"),
                        logmath);

}
开发者ID:4auka,项目名称:cmusphinx,代码行数:32,代码来源:main_conf.c


示例7: memset

int sieve_dict_storage_get_dict
(struct sieve_dict_storage *dstorage, struct dict **dict_r,
	enum sieve_error *error_r)
{
	struct sieve_storage *storage = &dstorage->storage;
	struct sieve_instance *svinst = storage->svinst;
	struct dict_settings dict_set;
	const char *error;
	int ret;

	if ( dstorage->dict == NULL ) {
		memset(&dict_set, 0, sizeof(dict_set));
		dict_set.username = dstorage->username;
		dict_set.base_dir = svinst->base_dir;
		ret = dict_init(dstorage->uri, &dict_set, &dstorage->dict, &error);
		if ( ret < 0 ) {
			sieve_storage_set_critical(storage,
				"Failed to initialize dict with data `%s' for user `%s': %s",
				dstorage->uri, dstorage->username, error);
			*error_r = SIEVE_ERROR_TEMP_FAILURE;
			return -1;
		}
	}

	*dict_r = dstorage->dict;
	return 0;
}
开发者ID:amrod-,项目名称:pigeonhole,代码行数:27,代码来源:sieve-dict-storage.c


示例8: main

main (int32 argc, char *argv[])
{
    mdef_t *m;
    dict_t *d;
    char wd[1024];
    s3wid_t wid;
    int32 p;
    
    if (argc < 3)
	E_FATAL("Usage: %s {mdeffile | NULL} dict [fillerdict]\n", argv[0]);
    
    m = (strcmp (argv[1], "NULL") != 0) ? mdef_init (argv[1]) : NULL;
    d = dict_init (m, argv[2], ((argc > 3) ? argv[3] : NULL), '_');
    
    for (;;) {
	printf ("word> ");
	scanf ("%s", wd);
	
	wid = dict_wordid (d, wd);
	if (NOT_WID(wid))
	    E_ERROR("Unknown word\n");
	else {
	    for (wid = dict_basewid(d, wid); IS_WID(wid); wid = d->word[wid].alt) {
		printf ("%s\t", dict_wordstr(d, wid));
		for (p = 0; p < d->word[wid].pronlen; p++)
		    printf (" %s", dict_ciphone_str (d, wid, p));
		printf ("\n");
	    }
	}
    }
}
开发者ID:10v,项目名称:cmusphinx,代码行数:31,代码来源:dict.c


示例9: dict_new

Dict* dict_new(uint16 key_size, uint16 value_size, DictHashFunc hash_func,
               DictEqualFunc equal_func)
{
  Dict* d = mem_new(Dict);
  dict_init(d, key_size, value_size, hash_func, equal_func);
  return d;
}
开发者ID:cabrilo,项目名称:ripe,代码行数:7,代码来源:dict.c


示例10: main

int main(int argc, char *argv[])
{
	int	ret = 0;
	DICT_STR *my_dict_str = NULL;

	ret = dict_init(&my_dict_str, argc, argv);
	if (ERRNO_INIT == ret)
	{
		/* 如果没有初始化此结构体,说明用户执行 --help ,
		 * 并没有出错,所有此处不打印出错信息,直接返回。
		 * 而对于程序来说,--help或者错误的参数也是程序
		 * 没有正确执行的一部分,所以main仍返回错误。*/
		if (NULL != my_dict_str)
			printf("[DICT]%s: Initialization Failed.", __func__);

		return ret;
	}
	
	ret = dict_exec(my_dict_str);
	if (ERRNO_EXEC == ret)
		printf("[DICT]%s: Execution Failed.", __func__);

	dict_free(my_dict_str);

	return ret;
}
开发者ID:leesheen,项目名称:dict-c,代码行数:26,代码来源:dict.c


示例11: main

///////////////////////
//test <test.dict>
int main(int argc, char * argv[]) {
	struct mg_server * server;
	//
	if(argc < 2) {
		printf("demo: %s <test.dict>\n", argv[0]);
		exit(0);
	}
	//
	dbox = dict_init();
	dict_load(dbox, argv[1]);
	//
	server = mg_create_server(NULL, ev_handler);
	//
	mg_set_option(server, "listening_port", "8089");
	//
	for(;;) {
		mg_poll_server(server, 1000);
	}
	//
	mg_destroy_server(&server);
	//
	dict_free(dbox);
	//
	return 0;
}
开发者ID:terminator123,项目名称:mg_test,代码行数:27,代码来源:dict.c


示例12: clone_breakpoints

static int
clone_breakpoints(Process * proc, Process * orig_proc)
{
	/* When copying breakpoints, we also have to copy the
	 * referenced symbols, and link them properly.  */
	Dict * map = dict_init(&dict_key2hash_int, &dict_key_cmp_int);
	struct library_symbol * it = proc->list_of_symbols;
	proc->list_of_symbols = NULL;
	for (; it != NULL; it = it->next) {
		struct library_symbol * libsym = clone_library_symbol(it);
		if (libsym == NULL) {
			int save_errno;
		err:
			save_errno = errno;
			destroy_library_symbol_chain(proc->list_of_symbols);
			dict_clear(map);
			errno = save_errno;
			return -1;
		}
		libsym->next = proc->list_of_symbols;
		proc->list_of_symbols = libsym;
		if (dict_enter(map, it, libsym) != 0)
			goto err;
	}

	proc->breakpoints = dict_clone2(orig_proc->breakpoints,
					address_clone, breakpoint_clone, map);
	if (proc->breakpoints == NULL)
		goto err;

	dict_clear(map);
	return 0;
}
开发者ID:KapJlcoH,项目名称:ltrace,代码行数:33,代码来源:handle_event.c


示例13: my_demangle

const char *
my_demangle(const char *function_name) {
	const char *tmp, *fn_copy;
#ifdef USE_CXA_DEMANGLE
	extern char *__cxa_demangle(const char *, char *, size_t *, int *);
#endif

	debug(DEBUG_FUNCTION, "my_demangle(name=%s)", function_name);

	if (!d)
		d = dict_init(dict_key2hash_string, dict_key_cmp_string);

	tmp = dict_find_entry(d, (void *)function_name);
	if (!tmp) {
		fn_copy = strdup(function_name);
#ifdef HAVE_LIBIBERTY
		tmp = cplus_demangle(function_name, DMGL_ANSI | DMGL_PARAMS);
#elif defined USE_CXA_DEMANGLE
		int status = 0;
		tmp = __cxa_demangle(function_name, NULL, NULL, &status);
#endif
		if (!tmp)
			tmp = fn_copy;
		if (tmp)
			dict_enter(d, (void *)fn_copy, (void *)tmp);
	}
	return tmp;
}
开发者ID:5py,项目名称:ltrace,代码行数:28,代码来源:demangle.c


示例14: cmd_dict_init_full

static struct dict *
cmd_dict_init_full(int *argc, char **argv[], int own_arg_count, int key_arg_idx,
		   doveadm_command_t *cmd, enum dict_iterate_flags *iter_flags)
{
	const char *getopt_args = iter_flags == NULL ? "u:" : "1Ru:V";
	struct dict *dict;
	const char *error, *username = "";
	int c;

	while ((c = getopt(*argc, *argv, getopt_args)) > 0) {
		switch (c) {
		case '1':
			i_assert(iter_flags != NULL);
			*iter_flags |= DICT_ITERATE_FLAG_EXACT_KEY;
			break;
		case 'R':
			i_assert(iter_flags != NULL);
			*iter_flags |= DICT_ITERATE_FLAG_RECURSE;
			break;
		case 'V':
			i_assert(iter_flags != NULL);
			*iter_flags |= DICT_ITERATE_FLAG_NO_VALUE;
			break;
		case 'u':
			username = optarg;
			break;
		default:
			dict_cmd_help(cmd);
		}
	}
	*argc -= optind;
	*argv += optind;

	if (*argc != 1 + own_arg_count)
		dict_cmd_help(cmd);

	dict_drivers_register_builtin();
	if (dict_init((*argv)[0], DICT_DATA_TYPE_STRING, username,
		      doveadm_settings->base_dir, &dict, &error) < 0)
		i_fatal("dict_init(%s) failed: %s", (*argv)[0], error);

	*argc += 1;
	*argv += 1;

	if (key_arg_idx >= 0) {
		const char *key = (*argv)[key_arg_idx];

		if (strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE)) != 0 &&
		    strncmp(key, DICT_PATH_SHARED, strlen(DICT_PATH_SHARED)) != 0) {
			i_fatal("Key must begin with '"DICT_PATH_PRIVATE
				"' or '"DICT_PATH_SHARED"': %s", key);
		}
		if (username[0] == '\0' &&
		    strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE)) == 0)
			i_fatal("-u must be specified for "DICT_PATH_PRIVATE" keys");
	}
	return dict;
}
开发者ID:bjacke,项目名称:core,代码行数:58,代码来源:doveadm-dict.c


示例15: dict_new

Dict* dict_new(uint16 key_size, uint16 value_size, DictHashFunc hash_func,
               DictEqualFunc equal_func)
{
  assert(key_size > 0); assert(value_size > 0);
  assert(hash_func != NULL); assert(equal_func != NULL);
  Dict* d = mem_new(Dict);
  dict_init(d, key_size, value_size, hash_func, equal_func);
  return d;
}
开发者ID:merolle,项目名称:ripe,代码行数:9,代码来源:dict.c


示例16: malloc

dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)
{
    dict_t *dict = (dict_t *) malloc(sizeof *dict);

    if (dict)
        dict_init(dict, maxcount, comp);

    return dict;
}
开发者ID:amuraru,项目名称:libm2handler,代码行数:9,代码来源:dict.c


示例17: START_TEST

END_TEST

START_TEST(test_dict_create2)
{
    Dict dict;
    dict_init(&dict);
    for (int i = 0; i < 256; i++)
        ck_assert_int_eq(dict.nodes[i].icount, 0);
    dict_destroy(&dict);
}
开发者ID:ryanfzy,项目名称:c-codes,代码行数:10,代码来源:test_dict.c


示例18: ps_load_dict

int
ps_load_dict(ps_decoder_t *ps, char const *dictfile,
             char const *fdictfile, char const *format)
{
    cmd_ln_t *newconfig;
    dict2pid_t *d2p;
    dict_t *dict;
    hash_iter_t *search_it;

    /* Create a new scratch config to load this dict (so existing one
     * won't be affected if it fails) */
    newconfig = cmd_ln_init(NULL, ps_args(), TRUE, NULL);
    cmd_ln_set_boolean_r(newconfig, "-dictcase",
                         cmd_ln_boolean_r(ps->config, "-dictcase"));
    cmd_ln_set_str_r(newconfig, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(newconfig, "-fdict", fdictfile);
    else
        cmd_ln_set_str_r(newconfig, "-fdict",
                         cmd_ln_str_r(ps->config, "-fdict"));

    /* Try to load it. */
    if ((dict = dict_init(newconfig, ps->acmod->mdef, ps->acmod->lmath)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Reinit the dict2pid. */
    if ((d2p = dict2pid_build(ps->acmod->mdef, dict)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Success!  Update the existing config to reflect new dicts and
     * drop everything into place. */
    cmd_ln_free_r(newconfig);
    cmd_ln_set_str_r(ps->config, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(ps->config, "-fdict", fdictfile);
    dict_free(ps->dict);
    ps->dict = dict;
    dict2pid_free(ps->d2p);
    ps->d2p = d2p;

    /* And tell all searches to reconfigure themselves. */
    for (search_it = hash_table_iter(ps->searches); search_it;
       search_it = hash_table_iter_next(search_it)) {
        if (ps_search_reinit(hash_entry_val(search_it->ent), dict, d2p) < 0) {
            hash_table_iter_free(search_it);
            return -1;
        }
    }

    return 0;
}
开发者ID:jhector,项目名称:sphinxfuzz,代码行数:55,代码来源:pocketsphinx.c


示例19: ps_load_dict

int
ps_load_dict(ps_decoder_t *ps, char const *dictfile,
             char const *fdictfile, char const *format)
{
    cmd_ln_t *newconfig;
    dict2pid_t *d2p;
    dict_t *dict;
    gnode_t *gn;
    int rv;

    /* Create a new scratch config to load this dict (so existing one
     * won't be affected if it fails) */
    newconfig = cmd_ln_init(NULL, ps_args(), TRUE, NULL);
    cmd_ln_set_boolean_r(newconfig, "-dictcase",
                         cmd_ln_boolean_r(ps->config, "-dictcase"));
    cmd_ln_set_str_r(newconfig, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(newconfig, "-fdict", fdictfile);
    else
        cmd_ln_set_str_r(newconfig, "-fdict",
                         cmd_ln_str_r(ps->config, "-fdict"));

    /* Try to load it. */
    if ((dict = dict_init(newconfig, ps->acmod->mdef)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Reinit the dict2pid. */
    if ((d2p = dict2pid_build(ps->acmod->mdef, dict)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Success!  Update the existing config to reflect new dicts and
     * drop everything into place. */
    cmd_ln_free_r(newconfig);
    cmd_ln_set_str_r(ps->config, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(ps->config, "-fdict", fdictfile);
    dict_free(ps->dict);
    ps->dict = dict;
    dict2pid_free(ps->d2p);
    ps->d2p = d2p;

    /* And tell all searches to reconfigure themselves. */
    for (gn = ps->searches; gn; gn = gnode_next(gn)) {
        ps_search_t *search = gnode_ptr(gn);
        if ((rv = ps_search_reinit(search, dict, d2p)) < 0)
            return rv;
    }

    return 0;
}
开发者ID:006,项目名称:ios_lab,代码行数:54,代码来源:pocketsphinx.c


示例20: main

int
main(int argc, char *argv[])
{
    ngram_trie_t *t;
    dict_t *dict;
    bin_mdef_t *mdef;
    logmath_t *lmath;
    cmd_ln_t *config;
    FILE *arpafh;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
                         "-hmm", TESTDATADIR "/hub4wsj_sc_8k",
                         "-dict", TESTDATADIR "/bn10000.homos.dic",
                         NULL);
    ps_init_defaults(config);

    lmath = logmath_init(cmd_ln_float32_r(config, "-logbase"),
                         0, FALSE);
    mdef = bin_mdef_read(config, cmd_ln_str_r(config, "-mdef"));
    dict = dict_init(config, mdef);

    t = ngram_trie_init(dict, lmath);
    arpafh = fopen(TESTDATADIR "/bn10000.3g.arpa", "r");
    ngram_trie_read_arpa(t, arpafh);
    fclose(arpafh);

    /* Test 1, 2, 3-gram probs without backoff. */
    test_lookups(t, lmath);

    arpafh = fopen("tmp.bn10000.3g.arpa", "w");
    ngram_trie_write_arpa(t, arpafh);
    fclose(arpafh);
    ngram_trie_free(t);

    t = ngram_trie_init(dict, lmath);
    arpafh = fopen("tmp.bn10000.3g.arpa", "r");
    ngram_trie_read_arpa(t, arpafh);
    fclose(arpafh);

    /* Test 1, 2, 3-gram probs without backoff. */
    test_lookups(t, lmath);

    /* Test adding nodes. */
    test_add_nodes(t, lmath);

    ngram_trie_free(t);

    dict_free(dict);
    logmath_free(lmath);
    bin_mdef_free(mdef);
    cmd_ln_free_r(config);

    return 0;
}
开发者ID:Jared-Prime,项目名称:cmusphinx,代码行数:54,代码来源:test_ngram_trie.c



注:本文中的dict_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dict_lookup函数代码示例发布时间:2022-05-30
下一篇:
C++ dict_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap