extractGroups function

Extract the group and/or category weights