Python Forum
Problem processing items in list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem processing items in list
#3
Here is an example of refactoring
sieves = [
    ('login', 'login'),
    ('logon', 'login'),
    ('spam', 'spam'),
    ('unable answer call', 'call_qlty'),
    ('static', 'call_qlty'),
    ('silent', 'call_qlty'),
    ('report', 'report'),
    ('service level', 'report'),
    ('tool', 'tools'),
    ('email', 'email'),
    ('stuck', 'routing'),
    ('routing', 'routing'),
    ('edge device', 'hw'),
    ('facebook', 'social'),
    ('twitter', 'social'),
    ('social', 'social'),
    # 'other'
]

score = { counter: 0 for (_, counter) in sieves }
score['other'] = 0
rest = []
for x in vdescription_tokens:
    for keyword, counter in sieves:
        if keyword in x:
            score[counter] += 1
            break
    else:
        score['other'] += 1
        rest.append(x)
print(score)
print(rest)
Output:
{'social': 1, 'email': 8, 'login': 11, 'spam': 0, 'report': 2, 'other': 31, 'routing': 16, 'tools': 1, 'hw': 1, 'call_qlty': 3} ['help lockdown version', 'call center agent line issue', 'genesys concern', 'call comming', 'africa multichoice africa callcabinet alert smtp', 'genesys workspace error call destination invalid', 'genesys pure cloud query queue counting shift openning october', 'genesys concern', 'genesys genesysout service', 'randburg pure cloud interaction search', 'parameter', 'gotv', 'genesys service', 'eb primary gen server', 'unable extract interaction genesys', 'ivr audio upload', 'genesys dstv', 'pure cloud issue', 'lusaka ebrahim kayabwe contact center closed urgent', 'genesys cloud agent mapping', 'genesys call centre line', 'genesys auto answer', 'africa multichoice africa callcabinet alert smtp', 'genesys pure cloud query queue counting shift openning october', 'call cabinet computer updating call call cabinet', 'unable extract interaction genesys', 'call answer user chanilda vilanculos', 'genesys pure cloud automatic call handling unavailable', 'genesys dstv', 'pure cloud issue', 'lusaka ebrahim kayabwe contact center closed urgent']
Reply


Messages In This Thread
Problem processing items in list - by PythonNewbee - Nov-07-2020, 11:16 AM
RE: Problem processing items in list - by Gribouillis - Nov-07-2020, 08:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List processing speed Brettr 2 2,688 Jul-13-2018, 09:56 AM
Last Post: Brettr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020