Thank you Rachel. I will look at employing     .charAt(0)     on the key. I
do believe it is indeed a string. To your point, I suspect I am comparing a
character to a string.
What of the need to clean up the keys - stripping them of any extraneous
spaces so I get just the character itself in the key string? Anyone know a
way to work through the map and trim keys?


On Wed, Feb 22, 2023 at 7:57 AM Rachel Greenham <rac...@merus.eu> wrote:

> Are you sure you’re not comparing Strings to Characters at some point?
> Going @TypeChecked might reveal if and where that’s happening...
>
> --
> Rachel Greenham
> rac...@merus.eu
>
> On 22 Feb 2023, at 11:58, James McMahon <jsmcmah...@gmail.com> wrote:
>
> I have a Groovy list that holds the unicode representation of select
> foreign language characters, something like this simplified version:
>
> def myList = ['*\u00E4*','\u00D6','\u00F8']
>
> I have built myself a Groovy map that is the crosstabulation of characters
> by count in an incoming document, so my map looks something like this:
>
> crossTab = ["a" : "16736", "b" : "192", " * ä  *" : "18"]
>
> The foreign language characters in this map that are in the set of keys
> often have extra whitespace around them, and for certain languages there is
> a weird "right to left" thing going on that I don't quite fully understand.
>
> My objective: iterate through my list, return true if the element from the
> list is found as a key in the map, and return the count - the map value for
> that key - if the key is found. My problem: my lookup is failing to return
> any hits right now. I know that some of these foreign language characters
> are in my data. I suspect my lookup is failing because the keys are not
> clean representations of the foreign language characters.
>
> How do I modify my keys using Groovy to trim them of leading and trailing
> whitespace?
>
> Since my element from my list is expressed as unicode, how would I convert
> the trimmed key representation to unicode using Groovy?
>
> Thank you in advance for any help.
>
>
>

Reply via email to