sudiptob2 / cf-stats

A github action based realtime Codeforces activity statistics card and badge generator for github readme
GNU General Public License v3.0
207 stars 40 forks source link

Update name slicer #40

Closed sudiptob2 closed 2 years ago

sudiptob2 commented 2 years ago

There are names such as MD Abdul Rahman Talukder. These names will be converted into MD by the slicer. We need to update the slicer so that it can slice the name in a more readable manner.

csemanish12 commented 2 years ago

since MD is a common first name, may be we can use both indexes (0 and 1) instead of just 0th index. we can treat it as a special case and create a dedicated method to handle slicing when 0th index has string "MD". I would be happy to add this logic. Let me know your thoughts @sudiptob2

sudiptob2 commented 2 years ago

Thanks much for looking into the issue :pray: I am thinking about a more generalized approach. If the given string is larger than the max_len we can generate the sliced string incrementally. I think that will be more resilient I am thinking about something like

string = string.split()
for token in string:
    if len(token ) + len(res) < max_len:
        res += token
return res

What do you think about this approach? @csemanish12

csemanish12 commented 2 years ago

Looks good enough to me. @sudiptob2

sudiptob2 commented 2 years ago

Great :rocket: Please also take care of the spaces between tokens while doing res += token.