I keep thinking this might be best dealt with by new-UI developments, and hypertextual summation.
Internally, the game knows that the speaker (or spoken-to) is "#entity314159", knows that this entity is "an elf" with a given name it can give, may know that this is the last (if not only) elf to speak and so can be "the elf", in context, maybe know that this elf is darker skinned than #entity271828 who has since been assigned "the other elf" etc, etc.
As such, there can be a (semi-)intelligent wording to reflect "An elf: 'l'm starving'" and then "The lighter elf was inevitable!' to the darker elf...". The underlines (or other highlighting, or hover-only highlighting) would give hovertext hints as to additional details, as required[1], and right-click options to artfully reconfigure the treatments[2] given to this particular identification, that are also available (in advance of any cue speech) from the sprite.
Some of these bits of suggestions might have been influenced by my experience in a MUD with a very advanced system (mostly for commands) that allowed "kill first dog", "kiss tall man" or "take filligree ring from second backpack; examine it ; wear it" that NLPs your intent (of all dogs here, the first / of all men here, the (first) one described as tall / the first ring of that type found in the second backpack being worn/held, which can be be identified as 'it' until demoted by future targetting). This level of parsing-complexity of input isn't even an issue under DF, just some (semi-)smart understanding of what would be a sensible constructed version of description to present the player. Perhaps the simplest/shortest of the choices that remain unambiguous[3], which would mean speculatively juggling the various hard-coded options but presenting just the one that seems most apt (dynamically influenced by existing player-prefs in general and notes player-selections specific to this encounter) in the player interface.
For any text logs, of course, it'd have to leave permanent "The dwarf (Urist McUnfortunate, Peasant) was hit by the spinning vomit." or whatever non-barebones format might be usable. Maybe it can be reconfigured to/from just explicit names&titles, but don't expect it to retroactively relog, so might be safer to stick with a single sufficiently identifiable default.
[1] Perhaps even pop-up a summary of this specific entity's entire conversation-log so far, as addresser or addressee (for singular or group utterences).
[2] Identify by full name, configurable nickname, "<Race> #<number>, etc. Force a conversation-following sub-window (like the suggested pop-up in Footnote1, but additionally with player-DMing capability so long as the range is valid to broadly shout/normally talk/confidentially whisper a player-style response to them.
[3] Or not critically ambiguous. "A dwarf says:" for the first dwarf to have said anything, in an encounter, may be acceptible/preferable shortening to give, prior to the player conversing with "the dwarf" and establishing that this is "Urist McUristname the Legendary Pump Operator", not "Urist McOtherurist the (Dabbling) Mechanic", aka "the second dwarf", but practically indistinguishable/undifferentiatable to the recently arrived human adventurer in most practical ways.