Almost periodic subspaces related to operator semigroups