I'm guessing they just compile associations from query history.
Like if you type "widget" - they check all past queries with a word widget in it and show you the list.
blue widget, nice widget, horny widget, etc...
To take it one level deeper:
In the secondary list they might pick the associated keywords and try to determine how broad they are.
blue widget -> blue, the word blue was used in a large number of queries without the word widget - it's too broad.
widgetspecattribute widget -> widgetspecattribute, mostly used with a word widget in the same query - it's not broad; get associations for the word widgetspecattribute.
The same priciple can be applied to the index database to see the word associations in the indexed documents instead of queries.