Nov-07-2020, 08:41 PM
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']