After using Imbue Item, the imbued item's name has text added that says what gem was imbued into the item, e.g. "woolen robe of alchemy <4 citrine> (0 def, 0 armour)". The problem is the number included in "<4 citrine>". IIRC, this number is the number of citrines that were in my inventory before imbuing one citrine into the robe. In any case, this number is not meaningful, because only a single citrine gets imbued into the robe. So I think that this number should be omitted.
To fix this, I think you can just use
when calling gem:getName() for the ego's name and display_string, like the logPlayer call already uses.
EDIT: I think the number is actually the number of gems after one is imbued, not before. Either way, it's not relevant to the imbued item's stats.