# ACE ubertagger: how does it get initialized?

**URL:** <https://delphinqa.ling.washington.edu/t/ace-ubertagger-how-does-it-get-initialized/924>\
**Category:** ACE\
**Tags:** c-programming\
**Created:** [May 15, 2023, 11:20am UTC](https://delphinqa.ling.washington.edu/t/ace-ubertagger-how-does-it-get-initialized/924 "2023-05-15T11:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olzama](https://delphinqa.ling.washington.edu/user_avatar/delphinqa.ling.washington.edu/olzama/32/6_2.png) [@olzama](https://delphinqa.ling.washington.edu/u/olzama)\
**Post date:** [May 15, 2023, 11:20am UTC](https://delphinqa.ling.washington.edu/t/ace-ubertagger-how-does-it-get-initialized/924/1 "2023-05-15T11:20:38Z")

</div>

Hopefully this question is more meaningful than my previous one about the curly braces and indentation 🤦‍♀️

I figured out the answer while writing the question. I will post the answer right below.

Original issue:

I cannot figure out how the ubertagger gets initialized. the code that uses it is in `parse.c` and it is this:

```auto
	extern struct ubertagger	*the_ubertagger;
	extern int	enable_ubertagging;
	char *st_file = "supertags.txt";
	if(g_profiling)start_and_alloc_profiler(&ubertagging_profiler, "übertagging", parse_profiler, lexical_filtering_profiler);
	if(the_ubertagger && enable_ubertagging) 
	{
		printf("Lexical chart before ubertagging:\n");
		ubertag_lattice(the_ubertagger, lexical_chart, log(ubertagging_threshold));
		printf("Lexical chart after ubertagging:\n");
		print_lexical_chart(lexical_chart);
	}

```

I have found the place where the variable `enable_ubertagging` can be set to 1 but I cannot find where the ubertagger is set up. Or rather, I found this code but it doesn’t seem to be executed:

```auto
int	load_ubertagging()
{
	char	*expath = get_conf_file_path("übertag-emission-path")?:get_conf_file_path("ubertag-emission-path");
	char	*txpath = get_conf_file_path("übertag-transition-path")?:get_conf_file_path("ubertag-transition-path");
	char	*gmpath = get_conf_file_path("übertag-generic-map-path")?:get_conf_file_path("ubertag-generic-map-path");
	char	*wlpath = get_conf_file_path("übertag-whitelist-path")?:get_conf_file_path("ubertag-whitelist-path");

	if(!expath || !txpath || !gmpath)return -1;
	
	//the_ubertagger = load_ubertagger("/home/sweaglesw/cdev/erg-1214/ut/nanc_wsj_redwoods_noaffix.ex.gz","/home/sweaglesw/cdev/erg-1214/ut/nanc_wsj_redwoods_noaffix.tx.gz", "/home/sweaglesw/cdev/erg-1214/ut/generics.cfg");
	the_ubertagger = load_ubertagger(expath,txpath,gmpath);
	printf("loaded ubertagger\n");
	if(!the_ubertagger)return -1;
	the_ubertagger->whitelist = hash_new("ut-whitelist");
	if(wlpath)load_hashlist(the_ubertagger->whitelist, wlpath);
	return 0;
}

```

The above is from `ubertag.c`. I do not see this code being executed with any of the commands I try, e.g.

```auto
./ace -g ~/delphin/erg/trunk/ace/english-ut.dat sentences.txt --ubertagging=0.0001

```

– the ubertagging works but I don’t understand where and how the ubertagger gets set up/initialized. It is not the code from `ubertag.c` above.

The only call to `load_ubertagging()` is in `tdl.c`, in the function `load_grammar()`:

```auto
	if(get_conf("ubertag-emission-path") || get_conf("übertag-emission-path"))
		run_task("loading übertagger", load_ubertagging);

```

but as far as I can tell, this code never gets called. How is the ubertagger initialized?

---

<div class="post-metadata">

**Author:** ![olzama](https://delphinqa.ling.washington.edu/user_avatar/delphinqa.ling.washington.edu/olzama/32/6_2.png) [@olzama](https://delphinqa.ling.washington.edu/u/olzama)\
**Post date:** [May 15, 2023, 11:22am UTC](https://delphinqa.ling.washington.edu/t/ace-ubertagger-how-does-it-get-initialized/924/2 "2023-05-15T11:22:46Z")

</div>

Answer: When you compile the grammar with ACE, it gets “frozen”. It is during the grammar compilation that the ubertagger is created (and also serialized). Then when you run ACE to parse things, it uses the frozen grammar and the frozen supertagger. So the line of code which loads the supertagger in the parsing mode is this one:

```auto
recover_ubertagger(G->ubertagger);
...
void	recover_ubertagger(void	*u)
{
	the_ubertagger = u;
}

```

---

<div class="post-metadata">

**Author:** ![Dan](https://delphinqa.ling.washington.edu/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@Dan](https://delphinqa.ling.washington.edu/u/Dan)\
**Post date:** [May 15, 2023, 5:57pm UTC](https://delphinqa.ling.washington.edu/t/ace-ubertagger-how-does-it-get-initialized/924/3 "2023-05-15T17:57:31Z")

</div>

Just to elaborate, the ERG needs to be recompiled after making the following change to the standard ace/config.tdl file:

Remove the semicolon comment character from the beginning of the four lines toward the bottom of the file that appear right after the line “DPF 2019-11-20 - These next four should be uncommented for release”.
